Skip to content

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

fix multi select notebook add not working

ammarahm-edf7b166ec1c67
diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js
index 67d688c39..8580287a1 100644
--- a/apps/mobile/src/components/MoveNoteDialog/index.js
+++ b/apps/mobile/src/components/MoveNoteDialog/index.js
@@ -137,6 +137,43 @@ const IntComponent = ({close, note, setNote}) => {
newTopicTitle = null;
};
+ const handlePress = async () => {
+ if (
+ note?.notebooks?.findIndex(
+ (o) =>
+ o.topics.findIndex((i) => {
+ return i === item.id;
+ }) > -1,
+ ) > -1
+ ) {
+ await db.notebooks
+ .notebook(item.notebookId)
+ .topics.topic(item.id)
+ .delete(note.id);
+
+ if (note && note.id) {
+ setNote({...db.notes.note(note.id).data});
+ }
+ dispatch({type: Actions.NOTEBOOKS});
+ return;
+ }
+
+ let noteIds = [];
+ selectedItemsList.forEach((i) => noteIds.push(i.id));
+ console.log(noteIds, 'NOTE IDS');
+ await db.notes.move(
+ {
+ topic: item.id,
+ id: item.notebookId,
+ },
+ ...noteIds,
+ );
+ if (note && note.id) {
+ setNote({...db.notes.note(note.id).data});
+ }
+ dispatch({type: Actions.NOTEBOOKS});
+ };
+
return (
<>
<View>
@@ -361,42 +398,7 @@ const IntComponent = ({close, note, setNote}) => {
}
renderItem={({item, index}) => (
<PressableButton
- onPress={async () => {
- if (
- note?.notebooks?.findIndex(
- (o) =>
- o.topics.findIndex((i) => {
- return i === item.id;
- }) > -1,
- ) > -1
- ) {
- await db.notebooks
- .notebook(item.notebookId)
- .topics.topic(item.id)
- .delete(note.id);
-
- if (note && note.id) {
- setNote({...db.notes.note(note.id).data});
- }
- dispatch({type: Actions.NOTEBOOKS});
- return;
- }
-
- let noteIds = [];
- selectedItemsList.forEach((i) => noteIds.push(i.id));
- await db.notes.move(
- {
- topic: item.id,
- id: item.notebookId,
- },
- ...noteIds,
- );
- console.log(item.id, item.notebookId);
- if (note && note.id) {
- setNote({...db.notes.note(note.id).data});
- }
- dispatch({type: Actions.NOTEBOOKS});
- }}
+ onPress={handlePress}
type="gray"
customStyle={{
height: 50,
diff --git a/apps/mobile/src/components/SelectionHeader/index.js b/apps/mobile/src/components/SelectionHeader/index.js
index beec3c12a..ca0164dde 100644
--- a/apps/mobile/src/components/SelectionHeader/index.js
+++ b/apps/mobile/src/components/SelectionHeader/index.js
@@ -9,6 +9,7 @@ import {eSendEvent, ToastEvent} from '../../services/EventManager';
import {db} from '../../utils/DB';
import {eOpenMoveNoteDialog, eOpenSimpleDialog} from '../../utils/Events';
import {SIZE} from '../../utils/SizeUtils';
+import {sleep} from '../../utils/TimeUtils';
import {ActionIcon} from '../ActionIcon';
import {TEMPLATE_DELETE} from '../DialogManager/Templates';
import Heading from '../Typography/Heading';
@@ -101,9 +102,9 @@ export const SelectionHeader = () => {
}}>
{currentScreen === 'trash' || currentScreen === 'notebooks' ? null : (
<ActionIcon
- onPress={() => {
+ onPress={async () => {
dispatch({type: Actions.SELECTION_MODE, enabled: false});
- dispatch({type: Actions.CLEAR_SELECTION});
+ await sleep(100);
eSendEvent(eOpenMoveNoteDialog);
}}
customStyle={{