@@ -66,7 +66,7 @@ const cropTitle = (image: APIImage | undefined): string => {
66
66
} ;
67
67
68
68
@Component ( {
69
- changeDetection : ChangeDetectionStrategy . OnPush ,
69
+ changeDetection : ChangeDetectionStrategy . Default ,
70
70
imports : [
71
71
MarkdownComponent ,
72
72
FormsModule ,
@@ -96,7 +96,7 @@ export class UploadIndexComponent implements OnInit {
96
96
protected files : File [ ] | undefined ;
97
97
protected readonly note = new FormControl < string > ( '' , { nonNullable : true } ) ;
98
98
protected progress : UploadProgress [ ] = [ ] ;
99
- protected pictures : APIPictureUpload [ ] = [ ] ;
99
+ protected readonly pictures : APIPictureUpload [ ] = [ ] ;
100
100
protected readonly formHidden = signal ( false ) ;
101
101
protected readonly authenticated$ = this . auth . authenticated$ ;
102
102
@@ -255,6 +255,7 @@ export class UploadIndexComponent implements OnInit {
255
255
progress . failed = true ;
256
256
257
257
progress . invalidParams = response . error . invalid_params ;
258
+ this . #cdr. markForCheck ( ) ;
258
259
}
259
260
260
261
return EMPTY ;
@@ -264,19 +265,24 @@ export class UploadIndexComponent implements OnInit {
264
265
if ( event . total ) {
265
266
progress . percentage = Math . round ( 50 + 25 * ( event . loaded / event . total ) ) ;
266
267
}
268
+
269
+ this . #cdr. markForCheck ( ) ;
267
270
return EMPTY ;
268
271
}
269
272
270
273
if ( event . type === HttpEventType . UploadProgress ) {
271
274
if ( event . total ) {
272
275
progress . percentage = Math . round ( 50 * ( event . loaded / event . total ) ) ;
273
276
}
277
+
278
+ this . #cdr. markForCheck ( ) ;
274
279
return EMPTY ;
275
280
}
276
281
277
282
if ( event . type === HttpEventType . Response ) {
278
283
progress . percentage = 75 ;
279
284
progress . success = true ;
285
+ this . #cdr. markForCheck ( ) ;
280
286
281
287
if ( ! event . body ) {
282
288
return throwError ( ( ) => 'no response body' ) ;
@@ -342,46 +348,47 @@ export class UploadIndexComponent implements OnInit {
342
348
const componentRef : ComponentRef < UploadCropComponent > = modalRef [ '_contentRef' ] . componentRef ;
343
349
componentRef . setInput ( 'picture' , picture . picture ) ;
344
350
345
- modalRef . componentInstance . changed
346
- . pipe (
347
- switchMap ( ( ) =>
348
- this . #picturesClient. setPictureCrop (
349
- new SetPictureCropRequest ( {
350
- cropHeight : picture . picture . image ?. cropHeight ? Math . round ( picture . picture . image . cropHeight ) : undefined ,
351
- cropLeft : picture . picture . image ?. cropLeft ? Math . round ( picture . picture . image . cropLeft ) : undefined ,
352
- cropTop : picture . picture . image ?. cropTop ? Math . round ( picture . picture . image . cropTop ) : undefined ,
353
- cropWidth : picture . picture . image ?. cropWidth ? Math . round ( picture . picture . image . cropWidth ) : undefined ,
354
- pictureId : picture . picture . id ,
355
- } ) ,
356
- ) ,
357
- ) ,
358
- catchError ( ( response : unknown ) => {
359
- this . #toastService. handleError ( response ) ;
360
- return EMPTY ;
361
- } ) ,
362
- switchMap ( ( ) =>
363
- this . #picturesClient. getPicture (
364
- new PicturesRequest ( {
365
- fields : new PictureFields ( {
366
- image : true ,
367
- thumbMedium : true ,
351
+ componentRef . instance . changed . subscribe ( ( ) => {
352
+ this . #picturesClient
353
+ . setPictureCrop (
354
+ new SetPictureCropRequest ( {
355
+ cropHeight : picture . picture . image ?. cropHeight ? Math . round ( picture . picture . image . cropHeight ) : undefined ,
356
+ cropLeft : picture . picture . image ?. cropLeft ? Math . round ( picture . picture . image . cropLeft ) : undefined ,
357
+ cropTop : picture . picture . image ?. cropTop ? Math . round ( picture . picture . image . cropTop ) : undefined ,
358
+ cropWidth : picture . picture . image ?. cropWidth ? Math . round ( picture . picture . image . cropWidth ) : undefined ,
359
+ pictureId : picture . picture . id ,
360
+ } ) ,
361
+ )
362
+ . pipe (
363
+ catchError ( ( response : unknown ) => {
364
+ this . #toastService. handleError ( response ) ;
365
+ return EMPTY ;
366
+ } ) ,
367
+ switchMap ( ( ) =>
368
+ this . #picturesClient. getPicture (
369
+ new PicturesRequest ( {
370
+ fields : new PictureFields ( {
371
+ image : true ,
372
+ thumbMedium : true ,
373
+ } ) ,
374
+ language : this . #languageService. language ,
375
+ options : new PictureListOptions ( { id : picture . picture . id } ) ,
368
376
} ) ,
369
- language : this . #languageService. language ,
370
- options : new PictureListOptions ( { id : picture . picture . id } ) ,
371
- } ) ,
377
+ ) ,
372
378
) ,
373
- ) ,
374
- catchError ( ( response : unknown ) => {
375
- this . #toastService. handleError ( response ) ;
376
- return EMPTY ;
377
- } ) ,
378
- tap ( ( response : Picture ) => {
379
- picture . picture . image = response . image ;
380
- picture . cropTitle = cropTitle ( response . image ) ;
381
- picture . picture . thumbMedium = response . thumbMedium ;
382
- } ) ,
383
- )
384
- . subscribe ( ) ;
379
+ catchError ( ( response : unknown ) => {
380
+ this . #toastService. handleError ( response ) ;
381
+ return EMPTY ;
382
+ } ) ,
383
+ tap ( ( response : Picture ) => {
384
+ picture . picture . image = response . image ;
385
+ picture . cropTitle = cropTitle ( response . image ) ;
386
+ picture . picture . thumbMedium = response . thumbMedium ;
387
+ this . #cdr. markForCheck ( ) ;
388
+ } ) ,
389
+ )
390
+ . subscribe ( ) ;
391
+ } ) ;
385
392
386
393
return false ;
387
394
}
0 commit comments