Skip to content

Commit

Permalink
Fix open app
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Feb 8, 2025
1 parent 631006e commit 6d2e558
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,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 @@ -1011,6 +1014,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
20 changes: 19 additions & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,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 @@ -239,7 +247,13 @@ function getOnyxDataForOpenOrReconnect(isOpenApp = false, isFullReconnect = fals
value: true,
},
],
successData: [],
successData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.HAS_LOADED_APP,
value: true,
},
],
finallyData: [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -291,6 +305,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 @@ -66,6 +66,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 6d2e558

Please sign in to comment.