Skip to content

Commit

Permalink
feat: PictureAcceptReplace via gRPC
Browse files Browse the repository at this point in the history
  • Loading branch information
autowp committed Sep 1, 2024
1 parent 4013933 commit bcc5780
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/app/moder/pictures/item/item.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ <h3 i18n>Replacement</h3>
>
</p>
@if (picture.rights.accept) {
<button class="btn btn-success" (click)="acceptReplace(picture.id)">
<button class="btn btn-success" (click)="acceptReplace(picture.id + '')">
<i class="bi bi-arrow-left-right" aria-hidden="true"></i>
<ng-container i18n>Accept and remove double</ng-container>
</button>
Expand Down
50 changes: 31 additions & 19 deletions src/app/moder/pictures/item/item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,28 +498,40 @@ export class ModerPicturesItemComponent {
protected cancelReplace(id: string) {
this.replaceLoading = true;

this.picturesClient.clearReplacePicture(new PictureIDRequest({id})).subscribe({
error: () => {
this.replaceLoading = false;
},
next: () => {
this.change$.next();
this.replaceLoading = false;
},
});
this.picturesClient
.clearReplacePicture(new PictureIDRequest({id}))
.pipe(
catchError((error: unknown) => {
this.replaceLoading = false;
this.toastService.handleError(error);
return EMPTY;
}),
)
.subscribe({
next: () => {
this.change$.next();
this.replaceLoading = false;
},
});
}

protected acceptReplace(id: number) {
protected acceptReplace(id: string) {
this.replaceLoading = true;
this.api.request<void>('PUT', 'picture/' + id + '/accept-replace', {body: {}}).subscribe({
error: () => {
this.replaceLoading = false;
},
next: () => {
this.change$.next();
this.replaceLoading = false;
},
});
this.picturesClient
.acceptReplacePicture(new PictureIDRequest({id}))
.pipe(
catchError((error: unknown) => {
this.replaceLoading = false;
this.toastService.handleError(error);
return EMPTY;
}),
)
.subscribe({
next: () => {
this.change$.next();
this.replaceLoading = false;
},
});
}

protected removeFromBlacklist(ip: string) {
Expand Down
37 changes: 37 additions & 0 deletions src/grpc/spec.pbsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3929,6 +3929,27 @@ export class PicturesClient {
responseClass: googleProtobuf001.Empty
});
},
/**
* Unary call: /goautowp.Pictures/AcceptReplacePicture
*
* @param requestMessage Request message
* @param requestMetadata Request metadata
* @returns Observable<GrpcEvent<googleProtobuf001.Empty>>
*/
acceptReplacePicture: (
requestData: thisProto.PictureIDRequest,
requestMetadata = new GrpcMetadata()
): Observable<GrpcEvent<googleProtobuf001.Empty>> => {
return this.handler.handle({
type: GrpcCallType.unary,
client: this.client,
path: '/goautowp.Pictures/AcceptReplacePicture',
requestData,
requestMetadata,
requestClass: thisProto.PictureIDRequest,
responseClass: googleProtobuf001.Empty
});
},
/**
* Unary call: /goautowp.Pictures/SetPicturePoint
*
Expand Down Expand Up @@ -4327,6 +4348,22 @@ export class PicturesClient {
.pipe(throwStatusErrors(), takeMessages());
}

/**
* Unary call @/goautowp.Pictures/AcceptReplacePicture
*
* @param requestMessage Request message
* @param requestMetadata Request metadata
* @returns Observable<googleProtobuf001.Empty>
*/
acceptReplacePicture(
requestData: thisProto.PictureIDRequest,
requestMetadata = new GrpcMetadata()
): Observable<googleProtobuf001.Empty> {
return this.$raw
.acceptReplacePicture(requestData, requestMetadata)
.pipe(throwStatusErrors(), takeMessages());
}

/**
* Unary call @/goautowp.Pictures/SetPicturePoint
*
Expand Down

0 comments on commit bcc5780

Please sign in to comment.