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);
    }
  }
}
