Skip to content

Commit 4f5f29d

Browse files
authored
Merge pull request Expensify#89461 from shubham1206agra/refactor-clearCustomStatus
Refactor: isolate clearCustomStatus from ONYXKEYS.SESSION Onyx data
2 parents 95801bd + 82a2f03 commit 4f5f29d

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

src/libs/Navigation/AppNavigator/UserStatusHandler.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import {useEffect} from 'react';
22
import useAutoUpdateTimezone from '@hooks/useAutoUpdateTimezone';
33
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
4-
import * as User from '@userActions/User';
4+
import {clearCustomStatus, clearDraftCustomStatus} from '@userActions/User';
55
import CONST from '@src/CONST';
66

7-
function clearStatus() {
8-
User.clearCustomStatus();
9-
User.clearDraftCustomStatus();
10-
}
11-
127
/**
138
* Component that does not render anything and owns the timezone auto-update logic and
149
* the status-clear timer effect.
@@ -21,6 +16,11 @@ function UserStatusHandler() {
2116

2217
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
2318

19+
const clearStatus = () => {
20+
clearCustomStatus(currentUserPersonalDetails.accountID);
21+
clearDraftCustomStatus();
22+
};
23+
2424
useEffect(() => {
2525
if (!currentUserPersonalDetails.status?.clearAfter) {
2626
return;
@@ -71,7 +71,7 @@ function UserStatusHandler() {
7171
}
7272

7373
clearStatus();
74-
}, [currentUserPersonalDetails.status?.clearAfter]);
74+
}, [clearStatus, currentUserPersonalDetails.status?.clearAfter]);
7575

7676
return null;
7777
}

src/libs/actions/User.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,13 +1255,13 @@ function updateCustomStatus(currentUserAccountIDParam: number, status: Status) {
12551255
/**
12561256
* Clears the custom status
12571257
*/
1258-
function clearCustomStatus() {
1258+
function clearCustomStatus(currentUserAccountIDParam: number) {
12591259
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
12601260
{
12611261
onyxMethod: Onyx.METHOD.MERGE,
12621262
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
12631263
value: {
1264-
[currentUserAccountID]: {
1264+
[currentUserAccountIDParam]: {
12651265
status: null, // Clearing the field
12661266
},
12671267
},

src/pages/settings/Profile/CustomStatus/StatusPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function StatusPage() {
141141
if (navigateBackToPreviousScreenTask.current) {
142142
return;
143143
}
144-
clearCustomStatus();
144+
clearCustomStatus(currentUserPersonalDetails.accountID);
145145
updateDraftCustomStatus({
146146
text: '',
147147
emojiCode: '',

0 commit comments

Comments
 (0)