-
Notifications
You must be signed in to change notification settings - Fork 4k
Show export status in one app-level modal instead of per screen #98521
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
base: main
Are you sure you want to change the base?
Changes from all commits
821ecd7
29c6b16
7ca6857
548a32e
5de1e87
0901054
79f147a
4f021f3
e2639d9
5e3b37d
6e94511
7d5a57a
06a0792
4893468
cb1aed7
9664283
363fb9d
b6ac844
697be31
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,67 @@ | ||
| import useOnyx from '@hooks/useOnyx'; | ||
|
|
||
| import {clearExportDownload, markExportDownloadSurfaced} from '@libs/actions/Export'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| import ExportDownloadStatusModal from './ExportDownloadStatusModal'; | ||
|
|
||
| /** | ||
| * Renders the queued export status modal for the whole app. It watches the export collection and shows the modal | ||
| * for the active export (preparing, ready, or failed). Because it is the single owner of the modal and reads | ||
| * straight from Onyx, a screen only has to start an export (which writes its record); this shows the progress, | ||
| * delivers the file when it is ready, and still surfaces it after a reload or once the screen that started it is | ||
| * gone. There is no per-screen modal to coordinate with. | ||
| */ | ||
| function ExportDownloadStatusManager() { | ||
| const [exportDownloads] = useOnyx(ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD); | ||
|
|
||
| const activeEntry = Object.entries(exportDownloads ?? {}).find(([, exportDownload]) => { | ||
|
Comment on lines
+20
to
+22
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.
When the same account is open in multiple browser tabs, this shared Onyx collection causes every Useful? React with 👍 / 👎. |
||
| if (!exportDownload) { | ||
| return false; | ||
| } | ||
| if (exportDownload.shouldSendFromConcierge) { | ||
| return !exportDownload.hasBeenSurfaced; | ||
| } | ||
| return ( | ||
| exportDownload.state === CONST.EXPORT_DOWNLOAD.STATE.PREPARING || | ||
| exportDownload.state === CONST.EXPORT_DOWNLOAD.STATE.READY || | ||
| exportDownload.state === CONST.EXPORT_DOWNLOAD.STATE.FAILED | ||
|
mollfpr marked this conversation as resolved.
|
||
| ); | ||
| }); | ||
|
|
||
| if (!activeEntry) { | ||
| return null; | ||
| } | ||
|
|
||
| const exportID = activeEntry[0].replace(ONYXKEYS.COLLECTION.EXPORT_DOWNLOAD, ''); | ||
| const exportDownload = activeEntry[1]; | ||
|
|
||
| const handleClose = () => { | ||
| if (exportDownload?.shouldSendFromConcierge) { | ||
| markExportDownloadSurfaced(exportID); | ||
| return; | ||
| } | ||
| // The modal already blocks dismissal while preparing, so this is an extra guard. | ||
| if (exportDownload?.state === CONST.EXPORT_DOWNLOAD.STATE.PREPARING) { | ||
| return; | ||
| } | ||
| clearExportDownload(exportID, exportDownload); | ||
| }; | ||
|
|
||
|
mollfpr marked this conversation as resolved.
|
||
| return ( | ||
| <ExportDownloadStatusModal | ||
| key={exportID} | ||
| exportID={exportID} | ||
| isVisible | ||
| onClose={handleClose} | ||
|
mollfpr marked this conversation as resolved.
|
||
| /> | ||
| ); | ||
| } | ||
|
|
||
| ExportDownloadStatusManager.displayName = 'ExportDownloadStatusManager'; | ||
|
|
||
| export default ExportDownloadStatusManager; | ||
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.