From 275fa1b3ca84617d4dd9e5a06e0f5058fc721a34 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Sat, 1 Apr 2023 23:32:05 +0500 Subject: [PATCH] mobile: fix loading editor screen on app launch --- apps/mobile/app/screens/editor/loading.js | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/mobile/app/screens/editor/loading.js b/apps/mobile/app/screens/editor/loading.js index 59cdba4ad..18bef8f97 100644 --- a/apps/mobile/app/screens/editor/loading.js +++ b/apps/mobile/app/screens/editor/loading.js @@ -42,7 +42,7 @@ const EditorOverlay = ({ editorId = "", editor }) => { const colors = useThemeStore((state) => state.colors); const [error, setError] = useState(false); const opacity = useSharedValue(1); - const translateValue = useSharedValue(6000); + const translateValue = useSharedValue(0); const deviceMode = useSettingStore((state) => state.deviceMode); const isTablet = deviceMode !== "mobile"; const insets = useGlobalSafeAreaInsets(); @@ -83,16 +83,14 @@ const EditorOverlay = ({ editorId = "", editor }) => { opacity.value = 0; translateValue.value = 6000; } else { + setError(false); + editorState().overlay = false; + opacity.value = withTiming(0, { + duration: 500 + }); setTimeout(() => { - setError(false); - editorState().overlay = false; - opacity.value = withTiming(0, { - duration: timeDiffSinceLoadStarted - }); - setTimeout(() => { - translateValue.value = 6000; - }, timeDiffSinceLoadStarted); - }, 0); + translateValue.value = 6000; + }, 500); } } }, @@ -100,12 +98,17 @@ const EditorOverlay = ({ editorId = "", editor }) => { ); useEffect(() => { + setTimeout(() => { + if (!loadingState.current.startTime) { + translateValue.value = 6000; + } + }, 1000); eSubscribeEvent("loadingNote" + editorId, load); return () => { clearTimers(); eUnSubscribeEvent("loadingNote" + editorId, load); }; - }, [editorId, load]); + }, [editorId, load, translateValue]); const animatedStyle = useAnimatedStyle(() => { return {