fix: quote packs, add preset settings to sidebar (WIP)

This commit is contained in:
David Ralph
2021-05-02 18:12:03 +01:00
parent f21ee5c5ba
commit f49cf1f65b
4 changed files with 21 additions and 25 deletions

View File

@@ -11,6 +11,7 @@ export default function Marketplace() {
<Tabs>
<div label={marketplace.photo_packs}><MarketplaceTab type='photo_packs'/></div>
<div label={marketplace.quote_packs}><MarketplaceTab type='quote_packs'/></div>
<div label={marketplace.preset_settings}><MarketplaceTab type='preset_settings'/></div>
</Tabs>
);
}

View File

@@ -67,6 +67,7 @@ function Tab(props) {
// Store
case marketplace.photo_packs: icon = <Background/>; break;
case marketplace.quote_packs: icon = <Quote/>; break;
case marketplace.preset_settings: icon = <Advanced/>; break;
case addons.added: icon = <Added/>; break;
case addons.sideload: icon = <Sideload/>; break;

View File

@@ -41,26 +41,6 @@ export default class Quote extends React.PureComponent {
});
}
getQuotePack() {
let quotePack = localStorage.getItem('quote_packs');
if (quotePack === 'undefined') {
return this.doOffline();
}
quotePack = JSON.parse(quotePack);
if (quotePack) {
const data = quotePack[Math.floor(Math.random() * quotePack.length)];
return this.setState({
quote: '"' + data.quote + '"',
author: data.author
});
} else {
this.doOffline();
}
}
async getQuote() {
const favouriteQuote = localStorage.getItem('favouriteQuote');
if (favouriteQuote) {
@@ -91,7 +71,23 @@ export default class Quote extends React.PureComponent {
author: quotePackAPI.author || data.author
});
} catch (e) {
return this.getQuotePack();
return this.doOffline();
}
}
let quotePack = localStorage.getItem('quote_packs');
if (quotePack !== null) {
quotePack = JSON.parse(quotePack);
if (quotePack) {
const data = quotePack[Math.floor(Math.random() * quotePack.length)];
return this.setState({
quote: '"' + data.quote + '"',
author: data.author
});
} else {
return this.doOffline();
}
}