branch-chat / src /utils /storage.js
suvadityamuk's picture
suvadityamuk HF Staff
fix: remove ghost text labels in graph view
7334a07
Raw
History Blame Contribute Delete
833 Bytes
const STORAGE_KEY = 'branchchat_state';
/**
* Load the full app state from LocalStorage.
* Returns null if nothing is stored or parsing fails.
*/
export function loadState() {
try {
const raw = localStorage.getItem(STORAGE_KEY);
if (!raw) return null;
return JSON.parse(raw);
} catch (err) {
console.warn('[Storage] Failed to load state:', err);
return null;
}
}
/**
* Save the full app state to LocalStorage.
*/
export function saveState(state) {
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
} catch (err) {
console.warn('[Storage] Failed to save state:', err);
}
}
/**
* Clear all stored state.
*/
export function clearState() {
try {
localStorage.removeItem(STORAGE_KEY);
} catch (err) {
console.warn('[Storage] Failed to clear state:', err);
}
}