Skip to content

Commit

Permalink
feat: reload cards
Browse files Browse the repository at this point in the history
  • Loading branch information
feildmaster committed Sep 30, 2020
1 parent f7b0db9 commit 086131e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/base/vanilla/reloadCards.js
Original file line number Diff line number Diff line change
@@ -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();
},
});
});
2 changes: 2 additions & 0 deletions src/hooks/translation.loaded.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ eventManager.on(':loaded', () => {
globalSet('translateElement', function translateElement(...args) {
eventManager.singleton.emit('translation:loaded');
return this.super(...args);
}, {
throws: false,
});
});
5 changes: 4 additions & 1 deletion src/utils/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions src/utils/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const settings = wrap(() => {
if (setting.hidden) return null;
const ret = $('<div>').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 = $(`<input type="checkbox" >`)
.prop('checked', current === '1' || current === true);
.prop('checked', current);
} else if (setting.type === 'text') {
el = $('<input type="text">')
.val(current);
Expand Down Expand Up @@ -399,6 +399,9 @@ const settings = wrap(() => {
}
return val;
}
if (setting.type === 'boolean') {
return false;
}
if (setting.type === 'select') {
return setting.options[0];
}
Expand Down

0 comments on commit 086131e

Please sign in to comment.