-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Workspace - Selected users to invite turn deselected when refresh Add message page. #66772
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
Changes from all commits
58d43c3
cbbdb33
18ba38a
e04a4f6
b67e687
af4d93c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -266,11 +266,13 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => { | |||||||
| const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: false}); | ||||||||
| const [internalOptions, setInternalOptions] = useState<OptionList>(optionsList); | ||||||||
| const prevOptions = useRef<OptionList>(null); | ||||||||
| const [areInternalOptionsInitialized, setAreInternalOptionsInitialized] = useState(false); | ||||||||
|
|
||||||||
| useEffect(() => { | ||||||||
| if (!prevOptions.current) { | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like the new part isn't related to the rest of the effect and has different dependencies. Why not add a separate effect for it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed, updated. |
||||||||
| prevOptions.current = optionsList; | ||||||||
| setInternalOptions(optionsList); | ||||||||
| setAreInternalOptionsInitialized(areOptionsInitialized); | ||||||||
| return; | ||||||||
| } | ||||||||
| /** | ||||||||
|
|
@@ -283,7 +285,8 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => { | |||||||
| return; | ||||||||
| } | ||||||||
| setInternalOptions(optionsList); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Same suggestion for the other |
||||||||
| }, [optionsList]); | ||||||||
| setAreInternalOptionsInitialized(areOptionsInitialized); | ||||||||
| }, [optionsList, areOptionsInitialized]); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please ignore this comment for now. |
||||||||
|
|
||||||||
| useEffect(() => { | ||||||||
| if (!shouldInitialize || areOptionsInitialized || isLoadingApp) { | ||||||||
|
|
@@ -293,14 +296,19 @@ const useOptionsList = (options?: {shouldInitialize: boolean}) => { | |||||||
| initializeOptions(); | ||||||||
| }, [shouldInitialize, initializeOptions, areOptionsInitialized, isLoadingApp]); | ||||||||
|
|
||||||||
| const resetInternalOptions = useCallback(() => { | ||||||||
| setAreInternalOptionsInitialized(false); | ||||||||
| resetOptions(); | ||||||||
| }, [resetOptions]); | ||||||||
|
|
||||||||
| return useMemo( | ||||||||
| () => ({ | ||||||||
| initializeOptions, | ||||||||
| options: internalOptions, | ||||||||
| areOptionsInitialized, | ||||||||
| resetOptions, | ||||||||
| areOptionsInitialized: areInternalOptionsInitialized, | ||||||||
| resetOptions: resetInternalOptions, | ||||||||
| }), | ||||||||
| [initializeOptions, internalOptions, areOptionsInitialized, resetOptions], | ||||||||
| [initializeOptions, internalOptions, resetInternalOptions, areInternalOptionsInitialized], | ||||||||
| ); | ||||||||
| }; | ||||||||
|
|
||||||||
|
|
||||||||
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.
Just wondering, why did you choose to use state instead of ref as you suggested earlier?
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 faced an edge case where the list was not currently re-rendered with the correct value
areInternalOptionsInitializedref value.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.
Thanks! Mind sharing how to trigger that edge case?