mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-17 03:19:59 +03:00
16 lines
460 B
TypeScript
16 lines
460 B
TypeScript
import { Brain } from "../types";
|
|
|
|
const BRAIN_LOCAL_STORAGE_KEY = "userBrains";
|
|
|
|
export const saveBrainInLocalStorage = (brain: Brain): void => {
|
|
localStorage.setItem(BRAIN_LOCAL_STORAGE_KEY, JSON.stringify(brain));
|
|
};
|
|
export const getBrainFromLocalStorage = (): Brain | undefined => {
|
|
const persistedBrain = localStorage.getItem(BRAIN_LOCAL_STORAGE_KEY);
|
|
if (persistedBrain === null) {
|
|
return;
|
|
}
|
|
|
|
return JSON.parse(persistedBrain) as Brain;
|
|
};
|