Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: use custom cache key for persist store

Ammar Ahmedd33f3c47690a
diff --git a/apps/mobile/app/components/sheets/move-notebook/index.tsx b/apps/mobile/app/components/sheets/move-notebook/index.tsx
index 1acefdbf8..d1d968801 100644
--- a/apps/mobile/app/components/sheets/move-notebook/index.tsx
+++ b/apps/mobile/app/components/sheets/move-notebook/index.tsx
@@ -54,7 +54,7 @@ const {
useNotebookExpandedStore,
useNotebookTreeStore,
useNotebookSelectionStore
-} = createNotebookTreeStores(false, false);
+} = createNotebookTreeStores(false, false, "move-notebook-tree-expanded");
export const MoveNotebookSheet = ({
selectedNotebooks,
@@ -293,13 +293,13 @@ const NotebookItemWrapper = React.memo(
index: number;
onPress: () => void;
}) => {
- const expanded = useSideMenuNotebookExpandedStore(
+ const expanded = useNotebookExpandedStore(
(state) => state.expanded[item.notebook.id]
);
- const selectionEnabled = useSideMenuNotebookSelectionStore(
+ const selectionEnabled = useNotebookSelectionStore(
(state) => state.enabled
);
- const selected = useSideMenuNotebookSelectionStore(
+ const selected = useNotebookSelectionStore(
(state) => state.selection[item.notebook.id] === "selected"
);
@@ -333,9 +333,7 @@ const NotebookItemWrapper = React.memo(
index={index}
expanded={expanded}
onToggleExpanded={async () => {
- useSideMenuNotebookExpandedStore
- .getState()
- .setExpanded(item.notebook.id);
+ useNotebookExpandedStore.getState().setExpanded(item.notebook.id);
if (!expanded) {
useNotebookTreeStore
.getState()
diff --git a/apps/mobile/app/stores/create-notebook-tree-stores.ts b/apps/mobile/app/stores/create-notebook-tree-stores.ts
index 87340461a..281d36209 100644
--- a/apps/mobile/app/stores/create-notebook-tree-stores.ts
+++ b/apps/mobile/app/stores/create-notebook-tree-stores.ts
@@ -44,7 +44,8 @@ function removeTreeItem(tree: TreeItem[], id: string) {
export function createNotebookTreeStores(
multiSelect: boolean,
- selectionEnabled: boolean
+ selectionEnabled: boolean,
+ persistKey?: string
) {
const useNotebookTreeStore = create<{
tree: TreeItem[];
@@ -207,7 +208,7 @@ export function createNotebookTreeStores(
}
}),
{
- name: "side-menu-notebook-expanded-v1",
+ name: persistKey || "side-menu-notebook-expanded",
getStorage: () => MMKV as unknown as StateStorage
}
)