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
fix menu items not updating on change
ammarahm-ede3b0eb415a88
diff --git a/apps/mobile/src/components/Menu/ColorSection.js b/apps/mobile/src/components/Menu/ColorSection.jsindex 9eeb9c8fe..177d6c447 100644--- a/apps/mobile/src/components/Menu/ColorSection.js+++ b/apps/mobile/src/components/Menu/ColorSection.js@@ -24,16 +24,19 @@ export const ColorSection = () => {}}, [loading]);- return colorNotes.map((item, index) => <ColorItem key={item.id} item={item} index={index} />);+ return colorNotes.map((item, index) => {+ let alias = db.colors.alias(item.id);+ return <ColorItem key={item.id} alias={alias} item={item} index={index} />;+ });};const ColorItem = React.memo(- ({ item, index }) => {+ ({ item, index, alias }) => {const [state] = useTracked();const { colors } = state;const setColorNotes = useMenuStore(state => state.setColorNotes);const [headerTextState, setHeaderTextState] = useState(null);- const alias = db.colors.alias(item.id);+ alias = db.colors.alias(item.id);const onHeaderStateChange = event => {setTimeout(() => {@@ -146,7 +149,10 @@ const ColorItem = React.memo();},(prev, next) => {+ if (prev.item?.dateModified !== next.item?.dateModified) return false;+ if (prev.alias !== next.alias) return false;if (prev.item?.id !== next.item?.id) return false;+return true;});diff --git a/apps/mobile/src/components/Menu/TagsSection.js b/apps/mobile/src/components/Menu/TagsSection.jsindex 96b71af4b..898f6f1f9 100644--- a/apps/mobile/src/components/Menu/TagsSection.js+++ b/apps/mobile/src/components/Menu/TagsSection.js@@ -67,6 +67,11 @@ export const TagsSection = () => {Navigation.closeDrawer();};+ const renderItem = ({ item, index }) => {+ let alias = item.type === 'tag' ? db.tags.alias(item.title) : item.title;+ return <PinItem item={item} index={index} alias={alias} onPress={onPress} />;+ };+return (<Viewstyle={{@@ -89,18 +94,18 @@ export const TagsSection = () => {flexGrow: 1}}keyExtractor={(item, index) => item.id}- renderItem={({ item, index }) => <PinItem item={item} index={index} onPress={onPress} />}+ renderItem={renderItem}/></View>);};export const PinItem = React.memo(- ({ item, index, onPress, placeholder }) => {+ ({ item, index, onPress, placeholder, alias }) => {const [state] = useTracked();const { colors } = state;const setMenuPins = useMenuStore(state => state.setMenuPins);- const alias = item.type === 'tag' ? db.tags.alias(item.title) : item.title;+ alias = item.type === 'tag' ? db.tags.alias(item.title) : item.title;const [visible, setVisible] = useState(false);const [headerTextState, setHeaderTextState] = useState(null);const color = headerTextState?.id === item.id ? colors.accent : colors.pri;@@ -234,6 +239,8 @@ export const PinItem = React.memo();},(prev, next) => {+ if (prev.alias !== next.alias) return false;+ if (prev.item?.dateModified !== next.item?.dateModified) return false;if (prev.item?.id !== next.item?.id) return false;return true;}diff --git a/apps/mobile/src/components/Properties/useActions.js b/apps/mobile/src/components/Properties/useActions.jsindex 08322a535..719feadbf 100644--- a/apps/mobile/src/components/Properties/useActions.js+++ b/apps/mobile/src/components/Properties/useActions.js@@ -350,6 +350,7 @@ export const useActions = ({ close = () => {}, item }) => {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.setRoutesToUpdate([Navigation.routeNames.Notes,Navigation.routeNames.NotesPage,