diff --git a/apps/mobile/app/screens/notebook/index.tsx b/apps/mobile/app/screens/notebook/index.tsx index d44d97f28..7a2f98cf3 100644 --- a/apps/mobile/app/screens/notebook/index.tsx +++ b/apps/mobile/app/screens/notebook/index.tsx @@ -40,10 +40,12 @@ import { openEditor, setOnFirstSave } from "../notes/common"; import { View } from "react-native"; import { DefaultAppStyles } from "../../utils/styles"; import { Notebooks } from "../../components/sheets/notebooks"; +import { useSettingStore } from "../../stores/use-setting-store"; const NotebookScreen = ({ route, navigation }: NavigationProps<"Notebook">) => { const [notes, setNotes] = useState>(); const params = useRef(route?.params); + const isAppLoading = useSettingStore((state) => state.isAppLoading); const [loading, setLoading] = useState(true); const updateOnFocus = useRef(false); const [breadcrumbs, setBreadcrumbs] = useState< @@ -81,6 +83,7 @@ const NotebookScreen = ({ route, navigation }: NavigationProps<"Notebook">) => { const onRequestUpdate = React.useCallback( async (data?: NotebookScreenParams) => { + if (useSettingStore.getState().isAppLoading) return; if ( useNavigationStore.getState().focusedRouteId !== params.current.item.id && @@ -135,12 +138,13 @@ const NotebookScreen = ({ route, navigation }: NavigationProps<"Notebook">) => { ); useEffect(() => { + if (isAppLoading) return; onRequestUpdate(params.current); const sub = eSubscribeEvent(eUpdateNotebookRoute, onRequestUpdate); return () => { sub?.unsubscribe(); }; - }, [onRequestUpdate]); + }, [onRequestUpdate, isAppLoading]); useEffect(() => { return () => { diff --git a/apps/mobile/app/screens/notes/index.tsx b/apps/mobile/app/screens/notes/index.tsx index 4639cfad9..6068c0695 100644 --- a/apps/mobile/app/screens/notes/index.tsx +++ b/apps/mobile/app/screens/notes/index.tsx @@ -41,6 +41,7 @@ import useNavigationStore, { } from "../../stores/use-navigation-store"; import { setOnFirstSave } from "./common"; import { strings } from "@notesnook/intl"; +import { useSettingStore } from "../../stores/use-setting-store"; export interface RouteProps extends NavigationProps { get: ( @@ -83,6 +84,7 @@ const NotesPage = ({ ? (params.current?.item as Color)?.colorCode : undefined; const updateOnFocus = useRef(false); + const isAppLoading = useSettingStore((state) => state.isAppLoading); const isFocused = useNavigationFocus(navigation, { onFocus: (prev) => { if (updateOnFocus.current) { @@ -118,6 +120,7 @@ const NotesPage = ({ const onRequestUpdate = React.useCallback( async (data?: NotesScreenParams) => { + if (useSettingStore.getState().isAppLoading) return; if ( params.current.item.id && useNavigationStore.getState().focusedRouteId !== @@ -164,6 +167,7 @@ const NotesPage = ({ ); useEffect(() => { + if (isAppLoading) return; if (loadingNotes) { get(params.current, true) .then(async (items) => { @@ -175,7 +179,7 @@ const NotesPage = ({ setLoadingNotes(false); }); } - }, [loadingNotes, get]); + }, [loadingNotes, get, isAppLoading]); useEffect(() => { eSubscribeEvent(route.name, onRequestUpdate);