mirror of
https://github.com/NovaGM/ModuleBuilder.git
synced 2024-08-15 00:23:33 +00:00
[PCCompat] Rewrite to use seperate global dir and object, other structural changes
This commit is contained in:
parent
2584ce03c5
commit
61c94f40d3
8 changed files with 130 additions and 126 deletions
33
moduleWrappers/powercord/util/settings.js
Normal file
33
moduleWrappers/powercord/util/settings.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
export const settingStores = {};
|
||||
|
||||
export const makeStore = (key) => {
|
||||
settingStores[key] = new SimpleStore();
|
||||
};
|
||||
|
||||
class SimpleStore {
|
||||
constructor() {
|
||||
this.store = {};
|
||||
}
|
||||
|
||||
getSetting = (key, defaultValue) => {
|
||||
return this.store[key] ?? defaultValue;
|
||||
}
|
||||
|
||||
updateSetting = (key, value) => {
|
||||
if (value === undefined) {
|
||||
return this.toggleSetting(key);
|
||||
}
|
||||
|
||||
this.store[key] = value;
|
||||
}
|
||||
|
||||
toggleSetting = (key) => {
|
||||
this.store[key] = !this.store[key];
|
||||
}
|
||||
|
||||
deleteSetting = (key) => {
|
||||
delete this.store[key];
|
||||
}
|
||||
|
||||
getKeys = () => Object.keys(this.store)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue