Skip to content

Commit c7639ce

Browse files
Refactor: isolate clearCustomStatus from ONYXKEYS.SESSION Onyx data
1 parent 1dd01da commit c7639ce

3 files changed

Lines changed: 11 additions & 10 deletions

File tree

src/libs/Navigation/AppNavigator/UserStatusHandler.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
44
import * as User from '@userActions/User';
55
import CONST from '@src/CONST';
66

7-
function clearStatus() {
8-
User.clearCustomStatus();
7+
function clearStatus(currentUserAccountID: number) {
8+
User.clearCustomStatus(currentUserAccountID);
99
User.clearDraftCustomStatus();
1010
}
1111

@@ -25,6 +25,7 @@ function UserStatusHandler() {
2525
if (!currentUserPersonalDetails.status?.clearAfter) {
2626
return;
2727
}
28+
const currentUserAccountID = currentUserPersonalDetails.accountID;
2829
const currentTime = new Date();
2930
const clearAfterTime = new Date(currentUserPersonalDetails.status.clearAfter);
3031
if (Number.isNaN(clearAfterTime.getTime())) {
@@ -41,7 +42,7 @@ function UserStatusHandler() {
4142
const remainingTime = clearAfterTime.getTime() - now.getTime();
4243

4344
if (remainingTime <= 0) {
44-
clearStatus();
45+
clearStatus(currentUserAccountID);
4546
if (intervalId) {
4647
clearInterval(intervalId);
4748
}
@@ -50,13 +51,13 @@ function UserStatusHandler() {
5051
clearInterval(intervalId);
5152
}
5253
timeoutId = setTimeout(() => {
53-
clearStatus();
54+
clearStatus(currentUserAccountID);
5455
}, remainingTime);
5556
}
5657
}, CONST.LIMIT_TIMEOUT);
5758
} else {
5859
timeoutId = setTimeout(() => {
59-
clearStatus();
60+
clearStatus(currentUserAccountID);
6061
}, subMillisecondsTime);
6162
}
6263

@@ -70,8 +71,8 @@ function UserStatusHandler() {
7071
};
7172
}
7273

73-
clearStatus();
74-
}, [currentUserPersonalDetails.status?.clearAfter]);
74+
clearStatus(currentUserAccountID);
75+
}, [currentUserPersonalDetails.accountID, currentUserPersonalDetails.status?.clearAfter]);
7576

7677
return null;
7778
}

src/libs/actions/User.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,13 +1199,13 @@ function updateCustomStatus(status: Status) {
11991199
/**
12001200
* Clears the custom status
12011201
*/
1202-
function clearCustomStatus() {
1202+
function clearCustomStatus(currentUserAccountIDParam: number) {
12031203
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.PERSONAL_DETAILS_LIST>> = [
12041204
{
12051205
onyxMethod: Onyx.METHOD.MERGE,
12061206
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
12071207
value: {
1208-
[currentUserAccountID]: {
1208+
[currentUserAccountIDParam]: {
12091209
status: null, // Clearing the field
12101210
},
12111211
},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function StatusPage() {
146146
if (navigateBackToPreviousScreenTask.current) {
147147
return;
148148
}
149-
clearCustomStatus();
149+
clearCustomStatus(currentUserPersonalDetails.accountID);
150150
updateDraftCustomStatus({
151151
text: '',
152152
emojiCode: '',

0 commit comments

Comments
 (0)