Commit b89fc821 authored by Dennis Willers's avatar Dennis Willers
Browse files

Tabooh Button gets disabled, if someone pressed it for 1500ms.

parent 9e5c3b77
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -74,4 +74,16 @@ export class SocketDataService {
      });
    });
  }

  getCanPressTabooh(sessionName: string): Observable<any> {
    if (!this.isConnected) {
      this.connect(sessionName);
    }
    this.sessionName = sessionName;
    return new Observable(observer => {
      this.socket.on(this.sessionName + ':canPressTabooh', (res: any) => {
        observer.next(res);
      });
    });
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
  <br>
  <button *ngIf="isExplainer" mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</button>
  <button *ngIf="isExplainer" mat-raised-button color="accent" style="margin: 40px" (click)="newCard()">Überspringen &#187;</button>
  <button mat-raised-button color="warn" (click)="wrongAnswer()">Tabooh &#10008;</button>
  <button mat-raised-button color="warn" [disabled]="PressTaboohDisabled" (click)="wrongAnswer()">Tabooh &#10008;</button>
  <br>
  <br>
  <mat-card class="transparent">
+8 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ export class GameComponent implements OnInit, OnDestroy {
  private ngUnsubscribe = new Subject();
  subNewCard: any;
  subEndRound: any;
  subCanPressTabooh: any;
  PressTaboohDisabled = false;
  sessionName = '';
  isWatchdog = false;
  isExplainer = false;
@@ -109,6 +111,12 @@ export class GameComponent implements OnInit, OnDestroy {
          this.router.navigate([this.sessionName + '/' + this.team]);
        }
      });
    this.subCanPressTabooh = this.socketDataService.getCanPressTabooh(this.sessionName)
      .pipe(takeUntil(this.ngUnsubscribe))
      .subscribe(data => {
        console.log('Status Tabooh can pressed: ', data);
        this.PressTaboohDisabled = !JSON.parse(data);
      });
  }

  onTimesUp(): void {