-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34978 from lukemorawski/20354-task_assignees_list…
…_refactor 20354 task assignees list refactor
- Loading branch information
Showing
4 changed files
with
104 additions
and
133 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {useMemo} from 'react'; | ||
import {usePersonalDetails, useSession} from '@components/OnyxProvider'; | ||
import CONST from '@src/CONST'; | ||
import type {PersonalDetails} from '@src/types/onyx'; | ||
|
||
type CurrentUserPersonalDetails = PersonalDetails | Record<string, never>; | ||
|
||
function useCurrentUserPersonalDetails() { | ||
const session = useSession(); | ||
const personalDetails = usePersonalDetails() ?? CONST.EMPTY_OBJECT; | ||
const accountID = session?.accountID ?? 0; | ||
const accountPersonalDetails = personalDetails?.[accountID]; | ||
const currentUserPersonalDetails: CurrentUserPersonalDetails = useMemo( | ||
() => (accountPersonalDetails ? {...accountPersonalDetails, accountID} : {}) as CurrentUserPersonalDetails, | ||
[accountPersonalDetails, accountID], | ||
); | ||
|
||
return currentUserPersonalDetails; | ||
} | ||
|
||
export default useCurrentUserPersonalDetails; |
Oops, something went wrong.