Merge pull request #6127 from tsiegleauq/stop-vote-show-please-wait

Use vote pending state as subject
This commit is contained in:
Emanuel Schütze 2021-06-23 16:18:38 +02:00 committed by GitHub
commit a14ab8c5e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -49,14 +49,14 @@
mat-stroked-button
[ngClass]="pollStateActions[poll.state].css"
(click)="nextPollState()"
[disabled]="stateChangePending"
[disabled]="stateChangePendingObservable | async"
>
<mat-icon> {{ pollStateActions[poll.state].icon }}</mat-icon>
<span class="next-state-label">
<ng-container *ngIf="!stateChangePending">
<ng-container *ngIf="!(stateChangePendingObservable | async)">
{{ poll.nextStateActionVerbose | translate }}
</ng-container>
<ng-container *ngIf="stateChangePending">
<ng-container *ngIf="stateChangePendingObservable | async">
{{ 'In progress, please wait...' | translate }}
</ng-container>
</span>

View File

@ -51,14 +51,14 @@
mat-stroked-button
[ngClass]="pollStateActions[poll.state].css"
(click)="nextPollState()"
[disabled]="stateChangePending"
[disabled]="stateChangePendingObservable | async"
>
<mat-icon> {{ pollStateActions[poll.state].icon }}</mat-icon>
<span class="next-state-label">
<ng-container *ngIf="!stateChangePending">
<ng-container *ngIf="!(stateChangePendingObservable | async)">
{{ poll.nextStateActionVerbose | translate }}
</ng-container>
<ng-container *ngIf="stateChangePending">
<ng-container *ngIf="stateChangePendingObservable | async">
{{ 'In progress, please wait...' | translate }}
</ng-container>
</span>

View File

@ -3,7 +3,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { Title } from '@angular/platform-browser';
import { TranslateService } from '@ngx-translate/core';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, Subject } from 'rxjs';
import { BasePollDialogService } from 'app/core/ui-services/base-poll-dialog.service';
import { ChoiceService } from 'app/core/ui-services/choice.service';
@ -19,7 +19,8 @@ export abstract class BasePollComponent<
V extends ViewBasePoll,
S extends PollService
> extends BaseViewComponentDirective {
public stateChangePending = false;
private stateChangePendingSubject = new Subject<boolean>();
public readonly stateChangePendingObservable = this.stateChangePendingSubject.asObservable();
public chartDataSubject: BehaviorSubject<ChartData> = new BehaviorSubject([]);
@ -74,12 +75,12 @@ export abstract class BasePollComponent<
}
private async changeState(targetState: PollState): Promise<void> {
this.stateChangePending = true;
this.stateChangePendingSubject.next(true);
this.repo
.changePollState(this._poll, targetState)
.catch(this.raiseError)
.finally(() => {
this.stateChangePending = false;
this.stateChangePendingSubject.next(false);
});
}