diff --git a/src/base/vanilla/reloadCards.js b/src/base/vanilla/reloadCards.js new file mode 100644 index 00000000..287fc1ad --- /dev/null +++ b/src/base/vanilla/reloadCards.js @@ -0,0 +1,11 @@ +eventManager.on(':loaded', () => { + const fetchAllCards = global('fetchAllCards', { throws: false }); + if (!fetchAllCards) return; + menu.addButton({ + text: 'Reload cards', + action() { + localStorage.removeItem('cardsVersion'); + fetchAllCards(); + }, + }); +}); diff --git a/src/hooks/translation.loaded.js b/src/hooks/translation.loaded.js index 1c41dbf2..7936f54b 100644 --- a/src/hooks/translation.loaded.js +++ b/src/hooks/translation.loaded.js @@ -2,5 +2,7 @@ eventManager.on(':loaded', () => { globalSet('translateElement', function translateElement(...args) { eventManager.singleton.emit('translation:loaded'); return this.super(...args); + }, { + throws: false, }); }); diff --git a/src/utils/plugin.js b/src/utils/plugin.js index c6fb3d3e..d47189d6 100644 --- a/src/utils/plugin.js +++ b/src/utils/plugin.js @@ -17,7 +17,10 @@ wrap(() => { modules.forEach(({ name: prop, mod }) => { // eslint-disable-next-line no-prototype-builtins if (methods.hasOwnProperty(prop)) return console.error(`Skipping "${prop}": Already exists`); - methods[prop] = mod(methods); + const val = mod(methods); + if (val !== undefined) { + methods[prop] = val; + } }); const plugin = Object.freeze(methods); diff --git a/src/utils/settings.js b/src/utils/settings.js index 2d6dbb87..c8b84d80 100644 --- a/src/utils/settings.js +++ b/src/utils/settings.js @@ -66,13 +66,13 @@ const settings = wrap(() => { if (setting.hidden) return null; const ret = $('
').addClass('flex-start'); const key = setting.key; - const current = localStorage.getItem(key) || getDefault(setting); + const current = value(key); let el; let lf = true; if (setting.type === 'boolean') { lf = false; el = $(``) - .prop('checked', current === '1' || current === true); + .prop('checked', current); } else if (setting.type === 'text') { el = $('') .val(current); @@ -399,6 +399,9 @@ const settings = wrap(() => { } return val; } + if (setting.type === 'boolean') { + return false; + } if (setting.type === 'select') { return setting.options[0]; }