Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Status message not cleared #53810

Merged
merged 13 commits into from
Jan 13, 2025
28 changes: 28 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRout
import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal';
import TestToolsModal from '@components/TestToolsModal';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
Expand Down Expand Up @@ -235,6 +236,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
const rootNavigatorOptions = useRootNavigatorOptions();
const {canUseDefaultRooms} = usePermissions();
const {activeWorkspaceID} = useActiveWorkspace();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const {toggleSearch} = useSearchRouterContext();

const modal = useRef<OnyxTypes.Modal>({});
Expand Down Expand Up @@ -406,6 +408,32 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

const clearStatus = () => {
User.clearCustomStatus();
User.clearDraftCustomStatus();
};
useEffect(() => {
if (!currentUserPersonalDetails.status?.clearAfter) {
return;
}
const currentTime = new Date();
const clearAfterTime = new Date(currentUserPersonalDetails.status.clearAfter);
if (Number.isNaN(clearAfterTime.getTime())) {
return;
}
const subMilisecondsTime = clearAfterTime.getTime() - currentTime.getTime();
if (subMilisecondsTime > 0) {
const timeoutID = setTimeout(() => {
clearStatus();
}, subMilisecondsTime);
return () => {
clearTimeout(timeoutID);
};
}

clearStatus();
}, [currentUserPersonalDetails.status?.clearAfter]);

const CentralPaneScreenOptions: PlatformStackNavigationOptions = {
...hideKeyboardOnSwipe,
headerShown: false,
Expand Down
Loading