Skip to content

Commit d33648f

Browse files
committed
feat: migrate to updatePicture gRPC API
1 parent 3f28618 commit d33648f

File tree

3 files changed

+320
-86
lines changed

3 files changed

+320
-86
lines changed

src/app/moder/pictures/item/item.component.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component} from '@angular/core';
22
import {ActivatedRoute, Router} from '@angular/router';
3+
import {Date as grpcDate} from '@grpc/google/type/date.pb';
34
import {
45
APIIP,
56
APIUser,
@@ -12,6 +13,7 @@ import {
1213
PictureIDRequest,
1314
SetPictureItemItemIDRequest,
1415
SetPictureItemPerspectiveRequest,
16+
UpdatePictureRequest,
1517
} from '@grpc/spec.pb';
1618
import {APIItem} from '@grpc/spec.pb';
1719
import {ItemsClient, PicturesClient} from '@grpc/spec.pbsc';
@@ -311,19 +313,25 @@ export class ModerPicturesItemComponent {
311313

312314
protected saveSpecialName(picture: APIPicture) {
313315
this.specialNameLoading = true;
314-
this.api
315-
.request<void>('PUT', 'picture/' + picture.id, {
316-
body: {
317-
special_name: picture.special_name,
318-
taken_day: picture.taken_day,
319-
taken_month: picture.taken_month,
320-
taken_year: picture.taken_year,
321-
},
322-
})
323-
.subscribe({
324-
error: () => {
316+
this.picturesClient
317+
.updatePicture(
318+
new UpdatePictureRequest({
319+
name: picture.special_name,
320+
takenDate: new grpcDate({
321+
day: picture.taken_day,
322+
month: picture.taken_month,
323+
year: picture.taken_year,
324+
}),
325+
}),
326+
)
327+
.pipe(
328+
catchError((error: unknown) => {
325329
this.specialNameLoading = false;
326-
},
330+
this.toastService.handleError(error);
331+
return EMPTY;
332+
}),
333+
)
334+
.subscribe({
327335
next: () => {
328336
this.specialNameLoading = false;
329337
},

0 commit comments

Comments
 (0)