Skip to content

Commit 423caf7

Browse files
committed
fix: crop issue
1 parent 73b2b62 commit 423caf7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/app/upload/index/index.component.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,16 @@ export class UploadIndexComponent implements OnInit {
259259
switchMap(() =>
260260
this.picturesClient.setPictureCrop(
261261
new SetPictureCropRequest({
262-
cropHeight: picture.crop.height || undefined,
263-
cropLeft: picture.crop.left || undefined,
264-
cropTop: picture.crop.top || undefined,
265-
cropWidth: picture.crop.width || undefined,
262+
cropHeight: picture.crop.height ? Math.round(picture.crop.height) : undefined,
263+
cropLeft: picture.crop.left ? Math.round(picture.crop.left) : undefined,
264+
cropTop: picture.crop.top ? Math.round(picture.crop.top) : undefined,
265+
cropWidth: picture.crop.width ? Math.round(picture.crop.width) : undefined,
266266
pictureId: '' + picture.id,
267267
}),
268268
),
269269
),
270270
catchError((response: unknown) => {
271-
if (response instanceof HttpErrorResponse) {
272-
this.toastService.response(response);
273-
}
271+
this.toastService.handleError(response);
274272
return EMPTY;
275273
}),
276274
switchMap(() =>
@@ -279,14 +277,12 @@ export class UploadIndexComponent implements OnInit {
279277
}),
280278
),
281279
catchError((response: unknown) => {
282-
if (response instanceof HttpErrorResponse) {
283-
this.toastService.response(response);
284-
}
280+
this.toastService.handleError(response);
285281
return EMPTY;
286282
}),
287283
tap((response: APIPicture) => {
288284
picture.crop = response.crop;
289-
picture.cropTitle = cropTitle(response.crop);
285+
picture.cropTitle = response.crop ? cropTitle(response.crop) : '';
290286
picture.thumb_medium = response.thumb_medium;
291287
}),
292288
)

0 commit comments

Comments
 (0)