mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-24 23:49:33 +01:00
fix bug, duplicate notes created
This commit is contained in:
@@ -265,9 +265,10 @@ const Editor = ({noMenu}) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const setNoteInEditorAferSaving = (id, rId) => {
|
||||
if (id !== rId) {
|
||||
id = rId;
|
||||
const setNoteInEditorAferSaving = (oldId, currentId) => {
|
||||
console.log(oldId, currentId);
|
||||
if (oldId !== currentId) {
|
||||
id = currentId;
|
||||
note = db.notes.note(id);
|
||||
if (note) {
|
||||
note = note.data;
|
||||
@@ -295,15 +296,8 @@ const Editor = ({noMenu}) => {
|
||||
},
|
||||
id: id,
|
||||
});
|
||||
setNoteInEditorAferSaving(id, rId);
|
||||
|
||||
if (id) {
|
||||
await addToCollection(id);
|
||||
dispatch({
|
||||
type: ACTIONS.CURRENT_EDITING_NOTE,
|
||||
id: id,
|
||||
});
|
||||
}
|
||||
setNoteInEditorAferSaving(id, rId);
|
||||
|
||||
if (content.text.length < 200 || saveCounter < 2) {
|
||||
dispatch({
|
||||
@@ -312,11 +306,18 @@ const Editor = ({noMenu}) => {
|
||||
eSendEvent(refreshNotesPage);
|
||||
}
|
||||
|
||||
InfoBarRef.current?.setDateEdited(
|
||||
db.notes.note(id).data.dateEdited,
|
||||
content?.text?.split(' ').length,
|
||||
);
|
||||
InfoBarRef.current?.setDateCreated(db.notes.note(id).data.dateCreated);
|
||||
if (id) {
|
||||
await addToCollection(id);
|
||||
dispatch({
|
||||
type: ACTIONS.CURRENT_EDITING_NOTE,
|
||||
id: id,
|
||||
});
|
||||
InfoBarRef.current?.setDateEdited(
|
||||
db.notes.note(id).data.dateEdited,
|
||||
content?.text?.split(' ').length,
|
||||
);
|
||||
InfoBarRef.current?.setDateCreated(db.notes.note(id).data.dateCreated);
|
||||
}
|
||||
|
||||
saveCounter++;
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@ import SelectionHeader from '../../components/SelectionHeader';
|
||||
import {useTracked} from '../../provider';
|
||||
import {ACTIONS} from '../../provider/actions';
|
||||
import {eSendEvent} from '../../services/eventManager';
|
||||
import {DDS, ToastEvent} from '../../utils/utils';
|
||||
import {DDS, ToastEvent, db} from '../../utils/utils';
|
||||
import {eScrollEvent, eOnLoadNote} from '../../services/events';
|
||||
import {openEditorAnimation} from '../../utils/animations';
|
||||
import {sideMenuRef} from '../../utils/refs';
|
||||
|
||||
Reference in New Issue
Block a user