import { safeGetItem, safeRemoveItem, safeSetItem } from "./safeStorage";

export const ACTIVE_THREADS_ACCOUNT_STORAGE_KEY = "haixun.active_threads_account_id";

export function persistActiveThreadsAccountId(accountId: string) {
  const trimmed = accountId.trim();
  if (!trimmed) {
    safeRemoveItem(ACTIVE_THREADS_ACCOUNT_STORAGE_KEY);
    return;
  }
  safeSetItem(ACTIVE_THREADS_ACCOUNT_STORAGE_KEY, trimmed);
}

export function readActiveThreadsAccountId() {
  return safeGetItem(ACTIVE_THREADS_ACCOUNT_STORAGE_KEY);
}
