Skip to content

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

mobile: fix selection state causing delete to fail

Ammar Ahmed9a031a4a4368
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/index.js b/apps/mobile/app/components/list-items/selection-wrapper/index.js
index ffa55e8a6..6a6a25683 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/index.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/index.js
@@ -43,6 +43,9 @@ const SelectionWrapper = ({
const onLongPress = () => {
if (!useSelectionStore.getState().selectionMode) {
+ useSelectionStore.setState({
+ selectedItemsList: []
+ });
useSelectionStore.getState().setSelectionMode(true);
}
useSelectionStore.getState().setSelectedItem(item);
diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.js
index 9bc68848d..1b27dcff1 100644
--- a/apps/mobile/app/utils/functions.js
+++ b/apps/mobile/app/utils/functions.js
@@ -67,15 +67,10 @@ export const deleteItems = async (item, context) => {
});
return;
}
- if (
- item &&
- item.id &&
- useSelectionStore.getState().selectedItemsList.length === 0
- ) {
- useSelectionStore.getState().setSelectedItem(item);
- }
- const { selectedItemsList } = useSelectionStore.getState();
+ const selectedItemsList = item
+ ? [item]
+ : useSelectionStore.getState().selectedItemsList;
let notes = selectedItemsList.filter((i) => i.type === "note");
let notebooks = selectedItemsList.filter((i) => i.type === "notebook");
@@ -179,7 +174,9 @@ export const deleteItems = async (item, context) => {
});
}
Navigation.queueRoutesForUpdate();
- useSelectionStore.getState().clearSelection();
+ if (!item) {
+ useSelectionStore.getState().clearSelection();
+ }
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();
SearchService.updateAndSearch();