fix: preset settings now work

This commit is contained in:
David Ralph
2021-05-03 12:05:21 +01:00
parent 6b4922b825
commit ed76fcccc8
12 changed files with 27 additions and 29 deletions

View File

@@ -129,7 +129,6 @@ p.description {
cursor: pointer;
width: 2rem !important;
height: 2rem !important;
margin-left: -8px;
&:hover {
color: grey;

View File

@@ -37,10 +37,20 @@ export default class Quote extends React.PureComponent {
// Set the quote
this.setState({
quote: '"' + quote.quote + '"',
author: quote.author
author: quote.author,
authorlink: this.getAuthorLink(quote.author)
});
}
getAuthorLink(author) {
let authorlink = `https://${window.languagecode.split('_')[0]}.wikipedia.org/wiki/${author.split(' ').join('_')}`;
if (localStorage.getItem('authorLink') === 'false' || author === 'Unknown') {
authorlink = null;
}
return authorlink;
}
async getQuote() {
const offline = (localStorage.getItem('offlineMode') === 'true');
@@ -48,17 +58,21 @@ export default class Quote extends React.PureComponent {
if (favouriteQuote) {
return this.setState({
quote: favouriteQuote.split(' - ')[0],
author: favouriteQuote.split(' - ')[1]
author: favouriteQuote.split(' - ')[1],
authorlink: this.getAuthorLink(data.author)
});
}
switch (localStorage.getItem('quoteType') || 'api') {
case 'custom':
const customQuote = localStorage.getItem('customQuote');
const customQuoteAuthor = localStorage.getItem('customQuoteAuthor');
if (customQuote) {
return this.setState({
quote: '"' + customQuote + '"',
author: localStorage.getItem('customQuoteAuthor'),
author: customQuoteAuthor,
authorlink: this.getAuthorLink(customQuote),
type: 'custom'
});
}
@@ -72,9 +86,12 @@ export default class Quote extends React.PureComponent {
if (quotePackAPI) {
try {
const data = await (await fetch(quotePackAPI.url)).json();
const author = data[quotePackAPI.author] || quotePackAPI.author;
return this.setState({
quote: '"' + data[quotePackAPI.quote] + '"',
author: data[quotePackAPI.author] || quotePackAPI.author,
author: author,
authorlink: this.getAuthorLink(author),
type: 'quote_pack'
});
} catch (e) {
@@ -92,6 +109,7 @@ export default class Quote extends React.PureComponent {
return this.setState({
quote: '"' + data.quote + '"',
author: data.author,
authorlink: this.getAuthorLink(data.author),
type: 'quote_pack'
});
} else {
@@ -114,15 +132,12 @@ export default class Quote extends React.PureComponent {
return this.doOffline();
}
let authorlink = `https://${window.languagecode.split('_')[0]}.wikipedia.org/wiki/${data.author.split(' ').join('_')}`;
if (localStorage.getItem('authorLink') === 'false' || data.author === 'Unknown') {
authorlink = null;
}
console.log(this.getAuthorLink(data.author))
this.setState({
quote: '"' + data.quote + '"',
author: data.author,
authorlink: authorlink,
authorlink: this.getAuthorLink(data.author),
quoteLanguage: quotelanguage,
type: 'api'
});

View File

@@ -1,5 +1,3 @@
import { toast } from 'react-toastify';
import EventBus from './eventbus';
export default class MarketplaceFunctions {
@@ -32,12 +30,7 @@ export default class MarketplaceFunctions {
EventBus.dispatch('refresh', 'marketplacebackgrounduninstall');
break;
default:
try {
localStorage.removeItem(type);
} catch (e) {
toast('Failed to uninstall addon, check the console');
console.error(e);
}
break;
}
let installed = JSON.parse(localStorage.getItem('installed'));
@@ -64,8 +57,8 @@ export default class MarketplaceFunctions {
});
localStorage.setItem('backup_settings', JSON.stringify(oldSettings));
input.settings.forEach((element) => {
localStorage.setItem(element.name, element.value);
Object.keys(input.settings).forEach((key) => {
localStorage.setItem(key, input.settings[key]);
});
break;

View File

@@ -316,7 +316,6 @@
"photo_packs": "Fotopakete",
"quote_packs": "Zitat-Pakete",
"preset_settings": "Voreingestellte Einstellungen",
"themes": "Themen",
"no_items": "Keine Einträge in dieser Kategorie",
"product": {
"overview": "Übersicht",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Photo Packs",
"quote_packs": "Quote Packs",
"preset_settings": "Preset Settings",
"themes": "Themes",
"no_items": "No items in this category",
"product": {
"overview": "Overview",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Photo Packs",
"quote_packs": "Quote Packs",
"preset_settings": "Preset Settings",
"themes": "Themes",
"no_items": "No items in this category",
"product": {
"overview": "Overview",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Paquetes de fotos",
"quote_packs": "Paquetes de citas",
"preset_settings": "Ajustes preestablecidos",
"themes": "Tema",
"no_items": "No hay artículos en esta categoría",
"product": {
"overview": "Vista general",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Packs Photos",
"quote_packs": "Packs Citations",
"preset_settings": "Paramètres prédéfinis",
"themes": "Thèmes",
"no_items": "Aucun article dans cette catégorie",
"product": {
"overview": "Aperçu",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Fotoverzamelingen",
"quote_packs": "Citaatverzamelingen",
"preset_settings": "Voorinstellingen",
"themes": "Thema's",
"no_items": "No items in this category",
"product": {
"overview": "Overzicht",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Bilde pakker",
"quote_packs": "Sitat pakker",
"preset_settings": "Preset instillinger",
"themes": "Themes",
"no_items": "No items in this category",
"product": {
"overview": "Oversikt",

View File

@@ -316,7 +316,6 @@
"photo_packs": "Наборы фото",
"quote_packs": "Наборы цитат",
"preset_settings": "Пресеты настроек",
"themes": "Темы",
"no_items": "No items in this category",
"product": {
"overview": "Обзор",

View File

@@ -316,7 +316,6 @@
"photo_packs": "图片包",
"quote_packs": "名言包",
"preset_settings": "预设设定",
"themes": "主题",
"no_items": "No items in this category",
"product": {
"overview": "总览",