mobile: exit current topic if it is deleted.

This commit is contained in:
ammarahm-ed
2023-04-01 13:21:07 +05:00
committed by Abdullah Atta
parent 234e368c4d
commit fb56e7c866
2 changed files with 8 additions and 3 deletions

View File

@@ -181,8 +181,9 @@ const NotesPage = ({
if (isNew) setLoadingNotes(true);
const notes = get(params.current, true) as NoteType[];
if (
(item.type === "tag" || item.type === "color") &&
(!notes || notes.length === 0)
((item.type === "tag" || item.type === "color") &&
(!notes || notes.length === 0)) ||
(item.type === "topic" && !notes)
) {
return Navigation.goBack();
}

View File

@@ -75,7 +75,11 @@ export const TopicNotes = ({
TopicNotes.get = (params: NotesScreenParams, grouped = true) => {
const { id, notebookId } = params.item as TopicType;
const notes = db.notebooks?.notebook(notebookId)?.topics.topic(id)?.all || [];
const topic = db.notebooks?.notebook(notebookId)?.topics.topic(id);
if (!topic) {
return null;
}
const notes = topic?.all || [];
return grouped
? groupArray(notes, db.settings?.getGroupOptions("notes"))
: notes;