Skip to content

Commit 2dafe6b

Browse files
authored
Merge pull request #18420 from mozilla/FXA-11165
fix(settings): Refresh recovery phone service availability on delete
2 parents a7b1e90 + 7784dd2 commit 2dafe6b

4 files changed

Lines changed: 17 additions & 21 deletions

File tree

packages/fxa-settings/src/components/Settings/PageRecoveryPhoneRemove/index.stories.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Meta } from '@storybook/react';
77
import { withLocalization } from 'fxa-react/lib/storybooks';
88
import PageRecoveryPhoneRemove from '.';
99
import { LocationProvider } from '@reach/router';
10-
import { mockAppContext } from '../../../models/mocks';
10+
import { mockAppContext, MOCK_ACCOUNT } from '../../../models/mocks';
1111
import { Account, AppContext } from '../../../models';
1212

1313
export default {
@@ -16,12 +16,20 @@ export default {
1616
decorators: [withLocalization],
1717
} as Meta;
1818

19+
const account = {
20+
...MOCK_ACCOUNT,
21+
recoveryPhone: {
22+
exists: true,
23+
phoneNumber: '123-456-7890',
24+
available: true,
25+
},
26+
removeRecoveryPhone: () => true,
27+
} as unknown as Account;
28+
1929
export const Default = () => (
2030
<AppContext.Provider
2131
value={mockAppContext({
22-
account: {
23-
removeRecoveryPhone: () => {},
24-
} as unknown as Account,
32+
account,
2533
})}
2634
>
2735
<LocationProvider>

packages/fxa-settings/src/components/Settings/PageRecoveryPhoneRemove/index.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jest.mock('@reach/router', () => ({
4141
}));
4242

4343
const account = {
44+
refresh: jest.fn(),
4445
removeRecoveryPhone: jest.fn().mockResolvedValue({}),
4546
recoveryPhone: { phoneNumber: MOCK_FULL_PHONE_NUMBER },
4647
} as unknown as Account;

packages/fxa-settings/src/components/Settings/PageRecoveryPhoneRemove/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ const PageRecoveryPhoneRemove = (props: RouteComponentProps) => {
5454
const clickRemoveRecoveryPhone = useCallback(async () => {
5555
try {
5656
await account.removeRecoveryPhone();
57-
57+
// get the latest status of recovery phone info and availability
58+
// ensure correct data is shown on the settings page
59+
// and that service availability is correctly checked against current location
60+
await account.refresh('recoveryPhone');
5861
alertSuccessAndGoHome();
5962
} catch (e) {
6063
const localizedError = getLocalizedErrorMessage(ftlMsgResolver, e);

packages/fxa-settings/src/models/Account.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,22 +1392,6 @@ export class Account implements AccountData {
13921392
const result = await this.withLoadingStatus(
13931393
this.authClient.recoveryPhoneDelete(sessionToken()!)
13941394
);
1395-
1396-
const cache = this.apolloClient.cache;
1397-
cache.modify({
1398-
id: cache.identify({ __typename: 'Account' }),
1399-
fields: {
1400-
recoveryPhone() {
1401-
return {
1402-
exists: false,
1403-
phoneNumber: null,
1404-
nationalFormat: null,
1405-
available: true,
1406-
};
1407-
},
1408-
},
1409-
});
1410-
14111395
return result;
14121396
}
14131397

0 commit comments

Comments
 (0)