null safe variable
This commit is contained in:
parent
42817eb8d2
commit
2424767e79
|
@ -115,8 +115,8 @@ export default function ExportModal(props: Props) {
|
||||||
(file) => file.ownerID === user?.id
|
(file) => file.ownerID === user?.id
|
||||||
);
|
);
|
||||||
const exportRecord = await exportService.getExportRecord();
|
const exportRecord = await exportService.getExportRecord();
|
||||||
const exportedFileCnt = exportRecord.exportedFiles.length;
|
const exportedFileCnt = exportRecord.exportedFiles?.length;
|
||||||
const failedFilesCnt = exportRecord.failedFiles.length;
|
const failedFilesCnt = exportRecord.failedFiles?.length;
|
||||||
const syncedFilesCnt = userPersonalFiles.length;
|
const syncedFilesCnt = userPersonalFiles.length;
|
||||||
if (syncedFilesCnt > exportedFileCnt + failedFilesCnt) {
|
if (syncedFilesCnt > exportedFileCnt + failedFilesCnt) {
|
||||||
updateExportProgress({
|
updateExportProgress({
|
||||||
|
@ -191,8 +191,8 @@ export default function ExportModal(props: Props) {
|
||||||
updateExportStage(ExportStage.INPROGRESS);
|
updateExportStage(ExportStage.INPROGRESS);
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
};
|
};
|
||||||
const postExportRun = async (paused: Boolean) => {
|
const postExportRun = async (exportResult?: { paused?: boolean }) => {
|
||||||
if (!paused) {
|
if (!exportResult?.paused) {
|
||||||
updateExportStage(ExportStage.FINISHED);
|
updateExportStage(ExportStage.FINISHED);
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
updateExportTime(Date.now());
|
updateExportTime(Date.now());
|
||||||
|
@ -202,22 +202,22 @@ export default function ExportModal(props: Props) {
|
||||||
const startExport = async () => {
|
const startExport = async () => {
|
||||||
await preExportRun();
|
await preExportRun();
|
||||||
updateExportProgress({ current: 0, total: 0 });
|
updateExportProgress({ current: 0, total: 0 });
|
||||||
const { paused } = await exportService.exportFiles(
|
const exportResult = await exportService.exportFiles(
|
||||||
updateExportProgress,
|
updateExportProgress,
|
||||||
ExportType.NEW
|
ExportType.NEW
|
||||||
);
|
);
|
||||||
await postExportRun(paused);
|
await postExportRun(exportResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
const stopExport = async () => {
|
const stopExport = async () => {
|
||||||
exportService.stopRunningExport();
|
exportService.stopRunningExport();
|
||||||
postExportRun(false);
|
postExportRun();
|
||||||
};
|
};
|
||||||
|
|
||||||
const pauseExport = () => {
|
const pauseExport = () => {
|
||||||
updateExportStage(ExportStage.PAUSED);
|
updateExportStage(ExportStage.PAUSED);
|
||||||
exportService.pauseRunningExport();
|
exportService.pauseRunningExport();
|
||||||
postExportRun(true);
|
postExportRun({ paused: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
const resumeExport = async () => {
|
const resumeExport = async () => {
|
||||||
|
@ -232,23 +232,23 @@ export default function ExportModal(props: Props) {
|
||||||
current: pausedStageProgress.current + progress.current,
|
current: pausedStageProgress.current + progress.current,
|
||||||
total: pausedStageProgress.current + progress.total,
|
total: pausedStageProgress.current + progress.total,
|
||||||
});
|
});
|
||||||
const { paused } = await exportService.exportFiles(
|
const exportResult = await exportService.exportFiles(
|
||||||
updateExportStatsWithOffset,
|
updateExportStatsWithOffset,
|
||||||
ExportType.PENDING
|
ExportType.PENDING
|
||||||
);
|
);
|
||||||
|
|
||||||
await postExportRun(paused);
|
await postExportRun(exportResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
const retryFailedExport = async () => {
|
const retryFailedExport = async () => {
|
||||||
await preExportRun();
|
await preExportRun();
|
||||||
updateExportProgress({ current: 0, total: exportStats.failed });
|
updateExportProgress({ current: 0, total: exportStats.failed });
|
||||||
|
|
||||||
const { paused } = await exportService.exportFiles(
|
const exportResult = await exportService.exportFiles(
|
||||||
updateExportProgress,
|
updateExportProgress,
|
||||||
ExportType.RETRY_FAILED
|
ExportType.RETRY_FAILED
|
||||||
);
|
);
|
||||||
await postExportRun(paused);
|
await postExportRun(exportResult);
|
||||||
};
|
};
|
||||||
|
|
||||||
const syncExportStatsWithReport = async () => {
|
const syncExportStatsWithReport = async () => {
|
||||||
|
|
Loading…
Reference in a new issue