mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-21 22:19:41 +01:00
fix multi select notebook add not working
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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={{
|
||||
|
||||
Reference in New Issue
Block a user