From b93302153ed71c836b695def0146cbd34c1ca9bd Mon Sep 17 00:00:00 2001 From: Isaac Date: Wed, 24 Aug 2022 21:41:22 +0100 Subject: [PATCH] fix: addons not being uninstalled correctly --- .../widgets/background/Background.jsx | 8 +++- src/components/widgets/quote/Quote.jsx | 40 +++++++++---------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/components/widgets/background/Background.jsx b/src/components/widgets/background/Background.jsx index 721e6b3e..3937407d 100644 --- a/src/components/widgets/background/Background.jsx +++ b/src/components/widgets/background/Background.jsx @@ -244,7 +244,13 @@ export default class Background extends PureComponent { return setFavourited(photofavourited); } - const photoPack = JSON.parse(localStorage.getItem('photo_packs')); + const photoPack = []; + const installed = JSON.parse(localStorage.getItem('installed')); + installed.forEach(item => { + if (item.type === 'photos') { + photoPack.push(...item.photos) + } + }); if (photoPack) { const randomPhoto = photoPack[Math.floor(Math.random() * photoPack.length)]; return this.setState({ diff --git a/src/components/widgets/quote/Quote.jsx b/src/components/widgets/quote/Quote.jsx index c39ea1bb..71445506 100644 --- a/src/components/widgets/quote/Quote.jsx +++ b/src/components/widgets/quote/Quote.jsx @@ -236,29 +236,29 @@ export default class Quote extends PureComponent { return this.doOffline(); } } + const quotePack = []; + const installed = JSON.parse(localStorage.getItem('installed')); + installed.forEach(item => { + if (item.type === 'quotes') { + quotePack.push(...item.quotes) + } + }); - let quotePack = localStorage.getItem('quote_packs'); + if (quotePack) { + const data = quotePack[Math.floor(Math.random() * quotePack.length)]; + const installed = JSON.parse(localStorage.getItem('installed')); + // todo: make this actually get the correct quote pack, instead of the first available + const info = installed.find((i) => i.type === 'quotes'); - if (quotePack !== null) { - quotePack = JSON.parse(quotePack); - - if (quotePack) { - const data = quotePack[Math.floor(Math.random() * quotePack.length)]; - const installed = JSON.parse(localStorage.getItem('installed')); - // todo: make this actually get the correct quote pack, instead of the first available - const info = installed.find((i) => i.type === 'quotes'); - - return this.setState({ - quote: '"' + data.quote + '"', - author: data.author, - authorlink: this.getAuthorLink(data.author), - authorimg: info.icon_url, - }); - } else { - return this.doOffline(); - } + return this.setState({ + quote: '"' + data.quote + '"', + author: data.author, + authorlink: this.getAuthorLink(data.author), + authorimg: info.icon_url, + }); + } else { + return this.doOffline(); } - break; case 'api': if (offline) { return this.doOffline();