1
1
import { Component } from '@angular/core' ;
2
2
import { ActivatedRoute , Router } from '@angular/router' ;
3
+ import { Date as grpcDate } from '@grpc/google/type/date.pb' ;
3
4
import {
4
5
APIIP ,
5
6
APIUser ,
@@ -12,6 +13,7 @@ import {
12
13
PictureIDRequest ,
13
14
SetPictureItemItemIDRequest ,
14
15
SetPictureItemPerspectiveRequest ,
16
+ UpdatePictureRequest ,
15
17
} from '@grpc/spec.pb' ;
16
18
import { APIItem } from '@grpc/spec.pb' ;
17
19
import { ItemsClient , PicturesClient } from '@grpc/spec.pbsc' ;
@@ -311,19 +313,25 @@ export class ModerPicturesItemComponent {
311
313
312
314
protected saveSpecialName ( picture : APIPicture ) {
313
315
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 ) => {
325
329
this . specialNameLoading = false ;
326
- } ,
330
+ this . toastService . handleError ( error ) ;
331
+ return EMPTY ;
332
+ } ) ,
333
+ )
334
+ . subscribe ( {
327
335
next : ( ) => {
328
336
this . specialNameLoading = false ;
329
337
} ,
0 commit comments