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
use alias from item
Ammar Ahmeddfcff8633cd7
diff --git a/apps/mobile/src/components/listitems/tag/index.js b/apps/mobile/src/components/listitems/tag/index.jsindex 7ccb49129..ade16282d 100644--- a/apps/mobile/src/components/listitems/tag/index.js+++ b/apps/mobile/src/components/listitems/tag/index.js@@ -48,7 +48,7 @@ const TagItem = React.memo(>#</Heading>- {db.tags.alias(item.id)}+ {item.alias}</Heading><Paragraphcolor={colors.icon}diff --git a/apps/mobile/src/components/properties/index.js b/apps/mobile/src/components/properties/index.jsindex c4154d2b2..1948648ed 100644--- a/apps/mobile/src/components/properties/index.js+++ b/apps/mobile/src/components/properties/index.js@@ -16,17 +16,13 @@ import { Synced } from './synced';import { Tags } from './tags';import { Topics } from './topics';import SearchService from '../../services/search';+import { COLORS_NOTE } from '../../utils/color-scheme';export const Properties = ({ close = () => {}, item, buttons = [], getRef }) => {const colors = useThemeStore(state => state.colors);- const alias = item- ? item.type === 'tag'- ? db.tags.alias(item.id)- : item.type === 'color'- ? db.colors.alias(item.id)- : item.title- : null;+ const alias = item.alias || item.title;+ const isColor = !!COLORS_NOTE[item.title];const onScrollEnd = () => {getRef().current?.handleChildScrollEnd();@@ -62,7 +58,11 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>}}><Heading size={SIZE.lg}>- {item.type === 'tag' ? '#' : null}+ {item.type === 'tag' && !isColor ? (+ <Heading size={SIZE.xl} color={colors.accent}>+ #+ </Heading>+ ) : null}{alias}</Heading>diff --git a/apps/mobile/src/components/sidemenu/pinnedsection.js b/apps/mobile/src/components/sidemenu/pinnedsection.jsindex 650481b7b..0a501415b 100644--- a/apps/mobile/src/components/sidemenu/pinnedsection.js+++ b/apps/mobile/src/components/sidemenu/pinnedsection.js@@ -47,7 +47,7 @@ export const TagsSection = React.memo(});};const renderItem = ({ item, index }) => {- let alias = item ? (item.type === 'tag' ? db.tags.alias(item.title) : item.title) : null;+ let alias = item.alias || item.title;return <PinItem item={item} index={index} alias={alias} onPress={onPress} />;};@@ -85,7 +85,7 @@ export const PinItem = React.memo(({ item, index, onPress, placeholder, alias }) => {const colors = useThemeStore(state => state.colors);const setMenuPins = useMenuStore(state => state.setMenuPins);- alias = !item ? '' : item.type === 'tag' ? db.tags.alias(item.title) : item.title;+ alias = item?.alias || item?.title;const [visible, setVisible] = useState(false);const [headerTextState, setHeaderTextState] = useState(null);const color = headerTextState?.id === item.id ? colors.accent : colors.pri;diff --git a/apps/mobile/src/screens/home/index.tsx b/apps/mobile/src/screens/home/index.tsxindex 08c9b3aa0..c9eab6de4 100755--- a/apps/mobile/src/screens/home/index.tsx+++ b/apps/mobile/src/screens/home/index.tsx@@ -33,6 +33,7 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {const loading = useNoteStore(state => state.loading);const isFocused = useNavigationFocus(navigation, {onFocus: prev => {+ console.log('updating', route.name, 'on focus');Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);useNavigationStore.getState().update({name: route.namediff --git a/apps/mobile/src/screens/notes/common.ts b/apps/mobile/src/screens/notes/common.tsindex 2a0e193c2..6e01a64d9 100644--- a/apps/mobile/src/screens/notes/common.ts+++ b/apps/mobile/src/screens/notes/common.ts@@ -15,13 +15,8 @@ export function toCamelCase(title: string) {export function getAlias(params: NotesScreenParams) {if (!params) return '';const { item } = params;- let alias =- item.type === 'tag'- ? db.tags?.alias(item.id)- : item.type === 'color'- ? db.colors?.alias(item.id)- : params?.title;- return alias || item.title;+ //@ts-ignore+ return item.alias || item.title;}export function openMonographsWebpage() {@@ -78,7 +73,6 @@ export function isSynced(params: NotesScreenParams) {async function onNoteCreated(id: string, params: FirstSaveData) {if (!params) return;-switch (params.type) {case 'topic': {await db.notes?.move(diff --git a/apps/mobile/src/screens/notes/index.tsx b/apps/mobile/src/screens/notes/index.tsxindex 489d74ccf..2ec6fc0fd 100644--- a/apps/mobile/src/screens/notes/index.tsx+++ b/apps/mobile/src/screens/notes/index.tsx@@ -50,6 +50,14 @@ export interface RouteProps<T extends RouteName> extends NavigationProps<T> {rightButtons?: (params: NotesScreenParams) => HeaderRightButton[];}+function getItemType(routeName: RouteName) {+ if (routeName === 'TaggedNotes') return 'tag';+ if (routeName === 'ColoredNotes') return 'color';+ if (routeName === 'TopicNotes') return 'topic';+ if (routeName === 'Monographs') return 'monograph';+ return 'note';+}+const NotesPage = ({route,navigation,@@ -108,7 +116,7 @@ const NotesPage = ({!isMonograph &&setOnFirstSave({- type: item.type,+ type: getItemType(route.name),id: item.id,color: item.title,//@ts-ignorediff --git a/apps/mobile/src/services/navigation.ts b/apps/mobile/src/services/navigation.tsindex 7b108da77..0e90c9336 100755--- a/apps/mobile/src/services/navigation.ts+++ b/apps/mobile/src/services/navigation.ts@@ -109,7 +109,7 @@ function clearRouteFromQueue(routeName: Route) {* Check if a route needs update*/function routeNeedsUpdate(routeName: Route, callback: () => void) {- console.log('routeName', routesUpdateQueue);+ console.log('routeNeedsUpdate', routesUpdateQueue, routesUpdateQueue.indexOf(routeName));if (routesUpdateQueue.indexOf(routeName) > -1) {clearRouteFromQueue(routeName);console.log('CALL ROUTE UPDATE');@@ -120,13 +120,16 @@ function routeNeedsUpdate(routeName: Route, callback: () => void) {function queueRoutesForUpdate(...routes: Route[]) {console.log('updating routes', routes);const currentScreen = useNavigationStore.getState().currentScreen;- const routeHistory = rootNavigatorRef.getState()?.history || [{ key: currentScreen.name }];+ const routeHistory = rootNavigatorRef.current?.getRootState()?.routes || [+ { key: currentScreen.name }+ ];+// filter out routes that are not rendered to prevent unnecessary updatesroutes = routes.filter(//@ts-ignorerouteName => routeHistory?.findIndex(route => route.key?.startsWith(routeName)) > -1);- console.log('routes to update: ', routes, routeHistory, currentScreen.name);+if (routes.indexOf(currentScreen.name) > -1) {console.log('updating current route');routeUpdateFunctions[currentScreen.name]();@@ -138,6 +141,7 @@ function queueRoutesForUpdate(...routes: Route[]) {routesUpdateQueue = routesUpdateQueue.concat(routes);routesUpdateQueue = [...new Set(routesUpdateQueue)];+ console.log(routesUpdateQueue);}function navigate<T extends RouteName>(screen: CurrentScreen, params: RouteParams[T]) {diff --git a/apps/mobile/src/utils/hooks/useActions.js b/apps/mobile/src/utils/hooks/useActions.jsindex 9b6b79bd2..83b204a0f 100644--- a/apps/mobile/src/utils/hooks/useActions.js+++ b/apps/mobile/src/utils/hooks/useActions.js@@ -47,12 +47,7 @@ export const useActions = ({ close = () => {}, item }) => {console.log(item.readonly, 'readonly');const user = useUserStore(state => state.user);const [notifPinned, setNotifPinned] = useState(null);- const alias =- item.type === 'tag'- ? db.tags.alias(item.id)- : item.type === 'color'- ? db.colors.alias(item.id)- : item.title;+ const alias = item.alias || item.title;const isPublished = item.type === 'note' && db.monographs.isPublished(item.id);