Change prefix used for storing user preferences.

The `role` value no longer exists; we're replacing that with the
user ID.
This commit is contained in:
D. Berge
2025-07-12 11:23:55 +02:00
parent b035d3481c
commit dc294b5b50

View File

@@ -56,11 +56,11 @@ function setCredentials ({state, commit, getters, dispatch}, {force, token} = {}
* Save user preferences to localStorage and store.
*
* User preferences are identified by a key that gets
* prefixed with the user name and role. The value can
* prefixed with the user ID. The value can
* be anything that JSON.stringify can parse.
*/
function saveUserPreference ({state, commit}, [key, value]) {
const k = `${state.user?.name}.${state.user?.role}.${key}`;
const k = `${state.user?.id}.${key}`;
if (value !== undefined) {
localStorage.setItem(k, JSON.stringify(value));
@@ -79,7 +79,7 @@ function saveUserPreference ({state, commit}, [key, value]) {
async function loadUserPreferences ({state, commit}) {
// Get all keys which are of interest to us
const prefix = `${state.user?.name}.${state.user?.role}`;
const prefix = `${state.user?.id}`;
const keys = Object.keys(localStorage).filter( k => k.startsWith(prefix) );
// Build the preferences object