Skip to content

Commit bcc5780

Browse files
committed
feat: PictureAcceptReplace via gRPC
1 parent 4013933 commit bcc5780

File tree

3 files changed

+69
-20
lines changed

3 files changed

+69
-20
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ <h3 i18n>Replacement</h3>
382382
>
383383
</p>
384384
@if (picture.rights.accept) {
385-
<button class="btn btn-success" (click)="acceptReplace(picture.id)">
385+
<button class="btn btn-success" (click)="acceptReplace(picture.id + '')">
386386
<i class="bi bi-arrow-left-right" aria-hidden="true"></i>
387387
<ng-container i18n>Accept and remove double</ng-container>
388388
</button>

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -498,28 +498,40 @@ export class ModerPicturesItemComponent {
498498
protected cancelReplace(id: string) {
499499
this.replaceLoading = true;
500500

501-
this.picturesClient.clearReplacePicture(new PictureIDRequest({id})).subscribe({
502-
error: () => {
503-
this.replaceLoading = false;
504-
},
505-
next: () => {
506-
this.change$.next();
507-
this.replaceLoading = false;
508-
},
509-
});
501+
this.picturesClient
502+
.clearReplacePicture(new PictureIDRequest({id}))
503+
.pipe(
504+
catchError((error: unknown) => {
505+
this.replaceLoading = false;
506+
this.toastService.handleError(error);
507+
return EMPTY;
508+
}),
509+
)
510+
.subscribe({
511+
next: () => {
512+
this.change$.next();
513+
this.replaceLoading = false;
514+
},
515+
});
510516
}
511517

512-
protected acceptReplace(id: number) {
518+
protected acceptReplace(id: string) {
513519
this.replaceLoading = true;
514-
this.api.request<void>('PUT', 'picture/' + id + '/accept-replace', {body: {}}).subscribe({
515-
error: () => {
516-
this.replaceLoading = false;
517-
},
518-
next: () => {
519-
this.change$.next();
520-
this.replaceLoading = false;
521-
},
522-
});
520+
this.picturesClient
521+
.acceptReplacePicture(new PictureIDRequest({id}))
522+
.pipe(
523+
catchError((error: unknown) => {
524+
this.replaceLoading = false;
525+
this.toastService.handleError(error);
526+
return EMPTY;
527+
}),
528+
)
529+
.subscribe({
530+
next: () => {
531+
this.change$.next();
532+
this.replaceLoading = false;
533+
},
534+
});
523535
}
524536

525537
protected removeFromBlacklist(ip: string) {

src/grpc/spec.pbsc.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,6 +3929,27 @@ export class PicturesClient {
39293929
responseClass: googleProtobuf001.Empty
39303930
});
39313931
},
3932+
/**
3933+
* Unary call: /goautowp.Pictures/AcceptReplacePicture
3934+
*
3935+
* @param requestMessage Request message
3936+
* @param requestMetadata Request metadata
3937+
* @returns Observable<GrpcEvent<googleProtobuf001.Empty>>
3938+
*/
3939+
acceptReplacePicture: (
3940+
requestData: thisProto.PictureIDRequest,
3941+
requestMetadata = new GrpcMetadata()
3942+
): Observable<GrpcEvent<googleProtobuf001.Empty>> => {
3943+
return this.handler.handle({
3944+
type: GrpcCallType.unary,
3945+
client: this.client,
3946+
path: '/goautowp.Pictures/AcceptReplacePicture',
3947+
requestData,
3948+
requestMetadata,
3949+
requestClass: thisProto.PictureIDRequest,
3950+
responseClass: googleProtobuf001.Empty
3951+
});
3952+
},
39323953
/**
39333954
* Unary call: /goautowp.Pictures/SetPicturePoint
39343955
*
@@ -4327,6 +4348,22 @@ export class PicturesClient {
43274348
.pipe(throwStatusErrors(), takeMessages());
43284349
}
43294350

4351+
/**
4352+
* Unary call @/goautowp.Pictures/AcceptReplacePicture
4353+
*
4354+
* @param requestMessage Request message
4355+
* @param requestMetadata Request metadata
4356+
* @returns Observable<googleProtobuf001.Empty>
4357+
*/
4358+
acceptReplacePicture(
4359+
requestData: thisProto.PictureIDRequest,
4360+
requestMetadata = new GrpcMetadata()
4361+
): Observable<googleProtobuf001.Empty> {
4362+
return this.$raw
4363+
.acceptReplacePicture(requestData, requestMetadata)
4364+
.pipe(throwStatusErrors(), takeMessages());
4365+
}
4366+
43304367
/**
43314368
* Unary call @/goautowp.Pictures/SetPicturePoint
43324369
*

0 commit comments

Comments
 (0)