From 30ac9259c7b9dc367fca15cb6e7895feb0955bd4 Mon Sep 17 00:00:00 2001 From: Ansh Date: Wed, 19 Jul 2023 23:50:42 -0700 Subject: [APP-775] Add Welcome screen after account creation (#1038) * add comments to step 1-3 * add onboarding screen * add analytics for onboarding tracking * fix useEffect * change text * change icon size * put onboarding into bottom sheet modal instead of react navigation * wip * Simplify the type validation * Fix: only trigger onboarding modal when account creation succeeds * Add the 'session-ready' event which fires when the new session is stable * Use the 'session-ready' event to trigger the onboarding modal * update copy * update copy --------- Co-authored-by: Paul Frazee --- src/Navigation.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/Navigation.tsx') diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 640b771d4..06cce0f00 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -66,6 +66,7 @@ import {SavedFeeds} from 'view/screens/SavedFeeds' import {getRoutingInstrumentation} from 'lib/sentry' import {bskyTitle} from 'lib/strings/headings' import {JSX} from 'react/jsx-runtime' +import {timeout} from 'lib/async/timeout' const navigationRef = createNavigationContainerRef() @@ -478,7 +479,8 @@ function resetToTab(tabName: 'HomeTab' | 'SearchTab' | 'NotificationsTab') { } } -function reset() { +// returns a promise that resolves after the state reset is complete +function reset(): Promise { if (navigationRef.isReady()) { navigationRef.dispatch( CommonActions.reset({ @@ -486,6 +488,18 @@ function reset() { routes: [{name: isNative ? 'HomeTab' : 'Home'}], }), ) + return Promise.race([ + timeout(1e3), + new Promise(resolve => { + const handler = () => { + resolve() + navigationRef.removeListener('state', handler) + } + navigationRef.addListener('state', handler) + }), + ]) + } else { + return Promise.resolve() } } -- cgit 1.4.1