Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: fix multiple timers set on reset root state causing jank

Ammar Ahmed66498e12ce4d
diff --git a/apps/mobile/app/components/auth/common.js b/apps/mobile/app/components/auth/common.js
index 88e62ff3d..255d4f96a 100644
--- a/apps/mobile/app/components/auth/common.js
+++ b/apps/mobile/app/components/auth/common.js
@@ -38,9 +38,6 @@ export function hideAuth(context) {
context === "intro"
) {
Navigation.replace("FluidPanelsView");
- setTimeout(() => {
- Navigation.resetRootState();
- }, 1000);
} else {
Navigation.goBack();
}
diff --git a/apps/mobile/app/navigation/navigation-stack.tsx b/apps/mobile/app/navigation/navigation-stack.tsx
index f566ccc0f..52726e214 100644
--- a/apps/mobile/app/navigation/navigation-stack.tsx
+++ b/apps/mobile/app/navigation/navigation-stack.tsx
@@ -258,12 +258,14 @@ export const RootNavigation = () => {
(state) => state.settings.introCompleted
);
const clearSelection = useSelectionStore((state) => state.clearSelection);
+ const resetTimer = React.useRef<NodeJS.Timeout>(undefined);
const onStateChange = React.useCallback(
(state: any) => {
if (useSelectionStore.getState().selectionMode) {
clearSelection();
}
- setTimeout(() => {
+ clearTimeout(resetTimer.current);
+ resetTimer.current = setTimeout(() => {
Navigation.resetRootState(state);
}, 1000);
hideAllTooltips();