Skip to content

Commit 3a4f42f

Browse files
committed
feat: add get() and getGroupsToAppend() methods to UserPreferences
1 parent fff1f31 commit 3a4f42f

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

rest-on-couch/UserPreferences.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,24 @@ class UserPreferences {
7171
}
7272
}
7373

74+
/**
75+
* Returns the current value of a preference key from the live API data.
76+
* @param {string} key
77+
* @returns {unknown}
78+
*/
79+
get(key) {
80+
const data = API.getData(this.varName);
81+
return data ? data[key] : undefined;
82+
}
83+
84+
/**
85+
* Returns the current list of groups to append for the logged-in user.
86+
* @returns {string[]}
87+
*/
88+
getGroupsToAppend() {
89+
return /** @type {string[]} */ (this.get('groupsToAppend') ?? []);
90+
}
91+
7492
/**
7593
* Saves current preferences to CouchDB.
7694
* @returns {Promise<void>}

0 commit comments

Comments
 (0)