fix bug, duplicate notes created

This commit is contained in:
ammarahm-ed
2020-04-26 09:18:53 +05:00
parent d3ff3eb060
commit e5e1bc83da
2 changed files with 18 additions and 17 deletions

View File

@@ -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 {

View File

@@ -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';