@@ -253,6 +253,7 @@ export function ScriptureTable(props: IProps) {
253253 const [ uploadGraphicVisible , setUploadGraphicVisible ] = useState ( false ) ;
254254 const [ importList , setImportList ] = useState < File [ ] > ( ) ;
255255 const cancelled = useRef ( false ) ;
256+ const graphicUploadCompleted = useRef ( false ) ;
256257 const uploadItem = useRef < ISheet | undefined > ( undefined ) ;
257258 const [ editRow , setEditRow ] = useState < ISheet > ( ) ;
258259 const [ versionRow , setVersionRow ] = useState < ISheet > ( ) ;
@@ -1156,6 +1157,7 @@ export function ScriptureTable(props: IProps) {
11561157
11571158 const handleGraphic = ( i : number ) => {
11581159 saveIfChanged ( ( ) => {
1160+ graphicUploadCompleted . current = false ;
11591161 setUploadType ( UploadType . Graphic ) ;
11601162 const { ws } = getByIndex ( sheetRef . current , i ) ;
11611163 const defaultName = getDefaultName ( ws , 'graphic' , memory , plan ) ;
@@ -1219,9 +1221,14 @@ export function ScriptureTable(props: IProps) {
12191221
12201222 const handleUploadGraphicVisible = ( v : boolean ) => {
12211223 if ( ! v && Boolean ( uploadType ) ) {
1222- afterConvert ( [ ] ) . then ( ( ) => {
1224+ if ( graphicUploadCompleted . current ) {
1225+ // Skip afterConvert - upload already saved; Dialog onClose may call us again
12231226 graphicsClosed ( false ) ;
1224- } ) ;
1227+ } else {
1228+ afterConvert ( [ ] ) . then ( ( ) => {
1229+ graphicsClosed ( false ) ;
1230+ } ) ;
1231+ }
12251232 } else {
12261233 graphicsClosed ( v ) ;
12271234 }
@@ -2121,7 +2128,10 @@ export function ScriptureTable(props: IProps) {
21212128 onOpen = { handleUploadGraphicVisible }
21222129 showMessage = { showMessage }
21232130 hasRights = { Boolean ( curGraphicRights ) }
2124- finish = { afterConvert }
2131+ finish = { ( images ) => {
2132+ if ( images . length > 0 ) graphicUploadCompleted . current = true ;
2133+ return afterConvert ( images ) ;
2134+ } }
21252135 cancelled = { cancelled }
21262136 uploadType = { uploadType as UploadType }
21272137 onFiles = { onFiles }
0 commit comments