Skip to content

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

mobile: unlink note from previous notebook in single-select mode

kashaf-ansari-devc89e333c113a
diff --git a/apps/mobile/app/screens/link-notebooks/index.tsx b/apps/mobile/app/screens/link-notebooks/index.tsx
index 7dc7598dc..4de77c6b8 100644
--- a/apps/mobile/app/screens/link-notebooks/index.tsx
+++ b/apps/mobile/app/screens/link-notebooks/index.tsx
@@ -163,7 +163,20 @@ const LinkNotebooks = (props: NavigationProps<"LinkNotebooks">) => {
}, [noteIds]);
const onSave = async () => {
- const changedNotebooks = useNotebookSelectionStore.getState().selection;
+ const selectionState = useNotebookSelectionStore.getState();
+ const changedNotebooks = { ...selectionState.selection };
+
+ if (!selectionState.multiSelect) {
+ for (const id in selectionState.initialState) {
+ if (
+ selectionState.initialState[id] === "selected" &&
+ changedNotebooks[id] !== "selected"
+ ) {
+ changedNotebooks[id] = "deselected";
+ }
+ }
+ }
+
for (const id in changedNotebooks) {
const item = await db.notebooks.notebook(id);
if (!item) continue;
@@ -207,11 +220,11 @@ const LinkNotebooks = (props: NavigationProps<"LinkNotebooks">) => {
rightButton={
hasSelection
? {
- name: "restore",
- onPress: () => {
- updateInitialSelectionState(noteIds);
- }
+ name: "restore",
+ onPress: () => {
+ updateInitialSelectionState(noteIds);
}
+ }
: undefined
}
/>