moved start logic to exportModal from exportInit
This commit is contained in:
parent
4a4accc4d4
commit
04e1b80cae
|
@ -2,26 +2,17 @@ import { DeadCenter } from 'pages/gallery';
|
|||
import React from 'react';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import constants from 'utils/strings/constants';
|
||||
import { ExportStage } from './ExportModal';
|
||||
|
||||
interface Props {
|
||||
show: boolean
|
||||
onHide: () => void
|
||||
updateExportFolder: (newFolder: string) => void;
|
||||
updateExportStage: (newState: ExportStage) => void;
|
||||
exportFolder: string
|
||||
exportFiles: () => void
|
||||
startExport: () => void
|
||||
exportSize: string;
|
||||
selectExportDirectory: () => void
|
||||
}
|
||||
export default function ExportInit(props: Props) {
|
||||
const startExport = async () => {
|
||||
if (!props.exportFolder) {
|
||||
await props.selectExportDirectory();
|
||||
}
|
||||
props.exportFiles();
|
||||
props.updateExportStage(ExportStage.INPROGRESS);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DeadCenter >
|
||||
|
@ -35,7 +26,7 @@ export default function ExportInit(props: Props) {
|
|||
flex: 1,
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
onClick={startExport}
|
||||
onClick={props.startExport}
|
||||
>{constants.START}</Button>
|
||||
</DeadCenter>
|
||||
</>
|
||||
|
|
|
@ -79,7 +79,14 @@ export default function ExportModal(props: Props) {
|
|||
setData(LS_KEYS.EXPORT, { ...getData(LS_KEYS.EXPORT), time: newTime });
|
||||
};
|
||||
|
||||
const startExport = () => {
|
||||
const startExport = async () => {
|
||||
if (!exportFolder) {
|
||||
const folderSelected = await selectExportDirectory();
|
||||
if (!folderSelected) {
|
||||
// no-op as select folder aborted
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateExportStage(ExportStage.INPROGRESS);
|
||||
setExportStats({ current: 0, total: 0, failed: 0 });
|
||||
exportService.exportFiles(setExportStats);
|
||||
|
@ -87,7 +94,12 @@ export default function ExportModal(props: Props) {
|
|||
|
||||
const selectExportDirectory = async () => {
|
||||
const newFolder = await exportService.selectExportDirectory();
|
||||
newFolder && updateExportFolder(newFolder);
|
||||
if (newFolder) {
|
||||
updateExportFolder(newFolder);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const cancelExport = () => {
|
||||
|
@ -111,8 +123,7 @@ export default function ExportModal(props: Props) {
|
|||
exportFolder={exportFolder}
|
||||
exportSize={exportSize}
|
||||
updateExportFolder={updateExportFolder}
|
||||
exportFiles={startExport}
|
||||
updateExportStage={updateExportStage}
|
||||
startExport={startExport}
|
||||
selectExportDirectory={selectExportDirectory}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -61,7 +61,7 @@ class ExportService {
|
|||
try {
|
||||
const dir = getData(LS_KEYS.EXPORT).folder;
|
||||
if (!dir) {
|
||||
// directory selector closed
|
||||
// no-export folder set
|
||||
return;
|
||||
}
|
||||
const exportedFiles: Set<string> = await this.ElectronAPIs.getExportedFiles(
|
||||
|
|
Loading…
Reference in a new issue