feat: per-admin localStorage namespacing with migration
Made-with: Cursor
This commit is contained in:
19
frontend/src/utils/adminPrefs.js
Normal file
19
frontend/src/utils/adminPrefs.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const PREF_KEYS = ['history-filter', 'history-show-limit'];
|
||||
|
||||
export function prefixKey(adminName, key) {
|
||||
if (!adminName) return key;
|
||||
return `${adminName}:${key}`;
|
||||
}
|
||||
|
||||
export function migratePreferences(adminName) {
|
||||
if (!adminName) return;
|
||||
|
||||
for (const key of PREF_KEYS) {
|
||||
const oldValue = localStorage.getItem(key);
|
||||
const newKey = prefixKey(adminName, key);
|
||||
if (oldValue !== null && localStorage.getItem(newKey) === null) {
|
||||
localStorage.setItem(newKey, oldValue);
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user