-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[NoQA] [HR Import] Initial sync modal, sync action and info on Members page #91315
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 9 commits
de5c54c
5e693c2
08076cf
df31cef
0d933d5
86095ba
e573980
ffbfb77
1f148e6
897ea31
2d31562
0a22e99
dbfd1fd
7d16afb
b6e4c26
158a688
38199e7
50e428e
bbb9810
ab55e28
ce62021
581fea7
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import {useEffect, useEffectEvent} from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import {setMergeHRInitialSyncModalShown} from '@libs/actions/connections/MergeHR'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type Policy from '@src/types/onyx/Policy'; | ||
| import useConfirmModal from './useConfirmModal'; | ||
| import useLocalize from './useLocalize'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| /** | ||
| * Shows a one-time informational modal when the Merge HR connection's first backend-initiated sync starts. | ||
| * The modal is suppressed for subsequent page loads during the same sync by persisting a sentinel value in Onyx. | ||
| */ | ||
| function useMergeHRInitialSyncingModal(policyID: string, policy: OnyxEntry<Policy>, isFocused: boolean) { | ||
|
mhawryluk marked this conversation as resolved.
Outdated
|
||
| const {showConfirmModal} = useConfirmModal(); | ||
| const {translate} = useLocalize(); | ||
| const [shownSentinel] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_MERGE_HR_INITIAL_SYNC_MODAL_SHOWN}${policyID}`); | ||
|
|
||
| const showSyncingModal = useEffectEvent(() => { | ||
| if (shownSentinel) { | ||
| return; | ||
| } | ||
| setMergeHRInitialSyncModalShown(policyID); | ||
| showConfirmModal({ | ||
| id: `merge-hr-syncing-${policyID}`, | ||
| title: translate('workspace.hr.syncingModalTitle'), | ||
| prompt: translate('workspace.hr.syncingModalDescription'), | ||
| confirmText: translate('common.buttonConfirm'), | ||
| shouldShowCancelButton: false, | ||
| }); | ||
| }); | ||
|
|
||
| const mergeLastSync = policy?.connections?.[CONST.POLICY.CONNECTIONS.NAME.MERGE_HR]?.lastSync; | ||
|
|
||
| useEffect(() => { | ||
| const isInitialSyncInProgress = mergeLastSync?.syncStatus === CONST.MERGE_HR.SYNC_STATUS.SYNCING && mergeLastSync?.syncType === CONST.MERGE_HR.SYNC_TYPE.INITIAL; | ||
|
|
||
| if (!isFocused || !isInitialSyncInProgress) { | ||
| return; | ||
| } | ||
|
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. [isInitialSyncInProgress, isFocused] @mhawryluk have you tried passing in isInitialSyncInProgress rather than rerender on both changes? |
||
|
|
||
| showSyncingModal(); | ||
|
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. could we use InteractionManager.runAfterInteractions here?
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. good idea, |
||
| }, [mergeLastSync?.syncStatus, mergeLastSync?.syncType, isFocused]); | ||
| } | ||
|
|
||
| export default useMergeHRInitialSyncingModal; | ||
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.
SYNC_STATUS: "SYNCING" | "DONE" | "FAILED" | "DISABLED";
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.
SYNC_TYPE: "initial" | "manual" | "auto" | "webhook";
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.
So the loading state is
First sync:
{ ... syncStatus: 'SYNCING', syncType: 'initial' }When done:
{ ... successfulDate: `<idk some date format off top of head>` syncStatus: 'DONE' | 'FAILED' | 'DISABLED', syncType: 'initial' }We only care about initial vs not initial for now, so we can ignore the other syncTypes for the time status