quivr/frontend/lib/context/BrainConfigProvider/helpers/brainConfigLocalStorage.ts

22 lines
576 B
TypeScript
Raw Normal View History

/* eslint-disable */
import { BrainConfig } from "../types";
const BRAIN_CONFIG_LOCAL_STORAGE_KEY = "userBrainConfig";
export const saveBrainConfigInLocalStorage = (updatedConfig: BrainConfig) => {
localStorage.setItem(
BRAIN_CONFIG_LOCAL_STORAGE_KEY,
JSON.stringify(updatedConfig)
);
};
export const getBrainConfigFromLocalStorage = (): BrainConfig | undefined => {
const persistedBrainConfig = localStorage.getItem(
BRAIN_CONFIG_LOCAL_STORAGE_KEY
);
if (persistedBrainConfig === null) {
return;
}
return JSON.parse(persistedBrainConfig);
};