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 total notes not updated on notebook and topics.
ammarahm-ed4899d3209958
diff --git a/apps/mobile/app/components/list-items/notebook/index.js b/apps/mobile/app/components/list-items/notebook/index.jsindex 67935a599..6323cd4c0 100644--- a/apps/mobile/app/components/list-items/notebook/index.js+++ b/apps/mobile/app/components/list-items/notebook/index.js@@ -41,14 +41,19 @@ const navigateToTopic = (topic) => {TopicNotes.navigate(topic, true);};-export const NotebookItem = ({ item, isTopic = false, isTrash, dateBy }) => {+export const NotebookItem = ({+ item,+ isTopic = false,+ isTrash,+ dateBy,+ totalNotes+}) => {const colors = useThemeStore((state) => state.colors);const notebooksListMode = useSettingStore((state) => state.settings.notebooksListMode);const compactMode = notebooksListMode === "compact";const topics = item.topics?.slice(0, 3) || [];- const totalNotes = getTotalNotes(item);return (<>diff --git a/apps/mobile/app/components/list-items/notebook/wrapper.js b/apps/mobile/app/components/list-items/notebook/wrapper.jsindex 504100128..b5c1cbdc3 100644--- a/apps/mobile/app/components/list-items/notebook/wrapper.js+++ b/apps/mobile/app/components/list-items/notebook/wrapper.js@@ -101,7 +101,7 @@ export const openNotebookTopic = (item) => {};export const NotebookWrapper = React.memo(- function NotebookWrapper({ item, index, dateBy }) {+ function NotebookWrapper({ item, index, dateBy, totalNotes }) {const isTrash = item.type === "trash";return (@@ -118,11 +118,13 @@ export const NotebookWrapper = React.memo(dateBy={dateBy}index={index}isTrash={isTrash}+ totalNotes={totalNotes}/></SelectionWrapper>);},(prev, next) => {+ if (prev.totalNotes !== next.totalNotes) return false;if (prev.item.title !== next.item.title) return false;if (prev.dateBy !== next.dateBy) {return false;diff --git a/apps/mobile/app/components/list/index.js b/apps/mobile/app/components/list/index.jsindex b6d1b0dba..454926e72 100644--- a/apps/mobile/app/components/list/index.js+++ b/apps/mobile/app/components/list/index.js@@ -35,6 +35,7 @@ import { NoteWrapper } from "../list-items/note/wrapper";import { NotebookWrapper } from "../list-items/notebook/wrapper";import TagItem from "../list-items/tag";import { Empty } from "./empty";+import { getTotalNotes } from "../../utils";const renderItems = {note: NoteWrapper,@@ -52,6 +53,7 @@ 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)@@ -73,6 +75,7 @@ const RenderItem = ({ item, index, type, ...restArgs }) => {dateBy={dateBy}index={index}type={type}+ totalNotes={totalNotes}{...restArgs}/>);diff --git a/apps/mobile/app/screens/notes/common.ts b/apps/mobile/app/screens/notes/common.tsindex 15c888d06..08adea892 100644--- a/apps/mobile/app/screens/notes/common.ts+++ b/apps/mobile/app/screens/notes/common.ts@@ -102,7 +102,8 @@ async function onNoteCreated(id: string, params: FirstSaveData) {"TopicNotes","Favorites","Notes",- "Notebook"+ "Notebook",+ "Notebooks");break;}diff --git a/apps/mobile/app/services/navigation.ts b/apps/mobile/app/services/navigation.tsindex 419c68751..b9392f699 100755--- a/apps/mobile/app/services/navigation.ts+++ b/apps/mobile/app/services/navigation.ts@@ -105,23 +105,12 @@ function routeNeedsUpdate(routeName: RouteName, callback: () => void) {function queueRoutesForUpdate(...routes: RouteName[]) {const currentScreen = useNavigationStore.getState().currentScreen;- // const routeHistory = rootNavigatorRef.current?.getRootState()?.routes || [- // { key: currentScreen.name }- // ];-- // filter out routes that are not rendered to prevent unnecessary updates- // routes = routes.filter(- // routeName => routeHistory?.findIndex(route => route.key?.startsWith(routeName)) > -1- // );-if (routes.indexOf(currentScreen.name) > -1) {routeUpdateFunctions[currentScreen.name]();clearRouteFromQueue(currentScreen.name);// Remove focused screen from queueroutes.splice(routes.indexOf(currentScreen.name), 1);- routesUpdateQueue.splice(routesUpdateQueue.indexOf(currentScreen.name), 1);}-routesUpdateQueue = routesUpdateQueue.concat(routes);routesUpdateQueue = [...new Set(routesUpdateQueue)];}diff --git a/apps/mobile/app/utils/index.js b/apps/mobile/app/utils/index.jsindex ee39d942f..3805b1462 100755--- a/apps/mobile/app/utils/index.js+++ b/apps/mobile/app/utils/index.js@@ -128,7 +128,7 @@ export function setWidthHeight(size) {}export function getTotalNotes(item) {- if (!item || item.type === "header") return 0;+ if (!item || (item.type !== "notebook" && item.type !== "topic")) return 0;if (item.type === "topic") {return (db.notebooks.notebook(item.notebookId)?.topics.topic(item.id)