@@ -117,26 +117,33 @@ class GraphLoadSave extends GraphUndoRedo {
117117 } ,
118118 ] ,
119119 } ;
120- const handle = await window . showSaveFilePicker ( options ) ;
121- const stream = await handle . createWritable ( ) ;
122- await stream . write ( blob ) ;
123- await stream . close ( ) ;
124- const fileData = await handle . getFile ( ) ;
125- let fS = this . superState . fileState ;
126- fS = fS . concat ( [ {
127- key : `${ this . superState . uploadedDirName } /${ handle . name } ` ,
128- modified : fileData . lastModified ,
129- size : fileData . size ,
130- fileObj : fileData ,
131- fileHandle : handle ,
132- } ] ) ;
133- this . dispatcher ( { type : T . SET_FILE_STATE , payload : fS } ) ;
120+ try {
121+ const handle = await window . showSaveFilePicker ( options ) ;
122+ const stream = await handle . createWritable ( ) ;
123+ await stream . write ( blob ) ;
124+ await stream . close ( ) ;
125+ const fileData = await handle . getFile ( ) ;
126+ let fS = this . superState . fileState ;
127+ fS = fS . concat ( [ {
128+ key : `${ this . superState . uploadedDirName } /${ handle . name } ` ,
129+ modified : fileData . lastModified ,
130+ size : fileData . size ,
131+ fileObj : fileData ,
132+ fileHandle : handle ,
133+ } ] ) ;
134+ this . dispatcher ( { type : T . SET_FILE_STATE , payload : fS } ) ;
135+ toast . success ( 'File saved Successfully' ) ;
136+ } catch ( error ) {
137+ if ( error . name !== 'AbortError' ) {
138+ console . error ( error ) ;
139+ }
140+ }
134141 } else {
135142 // eslint-disable-next-line no-alert
136143 const fileName = prompt ( 'Filename:' ) ;
137144 saveAs ( blob , `${ fileName || `${ this . getName ( ) } -concore` } .graphml` ) ;
145+ toast . success ( 'File saved Successfully' ) ;
138146 }
139- toast . success ( 'File saved Successfully' ) ;
140147 }
141148
142149 async saveWithoutFileHandle ( ) {
@@ -158,15 +165,21 @@ class GraphLoadSave extends GraphUndoRedo {
158165 } ,
159166 ] ,
160167 } ;
161- const handle = await window . showSaveFilePicker ( options ) ;
162- this . dispatcher ( {
163- type : T . SET_FILE_HANDLE ,
164- payload : { curGraphIndex : this . superState . curGraphIndex , fileHandle : handle } ,
165- } ) ;
166- const stream = await handle . createWritable ( ) ;
167- await stream . write ( blob ) ;
168- await stream . close ( ) ;
169- toast . success ( 'File saved Successfully' ) ;
168+ try {
169+ const handle = await window . showSaveFilePicker ( options ) ;
170+ this . dispatcher ( {
171+ type : T . SET_FILE_HANDLE ,
172+ payload : { curGraphIndex : this . superState . curGraphIndex , fileHandle : handle } ,
173+ } ) ;
174+ const stream = await handle . createWritable ( ) ;
175+ await stream . write ( blob ) ;
176+ await stream . close ( ) ;
177+ toast . success ( 'File saved Successfully' ) ;
178+ } catch ( error ) {
179+ if ( error . name !== 'AbortError' ) {
180+ console . error ( error ) ;
181+ }
182+ }
170183 }
171184
172185 saveToFolder ( ) {
0 commit comments