mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): bound read-state localStorage growth and recover from quota errors (#1502)
Signed-off-by: Wes <wesbillman@users.noreply.github.com> Co-authored-by: Brain <21994759fc7a6fa6b965551d35cfd7897d262f2495467f2d78694ddcfa6a5c7e@sprout-oss.stage.blox.sqprod.co>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Workspace } from "./types";
|
||||
import { homeDir } from "@tauri-apps/api/path";
|
||||
import { setLocalStorageItemWithRecovery } from "@/shared/lib/localStorageQuota";
|
||||
|
||||
const WORKSPACES_KEY = "buzz-workspaces";
|
||||
const ACTIVE_WORKSPACE_KEY = "buzz-active-workspace-id";
|
||||
@@ -52,7 +53,7 @@ export function loadWorkspaces(): Workspace[] {
|
||||
return entry;
|
||||
}) as Workspace[];
|
||||
if (didStrip) {
|
||||
localStorage.setItem(WORKSPACES_KEY, JSON.stringify(cleaned));
|
||||
setLocalStorageItemWithRecovery(WORKSPACES_KEY, JSON.stringify(cleaned));
|
||||
}
|
||||
return cleaned;
|
||||
} catch {
|
||||
@@ -61,7 +62,7 @@ export function loadWorkspaces(): Workspace[] {
|
||||
}
|
||||
|
||||
export function saveWorkspaces(workspaces: Workspace[]): void {
|
||||
localStorage.setItem(WORKSPACES_KEY, JSON.stringify(workspaces));
|
||||
setLocalStorageItemWithRecovery(WORKSPACES_KEY, JSON.stringify(workspaces));
|
||||
}
|
||||
|
||||
export function clearWorkspaceStorage(): void {
|
||||
@@ -74,7 +75,7 @@ export function loadActiveWorkspaceId(): string | null {
|
||||
}
|
||||
|
||||
export function saveActiveWorkspaceId(id: string): void {
|
||||
localStorage.setItem(ACTIVE_WORKSPACE_KEY, id);
|
||||
setLocalStorageItemWithRecovery(ACTIVE_WORKSPACE_KEY, id);
|
||||
}
|
||||
|
||||
export function normalizeRelayUrl(url: string): string {
|
||||
|
||||
Reference in New Issue
Block a user