-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
88d93f3
fix: Status message not cleared
nkdengineer 3151be8
Merge branch 'main' into fix/53518
nkdengineer 1ab2da2
Merge branch 'main' into fix/53518
nkdengineer bf668de
fix logic update clear status
nkdengineer 81f81d2
fix: lint and logic useEffect
nkdengineer 9897d39
fix lint
nkdengineer 839ff0f
fix conflist
nkdengineer 38b66b9
Merge branch 'main' into fix/53518
nkdengineer edcc53d
fix the default option
nkdengineer 24eba35
fix chore
nkdengineer 84973de
fix logic clear status
nkdengineer 374a6a6
fix lint
nkdengineer 7e4892d
using clear draft custom status
nkdengineer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import {findFocusedRoute} from '@react-navigation/native'; | ||
import {format} from 'date-fns'; | ||
import React, {memo, useEffect, useRef, useState} from 'react'; | ||
import {NativeModules, View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
|
@@ -13,12 +14,14 @@ | |
import TestToolsModal from '@components/TestToolsModal'; | ||
import * as TooltipManager from '@components/Tooltip/EducationalTooltip/TooltipManager'; | ||
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'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import {READ_COMMANDS} from '@libs/API/types'; | ||
import DateUtils from '@libs/DateUtils'; | ||
import HttpUtils from '@libs/HttpUtils'; | ||
import KeyboardShortcut from '@libs/KeyboardShortcut'; | ||
import Log from '@libs/Log'; | ||
|
@@ -147,7 +150,7 @@ | |
return; | ||
} | ||
|
||
currentAccountID = value.accountID ?? -1; | ||
Check failure on line 153 in src/libs/Navigation/AppNavigator/AuthScreens.tsx
|
||
|
||
if (Navigation.isActiveRoute(ROUTES.SIGN_IN_MODAL)) { | ||
// This means sign in in RHP was successful, so we can subscribe to user events | ||
|
@@ -237,6 +240,7 @@ | |
const rootNavigatorOptions = useRootNavigatorOptions(); | ||
const {canUseDefaultRooms} = usePermissions(); | ||
const {activeWorkspaceID} = useActiveWorkspace(); | ||
const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
const {toggleSearch} = useSearchRouterContext(); | ||
|
||
const modal = useRef<OnyxTypes.Modal>({}); | ||
|
@@ -249,7 +253,7 @@ | |
} | ||
|
||
const initialReport = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID); | ||
return initialReport?.reportID ?? ''; | ||
Check failure on line 256 in src/libs/Navigation/AppNavigator/AuthScreens.tsx
|
||
}); | ||
|
||
useEffect(() => { | ||
|
@@ -402,6 +406,31 @@ | |
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
const clearStatus = () => { | ||
User.updateDraftCustomStatus({ | ||
text: '', | ||
emojiCode: '', | ||
clearAfter: DateUtils.getEndOfToday(), | ||
}); | ||
}; | ||
useEffect(() => { | ||
const currentTime = format(new Date(), 'yyyy-MM-dd HH:mm:ss'); | ||
if (!currentUserPersonalDetails.status?.clearAfter) { | ||
return; | ||
} | ||
if (new Date(currentUserPersonalDetails.status?.clearAfter).getTime() > new Date(currentTime).getTime()) { | ||
const subMilisecondsTime = new Date(currentUserPersonalDetails.status?.clearAfter).getTime() - new Date(currentTime).getTime(); | ||
const timeoutID = setTimeout(() => { | ||
clearStatus(); | ||
}, subMilisecondsTime); | ||
return () => { | ||
clearTimeout(timeoutID); | ||
}; | ||
} | ||
|
||
clearStatus(); | ||
}, [currentUserPersonalDetails.status?.clearAfter]); | ||
|
||
const CentralPaneScreenOptions: PlatformStackNavigationOptions = { | ||
...hideKeyboardOnSwipe, | ||
headerShown: false, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make the code cleaner like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eh2077 i updated