From b5f693e230591b5d3bd1884ac2268574d798ba8d Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 12 Dec 2021 22:31:51 +0100 Subject: [PATCH] feat: use blurHash when loading list backgrounds --- src/models/list.js | 3 ++- src/store/index.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/models/list.js b/src/models/list.js index b5a08e814..bd170aadc 100644 --- a/src/models/list.js +++ b/src/models/list.js @@ -20,7 +20,7 @@ export default class ListModel extends AbstractModel { this.owner = new UserModel(this.owner) - if(typeof this.subscription !== 'undefined' && this.subscription !== null) { + if (typeof this.subscription !== 'undefined' && this.subscription !== null) { this.subscription = new SubscriptionModel(this.subscription) } @@ -44,6 +44,7 @@ export default class ListModel extends AbstractModel { isFavorite: false, subscription: null, position: 0, + backgroundBlurHash: '', created: null, updated: null, diff --git a/src/store/index.js b/src/store/index.js index 250d9c60b..ef1c4b2f5 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,4 +1,5 @@ import {createStore} from 'vuex' +import {getBlobFromBlurHash} from '../helpers/getBlobFromBlurHash' import { BACKGROUND, CURRENT_LIST, @@ -128,10 +129,15 @@ export const store = createStore({ ) { if (currentList.backgroundInformation) { try { + const blurHash = await getBlobFromBlurHash(currentList.backgroundBlurHash) + if(blurHash) { + commit(BACKGROUND, window.URL.createObjectURL(blurHash)) + } + const listService = new ListService() const background = await listService.background(currentList) commit(BACKGROUND, background) - } catch(e) { + } catch (e) { console.error('Error getting background image for list', currentList.id, e) } }