A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: fix tag not updated on list item on rename
ammarahm-edcf2f4c4bbbab
diff --git a/apps/mobile/app/components/list-items/note/index.js b/apps/mobile/app/components/list-items/note/index.jsindex 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 (<><Viewdiff --git a/apps/mobile/app/components/list-items/note/wrapper.js b/apps/mobile/app/components/list-items/note/wrapper.jsindex 737f3bcf3..e005de3b4 100644--- a/apps/mobile/app/components/list-items/note/wrapper.js+++ b/apps/mobile/app/components/list-items/note/wrapper.js@@ -100,7 +100,7 @@ export const openNote = async (item, isTrash, setSelectedItem, isSheet) => {};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}>- <NoteItem item={item} dateBy={dateBy} tags={tags} isTrash={isTrash} />+ <NoteItem item={item} dateBy={dateBy} isTrash={isTrash} /></SelectionWrapper>);},@@ -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.jsindex 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 (<Itemitem={item}- tags={tags}dateBy={dateBy}index={index}type={type}@@ -168,7 +153,6 @@ const List = ({minWidth: 1};- const _keyExtractor = (item) => 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.jsindex 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"