Skip to content

Commit

Permalink
Fix open app
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Jan 12, 2025
1 parent 4491e85 commit 53ee0be
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ const ONYXKEYS = {
/** Is report data loading? */
IS_LOADING_APP: 'isLoadingApp',

/** Is the app loaded? */
HAS_LOADED_APP: 'hasLoadedApp',

/** Is the test tools modal open? */
IS_TEST_TOOLS_MODAL_OPEN: 'isTestToolsModalOpen',

Expand Down Expand Up @@ -982,6 +985,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN]: boolean;
[ONYXKEYS.APP_PROFILING_IN_PROGRESS]: boolean;
[ONYXKEYS.IS_LOADING_APP]: boolean;
[ONYXKEYS.HAS_LOADED_APP]: boolean;
[ONYXKEYS.WALLET_TRANSFER]: OnyxTypes.WalletTransfer;
[ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID]: string;
[ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT]: boolean;
Expand Down
19 changes: 19 additions & 0 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ Onyx.connect({
},
});

let hasLoadedApp: boolean | undefined;
Onyx.connect({
key: ONYXKEYS.HAS_LOADED_APP,
callback: (value) => {
hasLoadedApp = value;
},
});

const KEYS_TO_PRESERVE: OnyxKey[] = [
ONYXKEYS.ACCOUNT,
ONYXKEYS.IS_CHECKING_PUBLIC_ROOM,
Expand Down Expand Up @@ -258,6 +266,13 @@ function getOnyxDataForOpenOrReconnect(isOpenApp = false): OnyxData {
value: true,
},
],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.HAS_LOADED_APP,
value: true,
},
],
finallyData: [
...defaultData.finallyData,
{
Expand Down Expand Up @@ -286,6 +301,10 @@ function openApp() {
* @param [updateIDFrom] the ID of the Onyx update that we want to start fetching from
*/
function reconnectApp(updateIDFrom: OnyxEntry<number> = 0) {
if (!hasLoadedApp) {
openApp();
return;
}
console.debug(`[OnyxUpdates] App reconnecting with updateIDFrom: ${updateIDFrom}`);
getPolicyParamsForOpenOrReconnect().then((policyParams) => {
const params: ReconnectAppParams = policyParams;
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [
ONYXKEYS.SESSION,
ONYXKEYS.STASHED_SESSION,
ONYXKEYS.IS_LOADING_APP,
ONYXKEYS.HAS_LOADED_APP,
ONYXKEYS.STASHED_CREDENTIALS,

// We need to preserve the sidebar loaded state since we never unrender the sidebar when connecting as a delegate
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/QueuedOnyxUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function flushQueue(): Promise<void> {
ONYXKEYS.NVP_PREFERRED_LOCALE,
ONYXKEYS.SESSION,
ONYXKEYS.IS_LOADING_APP,
ONYXKEYS.HAS_LOADED_APP,
ONYXKEYS.CREDENTIALS,
ONYXKEYS.IS_SIDEBAR_LOADED,
ONYXKEYS.ACCOUNT,
Expand Down

0 comments on commit 53ee0be

Please sign in to comment.