@@ -8,7 +8,7 @@ import Button from "react-bootstrap/Button";
88import Form from "react-bootstrap/Form" ;
99
1010// Project Component
11- import ColoredRadio from "../components/ColoredRadio " ;
11+ import { ColoredCheckBox , ColoredRadio } from "../components/ColoredFormCheck " ;
1212import FolderSelector from "../components/FolderSelector" ;
1313import { ModalControl } from "../controls/ModalControl" ;
1414
@@ -18,6 +18,7 @@ import {
1818 ExportCbzWithDefaultWrap ,
1919 ExportCbzWithWrap ,
2020 GetDefaultOutputDirectory ,
21+ RunSoftDelete ,
2122} from "../../wailsjs/go/application/App" ;
2223import { comicinfo } from "../../wailsjs/go/models" ;
2324import { ExportMethod } from "../controls/SessionData" ;
@@ -35,6 +36,10 @@ type ExportProps = {
3536 exportMethod : ExportMethod ;
3637 /** Method to set export method as react hook. */
3738 setExportMethod : ( val : ExportMethod ) => void ;
39+ /** Delete after export. */
40+ deleteAfterExport : boolean ;
41+ /** Method to set delete after export as react hook. */
42+ setDeleteAfterExport : ( val : boolean ) => void ;
3843} ;
3944
4045/**
@@ -47,6 +52,8 @@ export default function ExportPanel({
4752 modalControl,
4853 exportMethod,
4954 setExportMethod,
55+ deleteAfterExport,
56+ setDeleteAfterExport,
5057} : Readonly < ExportProps > ) {
5158 // Since this is the final step, could ignore the interaction with App.tsx
5259 const [ defaultDir , setDefaultDir ] = useState < string > ( "" ) ;
@@ -114,12 +121,32 @@ export default function ExportPanel({
114121
115122 // Start running
116123 promise . then ( ( msg ) => {
124+ console . log ( `cbz return: '${ msg } '` ) ;
125+
117126 if ( msg !== "" ) {
118127 modalControl . showErr ( msg ) ;
119- } else {
128+ return ;
129+ }
130+
131+ // Early return if no need to do anything
132+ if ( ! deleteAfterExport ) {
120133 modalControl . completeAndReset ( ) ;
134+ return ;
135+ }
136+
137+ // Run soft deletion if necessary
138+ if ( deleteAfterExport ) {
139+ console . log ( "Start soft deletion" ) ;
140+
141+ RunSoftDelete ( ) . then ( ( errMsg ) => {
142+ if ( errMsg !== "" ) {
143+ modalControl . showErr ( errMsg ) ;
144+ return ;
145+ }
146+
147+ modalControl . completeAndReset ( ) ;
148+ } ) ;
121149 }
122- console . log ( `cbz return: '${ msg } '` ) ;
123150 } ) ;
124151 }
125152
@@ -180,6 +207,18 @@ export default function ExportPanel({
180207 Export
181208 </ Button >
182209 </ div >
210+
211+ { /* Checkbox to soft deletion */ }
212+ < div className = "d-flex justify-content-center mt-2" >
213+ < ColoredCheckBox
214+ id = "soft-deletion"
215+ name = "soft-deletion"
216+ color = "dark-red"
217+ label = "Soft Delete after export"
218+ checked = { deleteAfterExport }
219+ onChange = { ( ) => setDeleteAfterExport ( ! deleteAfterExport ) }
220+ />
221+ </ div >
183222 </ div >
184223 ) ;
185224}
0 commit comments