File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed
Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -934,16 +934,19 @@ render() {
934934
935935 async processBlob ( blob , type , wid = null ) {
936936 const reader = new FileReader ( ) ;
937- reader . onload = function ( ) {
938- const arr_str = ( reader . result as string ) . replace ( "data:image/png;base64," , "" ) ;
939- this . send ( {
940- "data" : arr_str ,
941- "type" : type ,
942- "ID" : wid ,
943- } ) ;
944- this . send ( { 'type' : 'async_message' , 'data' : 'ok' } ) ;
945- } . bind ( this ) ;
946- reader . readAsDataURL ( blob ) ;
937+ const dataUrlPromise = new Promise ( ( resolve , reject ) => {
938+ reader . onload = ( ) => resolve ( reader . result ) ;
939+ reader . onerror = reject ;
940+ reader . readAsDataURL ( blob ) ;
941+ } ) ;
942+ const dataUrl = await dataUrlPromise as string ;
943+ const arr_str = dataUrl . replace ( "data:image/png;base64," , "" ) ;
944+ this . send ( {
945+ "data" : arr_str ,
946+ "type" : type ,
947+ "ID" : wid ,
948+ } ) ;
949+ this . send ( { 'type' : 'async_message' , 'data' : 'ok' } ) ;
947950 }
948951
949952
You can’t perform that action at this time.
0 commit comments