You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GooseMod/src/gmSettings.js

49 lines
956 B

const defaultSettings = {
changelog: true,
separators: true,
gmBadges: true,
attrs: false,
home: true,
devchannel: false,
snippets: false,
autoupdate: true,
newModuleNotifications: false,
placeholderimage: false,
collapsiblehome: true,
allThemeSettings: false,
debugToasts: false
};
const loadStore = () => {
const loaded = JSON.parse(goosemod.storage.get('goosemodGMSettings')) || {};
return {
...defaultSettings,
...loaded,
get: () => target // gmSettings.get compat (because of all theme settings using old)
};
};
const target = { uninit: true };
export default new Proxy({ uninit: true }, {
get(target, prop) {
if (target.uninit) target = loadStore();
return target[prop] ?? false;
},
set(target, prop, value) {
if (target.uninit) target = loadStore();
target[prop] = value;
goosemod.storage.set('goosemodGMSettings', JSON.stringify(target));
return true;
}
});