Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand",
"perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure",
"typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc",
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=215 --cache --cache-location=node_modules/.cache/eslint",
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=214 --cache --cache-location=node_modules/.cache/eslint",
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh",
"lint-watch": "npx eslint-watch --watch --changed",
"shellcheck": "./scripts/shellCheck.sh",
Expand Down
24 changes: 15 additions & 9 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@
policyIDList: string[];
};

let currentUserAccountID: number | undefined;
let currentUserEmail: string;
Onyx.connect({
// `currentSessionData` is only used in actions, not during render. So `Onyx.connectWithoutView` is appropriate.
// If React components need this value in the future, use `useOnyx` instead.
let currentSessionData: {accountID?: number; email: string} = {
accountID: undefined,
email: '',
};
Onyx.connectWithoutView({
key: ONYXKEYS.SESSION,
callback: (val) => {
currentUserAccountID = val?.accountID;
currentUserEmail = val?.email ?? '';
currentSessionData = {
accountID: val?.accountID,
email: val?.email ?? '',
};
},
});

Expand All @@ -63,7 +69,7 @@
});

let preservedShouldUseStagingServer: boolean | undefined;
Onyx.connect({

Check warning on line 72 in src/libs/actions/App.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.ACCOUNT,
callback: (value) => {
preservedShouldUseStagingServer = value?.shouldUseStagingServer;
Expand All @@ -90,7 +96,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 99 in src/libs/actions/App.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -170,7 +176,7 @@
}

// If user is not signed in, change just locally.
if (!currentUserAccountID) {
if (!currentSessionData.accountID) {
Onyx.merge(ONYXKEYS.NVP_PREFERRED_LOCALE, locale);
return;
}
Expand Down Expand Up @@ -218,7 +224,7 @@
function getPolicyParamsForOpenOrReconnect(): Promise<PolicyParamsForOpenOrReconnect> {
return new Promise((resolve) => {
isReadyToOpenApp.then(() => {
const connection = Onyx.connect({

Check warning on line 227 in src/libs/actions/App.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (policies) => {
Expand Down Expand Up @@ -563,7 +569,7 @@

// If the route that is being handled is a magic link, email and shortLivedAuthToken should not be attached to the url
// to prevent signing into the wrong account
if (!currentUserAccountID || !shouldAuthenticateWithCurrentAccount) {
if (!currentSessionData.accountID || !shouldAuthenticateWithCurrentAccount) {
Browser.openRouteInDesktopApp();
return;
}
Expand All @@ -575,13 +581,13 @@
if (!response) {
Log.alert(
'Trying to redirect via deep link, but the response is empty. User likely not authenticated.',
{response, shouldAuthenticateWithCurrentAccount, currentUserAccountID},
{response, shouldAuthenticateWithCurrentAccount, currentUserAccountID: currentSessionData.accountID},
true,
);
return;
}

Browser.openRouteInDesktopApp(response.shortLivedAuthToken, currentUserEmail, isMagicLink ? '/r' : initialRoute);
Browser.openRouteInDesktopApp(response.shortLivedAuthToken, currentSessionData.email, isMagicLink ? '/r' : initialRoute);
});
}

Expand Down
Loading