@@ -14,28 +14,31 @@ export const useRedactionPlan = reactive({
1414 } ,
1515 async getThumbnail ( imagedict : Record < string , Record < string , string > > ) {
1616 Object . keys ( imagedict ) . forEach ( async ( image ) => {
17- const response = await getImages (
18- this . currentDirectory + "/" + image ,
19- "thumbnail" ,
20- ) ;
21- if ( response . status >= 400 ) {
22- this . imageRedactionPlan . data [ image ] . thumbnail =
23- "/thumbnailPlaceholder.svg" ;
24- return ;
25- }
26- if ( response . body ) {
27- const reader = response . body . getReader ( ) ;
28- const chunks = [ ] ;
17+ const keys = [ "thumbnail" , "label" , "macro" ] ;
18+ for ( let kidx = 0 ; kidx < keys . length ; kidx += 1 ) {
19+ const key = keys [ kidx ] ;
20+ const response = await getImages (
21+ this . currentDirectory + "/" + image ,
22+ key ,
23+ ) ;
24+ if ( response . status >= 400 ) {
25+ this . imageRedactionPlan . data [ image ] [ key ] = key === "thumbnail" ? "/thumbnailPlaceholder.svg" : "/associatedPlaceholder.svg" ;
26+ return ;
27+ }
28+ if ( response . body ) {
29+ const reader = response . body . getReader ( ) ;
30+ const chunks = [ ] ;
2931
30- while ( true ) {
31- const { done, value } = await reader . read ( ) ;
32- if ( done ) break ;
33- chunks . push ( value ) ;
32+ while ( true ) {
33+ const { done, value } = await reader . read ( ) ;
34+ if ( done ) break ;
35+ chunks . push ( value ) ;
36+ }
37+ const blob = new Blob ( chunks ) ;
38+ const url = URL . createObjectURL ( blob ) ;
39+ this . imageRedactionPlan . data [ image ] [ key ] = url ;
3440 }
35- const blob = new Blob ( chunks ) ;
36- const url = URL . createObjectURL ( blob ) ;
37- this . imageRedactionPlan . data [ image ] . thumbnail = url ;
38- }
41+ } ;
3942 } ) ;
4043 } ,
4144
0 commit comments