optimize moving note performance

This commit is contained in:
ammarahm-ed
2021-02-15 11:09:01 +05:00
parent d6b138ab14
commit 7be721badb

View File

@@ -12,6 +12,7 @@ import {
sendNoteEditedEvent,
ToastEvent,
} from '../../services/EventManager';
import Navigation from '../../services/Navigation';
import {db} from '../../utils/DB';
import {
eOnNewTopicAdded,
@@ -58,11 +59,14 @@ const MoveNoteDialog = () => {
newTopicTitle = null;
newNotebookTitle = null;
setNote(null);
eSendEvent(refreshNotesPage);
eSendEvent(eOnNewTopicAdded);
Navigation.setRoutesToUpdate([
Navigation.routeNames.Notes,
Navigation.routeNames.Favorites,
Navigation.routeNames.NotesPage,
Navigation.routeNames.Notebook,
Navigation.routeNames.Notebooks,
]);
dispatch({type: Actions.CLEAR_SELECTION});
dispatch({type: Actions.NOTEBOOKS});
dispatch({type: Actions.NOTES});
};
const update = (note) => {
@@ -97,7 +101,7 @@ const MoveNoteComponent = ({close, note, setNote}) => {
});
notebookInput.current?.clear();
notebookInput.current?.blur();
dispatch({type: Actions.NOTEBOOKS});
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
};
const addNewTopic = async () => {
@@ -105,7 +109,7 @@ const MoveNoteComponent = ({close, note, setNote}) => {
return ToastEvent.show('Title is required', 'error', 'local');
}
await db.notebooks.notebook(expanded).topics.add(newTopicTitle);
dispatch({type: Actions.NOTEBOOKS});
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
topicInput.current?.clear();
topicInput.current?.blur();
newTopicTitle = null;
@@ -132,7 +136,7 @@ const MoveNoteComponent = ({close, note, setNote}) => {
forced: true,
});
}
dispatch({type: Actions.NOTEBOOKS});
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
return;
}
@@ -155,7 +159,7 @@ const MoveNoteComponent = ({close, note, setNote}) => {
forced: true,
});
}
dispatch({type: Actions.NOTEBOOKS});
Navigation.setRoutesToUpdate([Navigation.routeNames.Notebooks]);
};
return (