Skip to content

Commit

Permalink
Merge pull request #44453 from Expensify/jpersaud_remove_open_profile
Browse files Browse the repository at this point in the history
Remove OpenProfile calls
  • Loading branch information
carlosmiceli authored Jun 27, 2024
2 parents 6ea15ed + 46514a0 commit 7493f2a
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 74 deletions.
5 changes: 0 additions & 5 deletions src/libs/API/parameters/OpenProfileParams.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type {default as OpenAppParams} from './OpenAppParams';
export type {default as OpenOldDotLinkParams} from './OpenOldDotLinkParams';
export type {default as OpenPlaidBankAccountSelectorParams} from './OpenPlaidBankAccountSelectorParams';
export type {default as OpenPlaidBankLoginParams} from './OpenPlaidBankLoginParams';
export type {default as OpenProfileParams} from './OpenProfileParams';
export type {default as OpenPublicProfilePageParams} from './OpenPublicProfilePageParams';
export type {default as OpenReimbursementAccountPageParams} from './OpenReimbursementAccountPageParams';
export type {default as OpenReportParams} from './OpenReportParams';
Expand Down
2 changes: 0 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const WRITE_COMMANDS = {
UPDATE_PREFERRED_LOCALE: 'UpdatePreferredLocale',
OPEN_APP: 'OpenApp',
RECONNECT_APP: 'ReconnectApp',
OPEN_PROFILE: 'OpenProfile',
HANDLE_RESTRICTED_EVENT: 'HandleRestrictedEvent',
OPEN_REPORT: 'OpenReport',
DELETE_PAYMENT_BANK_ACCOUNT: 'DeletePaymentBankAccount',
Expand Down Expand Up @@ -237,7 +236,6 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UPDATE_PREFERRED_LOCALE]: Parameters.UpdatePreferredLocaleParams;
[WRITE_COMMANDS.RECONNECT_APP]: Parameters.ReconnectAppParams;
[WRITE_COMMANDS.OPEN_APP]: Parameters.OpenAppParams;
[WRITE_COMMANDS.OPEN_PROFILE]: Parameters.OpenProfileParams;
[WRITE_COMMANDS.HANDLE_RESTRICTED_EVENT]: Parameters.HandleRestrictedEventParams;
[WRITE_COMMANDS.OPEN_REPORT]: Parameters.OpenReportParams;
[WRITE_COMMANDS.DELETE_PAYMENT_BANK_ACCOUNT]: Parameters.DeletePaymentBankAccountParams;
Expand Down
59 changes: 1 addition & 58 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@ import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import {importEmojiLocale} from '@assets/emojis';
import * as API from '@libs/API';
import type {
GetMissingOnyxMessagesParams,
HandleRestrictedEventParams,
OpenAppParams,
OpenOldDotLinkParams,
OpenProfileParams,
ReconnectAppParams,
UpdatePreferredLocaleParams,
} from '@libs/API/parameters';
import type {GetMissingOnyxMessagesParams, HandleRestrictedEventParams, OpenAppParams, OpenOldDotLinkParams, ReconnectAppParams, UpdatePreferredLocaleParams} from '@libs/API/parameters';
import {SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as Browser from '@libs/Browser';
import DateUtils from '@libs/DateUtils';
import {buildEmojisTrie} from '@libs/EmojiTrie';
import Log from '@libs/Log';
import getCurrentUrl from '@libs/Navigation/currentUrl';
Expand All @@ -32,7 +23,6 @@ import type {OnyxKey} from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
import ROUTES from '@src/ROUTES';
import type * as OnyxTypes from '@src/types/onyx';
import type {SelectedTimezone} from '@src/types/onyx/PersonalDetails';
import type {OnyxData} from '@src/types/onyx/Request';
import * as Policy from './Policy/Policy';
import * as Session from './Session';
Expand Down Expand Up @@ -457,52 +447,6 @@ function redirectThirdPartyDesktopSignIn() {
}
}

function openProfile(personalDetails: OnyxTypes.PersonalDetails) {
const oldTimezoneData = personalDetails.timezone ?? {};
let newTimezoneData = oldTimezoneData;

if (oldTimezoneData?.automatic ?? true) {
newTimezoneData = {
automatic: true,
selected: Intl.DateTimeFormat().resolvedOptions().timeZone as SelectedTimezone,
};
}

newTimezoneData = DateUtils.formatToSupportedTimezone(newTimezoneData);

const parameters: OpenProfileParams = {
timezone: JSON.stringify(newTimezoneData),
};

// We expect currentUserAccountID to be a number because it doesn't make sense to open profile if currentUserAccountID is not set
if (typeof currentUserAccountID === 'number') {
API.write(WRITE_COMMANDS.OPEN_PROFILE, parameters, {
optimisticData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[currentUserAccountID]: {
timezone: newTimezoneData,
},
},
},
],
failureData: [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
value: {
[currentUserAccountID]: {
timezone: oldTimezoneData,
},
},
},
],
});
}
}

/**
* @param shouldAuthenticateWithCurrentAccount Optional, indicates whether default authentication method (shortLivedAuthToken) should be used
*/
Expand Down Expand Up @@ -558,7 +502,6 @@ export {
setLocaleAndNavigate,
setSidebarLoaded,
setUpPoliciesAndNavigate,
openProfile,
redirectThirdPartyDesktopSignIn,
openApp,
reconnectApp,
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/__mocks__/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const {
setLocaleAndNavigate,
setSidebarLoaded,
setUpPoliciesAndNavigate,
openProfile,
redirectThirdPartyDesktopSignIn,
openApp,
reconnectApp,
Expand Down Expand Up @@ -59,7 +58,6 @@ export {
setLocaleAndNavigate,
setSidebarLoaded,
setUpPoliciesAndNavigate,
openProfile,
redirectThirdPartyDesktopSignIn,
openApp,
reconnectApp,
Expand Down
7 changes: 1 addition & 6 deletions src/pages/settings/Profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useEffect} from 'react';
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -21,7 +21,6 @@ import * as LocalePhoneNumber from '@libs/LocalePhoneNumber';
import Navigation from '@libs/Navigation/Navigation';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as UserUtils from '@libs/UserUtils';
import * as App from '@userActions/App';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -101,10 +100,6 @@ function ProfilePage({
},
];

useEffect(() => {
App.openProfile(currentUserPersonalDetails);
}, [currentUserPersonalDetails]);

const privateOptions = [
{
description: translate('privatePersonalDetails.legalName'),
Expand Down

0 comments on commit 7493f2a

Please sign in to comment.