Added collapsible skill group & volatile storage.
This commit is contained in:
39
system/scripts/storage.js
Normal file
39
system/scripts/storage.js
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Volatile Storage - Store things like collapsible state (refresh kill it)
|
||||
*/
|
||||
export class Storage {
|
||||
store = new Map();
|
||||
|
||||
/**
|
||||
* Get list of active keys for this app
|
||||
* @param {string} app
|
||||
* @return {string[]}
|
||||
*/
|
||||
getAppKeys(app) {
|
||||
if (!this.store.has(app)) {
|
||||
return [];
|
||||
}
|
||||
return Array.from(this.store.get(app).keys());
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle a key for this app
|
||||
* @param {string} app app name, ex "actor-Zca44Nv7ydMcNN9p"
|
||||
* @param {string} key Key name, ex "toggle-skill-category-martial"
|
||||
*/
|
||||
toggleKey(app, key) {
|
||||
if (this.store.has(app)) {
|
||||
const appMap = this.store.get(app);
|
||||
if (appMap.has(key)) {
|
||||
appMap.delete(key);
|
||||
} else {
|
||||
appMap.set(key, true);
|
||||
}
|
||||
} else {
|
||||
// Create app map
|
||||
const appMap = new Map();
|
||||
appMap.set(key, true);
|
||||
this.store.set(app, appMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user