diff --git a/apps/mobile/app/components/list-items/note/index.js b/apps/mobile/app/components/list-items/note/index.js index 8a21c2b87..328c11a7c 100644 --- a/apps/mobile/app/components/list-items/note/index.js +++ b/apps/mobile/app/components/list-items/note/index.js @@ -81,10 +81,20 @@ function getNotebook(item) { return items; } +function getTags(item) { + const noteTags = item.tags?.slice(0, 3) || []; + const tags = []; + for (const tagName of noteTags) { + const tag = db.tags.tag(tagName); + if (!tag) continue; + tags.push(tag); + } + return tags; +} + const NoteItem = ({ item, isTrash, - tags, dateBy = "dateCreated", noOpen = false }) => { @@ -100,6 +110,7 @@ const NoteItem = ({ const reminders = db.relations.from(item, "reminder"); const reminder = getUpcomingReminder(reminders); const noteColor = COLORS_NOTE[item.color?.toLowerCase()]; + const tags = getTags(item); return ( <> { }; export const NoteWrapper = React.memo( - function NoteWrapper({ item, index, tags, dateBy, isSheet }) { + function NoteWrapper({ item, index, dateBy, isSheet }) { const isTrash = item.type === "trash"; const setSelectedItem = useSelectionStore((state) => state.setSelectedItem); @@ -113,7 +113,7 @@ export const NoteWrapper = React.memo( isSheet={isSheet} item={item} > - + ); }, @@ -125,10 +125,6 @@ export const NoteWrapper = React.memo( return false; } - if (JSON.stringify(prev.tags) !== JSON.stringify(next.tags)) { - return false; - } - if (prev.item !== next.item) { return false; } diff --git a/apps/mobile/app/components/list/index.js b/apps/mobile/app/components/list/index.js index 699a1e5e4..495f8b323 100644 --- a/apps/mobile/app/components/list/index.js +++ b/apps/mobile/app/components/list/index.js @@ -57,25 +57,10 @@ const RenderItem = ({ item, index, type, ...restArgs }) => { const dateBy = groupOptions.sortBy !== "title" ? groupOptions.sortBy : "dateEdited"; const totalNotes = getTotalNotes(item); - const tags = - item.tags - ?.slice(0, 3) - ?.map((item) => { - let tag = db.tags.tag(item); - - if (!tag) return null; - return { - title: tag.title, - id: tag.id, - alias: tag.alias - }; - }) - .filter((t) => t !== null) || []; return ( item.id || item.title; const ListView = ScrollComponent ? ScrollComponent : FlashList; return ( <> diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.js index 809fb51d3..3c2528b19 100644 --- a/apps/mobile/app/hooks/use-actions.js +++ b/apps/mobile/app/hooks/use-actions.js @@ -381,9 +381,11 @@ export const useActions = ({ close = () => null, item }) => { positivePress: async (value) => { if (!value || value === "" || value.trimStart().length == 0) return; await db.tags.rename(item.id, db.tags.sanitize(value)); - useTagStore.getState().setTags(); - useMenuStore.getState().setMenuPins(); - Navigation.queueRoutesForUpdate(); + setImmediate(() => { + useTagStore.getState().setTags(); + useMenuStore.getState().setMenuPins(); + Navigation.queueRoutesForUpdate(); + }); }, input: true, defaultValue: alias, @@ -426,24 +428,16 @@ export const useActions = ({ close = () => null, item }) => { ? "This reminder will be removed" : "This tag will be removed from all notes.", positivePress: async () => { - const routes = []; - routes.push( - "TaggedNotes", - "ColoredNotes", - "Notes", - "NotesPage", - "Reminders", - "Favorites" - ); if (item.type === "reminder") { await db.reminders.remove(item.id); } else { await db.tags.remove(item.id); - useTagStore.getState().setTags(); - routes.push("Tags"); } - Navigation.queueRoutesForUpdate(); - useRelationStore.getState().update(); + setImmediate(() => { + useTagStore.getState().setTags(); + Navigation.queueRoutesForUpdate(); + useRelationStore.getState().update(); + }); }, positiveText: "Delete", positiveType: "errorShade" @@ -505,12 +499,14 @@ export const useActions = ({ close = () => null, item }) => { negativeText: "Cancel", positivePress: async () => { await db.trash.delete(item.id); - Navigation.queueRoutesForUpdate(); - useSelectionStore.getState().setSelectionMode(false); - ToastEvent.show({ - heading: "Permanantly deleted items", - type: "success", - context: "local" + setImmediate(() => { + Navigation.queueRoutesForUpdate(); + useSelectionStore.getState().setSelectionMode(false); + ToastEvent.show({ + heading: "Permanantly deleted items", + type: "success", + context: "local" + }); }); }, positiveType: "errorShade"