Skip to content

Commit

Permalink
improve openApp flow
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Nov 27, 2024
1 parent c848cfd commit 4170968
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
17 changes: 7 additions & 10 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,13 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
setDidPusherInit(true);
});

// In Hybrid App we decide to call one of those method when booting ND and we don't want to duplicate calls
if (!NativeModules.HybridAppModule) {
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
App.reconnectApp(initialLastUpdateIDAppliedToClient);
}
// If we are on this screen then we are "logged in", but the user might not have "just logged in". They could be reopening the app
// or returning from background. If so, we'll assume they have some app data already and we can call reconnectApp() instead of openApp().
if (SessionUtils.didUserLogInDuringSession()) {
App.openApp();
} else {
Log.info('[AuthScreens] Sending ReconnectApp');
App.reconnectApp(initialLastUpdateIDAppliedToClient);
}

PriorityMode.autoSwitchToFocusMode();
Expand Down
15 changes: 1 addition & 14 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,15 +489,6 @@ function signUpUser() {
API.write(WRITE_COMMANDS.SIGN_UP_USER, params, {optimisticData, successData, failureData});
}

function getLastUpdateIDAppliedToClient(): Promise<number> {
return new Promise((resolve) => {
Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_LAST_UPDATE_ID_APPLIED_TO_CLIENT,
callback: (value) => resolve(value ?? 0),
});
});
}

function signInAfterTransitionFromOldDot(route: Route, hybridAppSettings: string) {
const parsedHybridAppSettings = parseHybridAppSettings(hybridAppSettings);
const {initialOnyxValues} = parsedHybridAppSettings;
Expand All @@ -517,12 +508,8 @@ function signInAfterTransitionFromOldDot(route: Route, hybridAppSettings: string
if (hybridApp.useNewDotSignInPage) {
setNewDotSignInState(CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED);
setOldDotSignInState(CONST.HYBRID_APP_SIGN_IN_STATE.NOT_STARTED);
return Promise.resolve();
}

return getLastUpdateIDAppliedToClient().then((lastUpdateId) => {
return App.reconnectApp(lastUpdateId);
});
return Promise.resolve();
};

return new Promise<Route>((resolve) => {
Expand Down

0 comments on commit 4170968

Please sign in to comment.