Skip to content

Commit 086131e

Browse files
committed
feat: reload cards
1 parent f7b0db9 commit 086131e

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

src/base/vanilla/reloadCards.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eventManager.on(':loaded', () => {
2+
const fetchAllCards = global('fetchAllCards', { throws: false });
3+
if (!fetchAllCards) return;
4+
menu.addButton({
5+
text: 'Reload cards',
6+
action() {
7+
localStorage.removeItem('cardsVersion');
8+
fetchAllCards();
9+
},
10+
});
11+
});

src/hooks/translation.loaded.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ eventManager.on(':loaded', () => {
22
globalSet('translateElement', function translateElement(...args) {
33
eventManager.singleton.emit('translation:loaded');
44
return this.super(...args);
5+
}, {
6+
throws: false,
57
});
68
});

src/utils/plugin.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ wrap(() => {
1717
modules.forEach(({ name: prop, mod }) => {
1818
// eslint-disable-next-line no-prototype-builtins
1919
if (methods.hasOwnProperty(prop)) return console.error(`Skipping "${prop}": Already exists`);
20-
methods[prop] = mod(methods);
20+
const val = mod(methods);
21+
if (val !== undefined) {
22+
methods[prop] = val;
23+
}
2124
});
2225

2326
const plugin = Object.freeze(methods);

src/utils/settings.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ const settings = wrap(() => {
6666
if (setting.hidden) return null;
6767
const ret = $('<div>').addClass('flex-start');
6868
const key = setting.key;
69-
const current = localStorage.getItem(key) || getDefault(setting);
69+
const current = value(key);
7070
let el;
7171
let lf = true;
7272
if (setting.type === 'boolean') {
7373
lf = false;
7474
el = $(`<input type="checkbox" >`)
75-
.prop('checked', current === '1' || current === true);
75+
.prop('checked', current);
7676
} else if (setting.type === 'text') {
7777
el = $('<input type="text">')
7878
.val(current);
@@ -399,6 +399,9 @@ const settings = wrap(() => {
399399
}
400400
return val;
401401
}
402+
if (setting.type === 'boolean') {
403+
return false;
404+
}
402405
if (setting.type === 'select') {
403406
return setting.options[0];
404407
}

0 commit comments

Comments
 (0)