From 96d12d654738cdc814072db01f8a11e9012cb4fb Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Thu, 21 Sep 2023 13:03:00 +0200 Subject: [PATCH 1/3] Cleanup dialog if not in meeting --- .../chess-dialog/chess-dialog.component.html | 11 +++--- .../chess-dialog/chess-dialog.component.ts | 34 ++++++++++--------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.html b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.html index 8093e628c5..45eded4204 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.html +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.html @@ -5,13 +5,10 @@

{{ caption | translate }}

close - -
{{ 'Playing against' | translate }} {{ opponentName }}
-
-
- -
-
diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts index f934a0ebc7..069f3ab8f1 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { Chess, EVENT_TYPE } from 'cm-chess/src/Chess'; import { BORDER_TYPE, Chessboard, COLOR, FEN, INPUT_EVENT_TYPE } from 'cm-chessboard/src/Chessboard'; import { PromotionDialog } from 'cm-chessboard/src/extensions/promotion-dialog/PromotionDialog'; @@ -11,7 +11,7 @@ import { BaseGameDialogComponent, State } from '../../../../components/base-game styleUrls: [`./chess-dialog.component.scss`], encapsulation: ViewEncapsulation.None }) -export class ChessDialogComponent extends BaseGameDialogComponent implements OnInit, OnDestroy { +export class ChessDialogComponent extends BaseGameDialogComponent implements OnInit { protected prefix = `chess`; /** @@ -34,21 +34,23 @@ export class ChessDialogComponent extends BaseGameDialogComponent implements OnI public override ngOnInit(): void { super.ngOnInit(); - this.board = new Chessboard(this.boardContainer.nativeElement, { - position: FEN.start, - language: this.translate.currentLang == `de` ? `de` : `en`, - assetsUrl: `./chess/`, - style: { - borderType: BORDER_TYPE.frame - }, - extensions: [{ class: PromotionDialog }] - }); - this.chess.addObserver(({ type }) => { - if (type === EVENT_TYPE.initialized || type === EVENT_TYPE.legalMove) { - this.board.setPosition(this.chess.fen(), true); - } - }); this.caption = this.translate.instant(`Chess`); + if (this.inMeeting) { + this.board = new Chessboard(this.boardContainer.nativeElement, { + position: FEN.start, + language: this.translate.currentLang == `de` ? `de` : `en`, + assetsUrl: `./chess/`, + style: { + borderType: BORDER_TYPE.frame + }, + extensions: [{ class: PromotionDialog }] + }); + this.chess.addObserver(({ type }) => { + if (type === EVENT_TYPE.initialized || type === EVENT_TYPE.legalMove) { + this.board.setPosition(this.chess.fen(), true); + } + }); + } } protected override reset(): void { From 508f7159e7f2eb0c685ca61c45e80b5ef22ea496 Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Tue, 26 Sep 2023 10:00:17 +0200 Subject: [PATCH 2/3] Add alternative way to start --- .../account-button.component.ts | 14 +++++-- .../global-headbar/global-headbar.module.ts | 2 + .../base-game-dialog/base-game-dialog.ts | 18 ++++---- .../chess-dialog/chess-dialog.module.ts | 4 +- .../chess-dialog/chess-dialog.component.ts | 42 ++++++++++++++++++- .../services/chess-challenge.service.ts | 27 ++++++++++++ 6 files changed, 95 insertions(+), 12 deletions(-) create mode 100644 client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts diff --git a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts index 2e8e7fe6df..d1b3bf5b97 100644 --- a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts +++ b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; +import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; import { MatMenuTrigger } from '@angular/material/menu'; import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; @@ -20,6 +20,7 @@ import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; import { ChessDialogComponent } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component'; import { AccountDialogComponent } from '../account-dialog/account-dialog.component'; +import { ChessChallengeService } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service'; @Component({ selector: `os-account-button`, @@ -81,9 +82,11 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit { private theme: ThemeService, private meetingSettingsService: MeetingSettingsService, private activeMeetingIdService: ActiveMeetingIdService, - private controller: UserControllerService + private controller: UserControllerService, + chessChallengeService: ChessChallengeService ) { super(); + chessChallengeService.startListening(); } public ngOnInit(): void { @@ -159,7 +162,12 @@ export class AccountButtonComponent extends BaseUiComponent implements OnInit { if (this.clickCounter === 4) { this.clickCounter = 0; - this.dialog.open(ChessDialogComponent, { ...mediumDialogSettings }); + const config: MatDialogConfig = mediumDialogSettings; + const match = this.router.url.match(/.*\/participants\/(\d+)\/?$/); + if (match) { + config.data = { userId: +match[1] }; + } + this.dialog.open(ChessDialogComponent, config); } else { this.clickTimeout = setTimeout(() => { this.clickCounter = 0; diff --git a/client/src/app/site/modules/global-headbar/global-headbar.module.ts b/client/src/app/site/modules/global-headbar/global-headbar.module.ts index 50d8979428..0cde6cdd5e 100644 --- a/client/src/app/site/modules/global-headbar/global-headbar.module.ts +++ b/client/src/app/site/modules/global-headbar/global-headbar.module.ts @@ -26,6 +26,7 @@ import { AccountButtonComponent } from './components/account-button/account-butt import { AccountDialogComponent } from './components/account-dialog/account-dialog.component'; import { GlobalHeadbarComponent } from './components/global-headbar/global-headbar.component'; import { GlobalSearchComponent } from './components/global-search/global-search.component'; +import { ChessDialogModule } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog'; const MODULES = [ InputModule, @@ -58,6 +59,7 @@ const DECLARATIONS = [GlobalHeadbarComponent]; ScrollingModule, FormsModule, ReactiveFormsModule, + ChessDialogModule, ...MODULES ] }) diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts index 932401dbc6..8f8f868cb3 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/components/base-game-dialog/base-game-dialog.ts @@ -56,7 +56,7 @@ export abstract class BaseGameDialogComponent implements OnInit, OnDestroy { /** * The channel of the opponent. */ - private replyChannel: string | null = null; + protected replyChannel: string | null = null; /** * The opponents name. @@ -227,6 +227,15 @@ export abstract class BaseGameDialogComponent implements OnInit, OnDestroy { return this.op.shortName; } + protected setTimeout(): void { + if (this.waitTimout) { + clearTimeout(this.waitTimout); + } + this.waitTimout = setTimeout(() => { + this.handleEvent(`waitTimeout`); + }, 5000); + } + /** * Main state machine handler. The current state handler will be called with * the given event. If the handler returns a state (and not null), this will be @@ -276,12 +285,7 @@ export abstract class BaseGameDialogComponent implements OnInit, OnDestroy { { name: this.getPlayerName() }, this.replyChannel! ); - if (this.waitTimout) { - clearTimeout(this.waitTimout); - } - this.waitTimout = setTimeout(() => { - this.handleEvent(`waitTimeout`); - }, 5000); + this.setTimeout(); } /** diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts index 3125c69de8..122aafae26 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts @@ -6,10 +6,12 @@ import { MatIconModule } from '@angular/material/icon'; import { OpenSlidesTranslationModule } from 'src/app/site/modules/translations'; import { ChessDialogComponent } from './components/chess-dialog/chess-dialog.component'; +import { PromptDialogModule, PromptService } from 'src/app/ui/modules/prompt-dialog'; @NgModule({ declarations: [ChessDialogComponent], - imports: [CommonModule, MatButtonModule, MatIconModule, MatDialogModule, OpenSlidesTranslationModule.forChild()] + imports: [CommonModule, MatButtonModule, MatIconModule, MatDialogModule, OpenSlidesTranslationModule.forChild(), PromptDialogModule], + providers: [PromptService] }) export class ChessDialogModule { public static readonly label = `Play chess`; diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts index 069f3ab8f1..3eac5208f3 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts @@ -1,9 +1,20 @@ -import { Component, ElementRef, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { Component, ElementRef, Inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { Chess, EVENT_TYPE } from 'cm-chess/src/Chess'; import { BORDER_TYPE, Chessboard, COLOR, FEN, INPUT_EVENT_TYPE } from 'cm-chessboard/src/Chessboard'; import { PromotionDialog } from 'cm-chessboard/src/extensions/promotion-dialog/PromotionDialog'; import { BaseGameDialogComponent, State } from '../../../../components/base-game-dialog/base-game-dialog'; +import { ActiveMeetingService } from 'src/app/site/pages/meetings/services/active-meeting.service'; +import { NotifyResponse, NotifyService } from 'src/app/gateways/notify.service'; +import { OperatorService } from 'src/app/site/services/operator.service'; +import { TranslateService } from '@ngx-translate/core'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { Id } from 'src/app/domain/definitions/key-types'; + +interface ChessDialogConfig { + userId?: Id; + notify?: NotifyResponse<{ name: string }>; +} @Component({ selector: `os-chess-dialog`, @@ -24,6 +35,9 @@ export class ChessDialogComponent extends BaseGameDialogComponent implements OnI */ private board: Chessboard = null; + /** + * The HTML element for the chess board + */ @ViewChild(`chessboard`, { static: true }) public boardContainer: ElementRef; @@ -32,6 +46,16 @@ export class ChessDialogComponent extends BaseGameDialogComponent implements OnI */ private ownColor: COLOR = COLOR.white; + public constructor( + activeMeetingService: ActiveMeetingService, + notifyService: NotifyService, + op: OperatorService, + translate: TranslateService, + @Inject(MAT_DIALOG_DATA) private config: ChessDialogConfig + ) { + super(activeMeetingService, notifyService, op, translate); + } + public override ngOnInit(): void { super.ngOnInit(); this.caption = this.translate.instant(`Chess`); @@ -51,6 +75,22 @@ export class ChessDialogComponent extends BaseGameDialogComponent implements OnI } }); } + if (this.config?.userId) { + this.state = `waitForResponse`; + this.notifyService.sendToUsers(`chess_challenge`, { name: this.getPlayerName() }, this.config.userId); + this.caption = this.translate.instant(`Waiting for response...`); + const handle = this.SM.waitForResponse.receivedACK.handle; + this.SM.waitForResponse.receivedACK.handle = (notify: NotifyResponse<{ name: string }>) => { + if (notify.sender_user_id === this.config.userId) { + this.replyChannel = notify.sender_channel_id; + return handle(notify); + } + return null; + }; + } else if (this.config?.notify) { + this.state = `search`; + this.handleEvent(`receivedSearchResponse`, this.config.notify); + } } protected override reset(): void { diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts new file mode 100644 index 0000000000..3324e7987d --- /dev/null +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { NotifyResponse, NotifyService } from 'src/app/gateways/notify.service'; +import { OperatorService } from 'src/app/site/services/operator.service'; +import { PromptService } from 'src/app/ui/modules/prompt-dialog'; +import { mediumDialogSettings } from 'src/app/infrastructure/utils/dialog-settings'; +import { TranslateService } from '@ngx-translate/core'; +import { ChessDialogModule } from '../chess-dialog.module'; + +@Injectable({ + providedIn: ChessDialogModule +}) +export class ChessChallengeService { + constructor(private notifyService: NotifyService, private op: OperatorService, private dialog: MatDialog, private translate: TranslateService, private prompt: PromptService) {} + + public startListening(): void { + this.notifyService.getMessageObservable(`chess_challenge`).subscribe(async (notify: NotifyResponse<{ name: string }>) => { + if (!notify.sendByThisUser) { + const title = notify.message.name + ` ` + this.translate.instant(`challenged you to a chess match!`); + const content = this.translate.instant(`Do you accept?`); + if (await this.prompt.open(title, content)) { + this.dialog.open(ChessDialogModule.getComponent(), { ...mediumDialogSettings, data: { notify } }) + } + } + }); + } +} From 34a2fd31ea0ffef2f349b9706e3ab4266c340ccd Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Tue, 26 Sep 2023 10:29:25 +0200 Subject: [PATCH 3/3] Fix formatting --- .../account-button.component.ts | 2 +- .../global-headbar/global-headbar.module.ts | 2 +- .../chess-dialog/chess-dialog.module.ts | 11 ++++-- .../chess-dialog/chess-dialog.component.ts | 12 +++---- .../services/chess-challenge.service.ts | 35 +++++++++++++------ 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts index d1b3bf5b97..29c6c7a13c 100644 --- a/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts +++ b/client/src/app/site/modules/global-headbar/components/account-button/account-button.component.ts @@ -18,9 +18,9 @@ import { ThemeService } from 'src/app/site/services/theme.service'; import { UserControllerService } from 'src/app/site/services/user-controller.service'; import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; import { ChessDialogComponent } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component'; +import { ChessChallengeService } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service'; import { AccountDialogComponent } from '../account-dialog/account-dialog.component'; -import { ChessChallengeService } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service'; @Component({ selector: `os-account-button`, diff --git a/client/src/app/site/modules/global-headbar/global-headbar.module.ts b/client/src/app/site/modules/global-headbar/global-headbar.module.ts index 0cde6cdd5e..526aeaec5a 100644 --- a/client/src/app/site/modules/global-headbar/global-headbar.module.ts +++ b/client/src/app/site/modules/global-headbar/global-headbar.module.ts @@ -19,6 +19,7 @@ import { RouterModule } from '@angular/router'; import { DirectivesModule } from 'src/app/ui/directives'; import { CommaSeparatedListingModule } from 'src/app/ui/modules/comma-separated-listing'; import { InputModule } from 'src/app/ui/modules/input'; +import { ChessDialogModule } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog'; import { OpenSlidesTranslationModule } from '../translations'; import { UserComponentsModule } from '../user-components'; @@ -26,7 +27,6 @@ import { AccountButtonComponent } from './components/account-button/account-butt import { AccountDialogComponent } from './components/account-dialog/account-dialog.component'; import { GlobalHeadbarComponent } from './components/global-headbar/global-headbar.component'; import { GlobalSearchComponent } from './components/global-search/global-search.component'; -import { ChessDialogModule } from 'src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog'; const MODULES = [ InputModule, diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts index 122aafae26..2925de490d 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/chess-dialog.module.ts @@ -4,13 +4,20 @@ import { MatButtonModule } from '@angular/material/button'; import { MatDialogModule } from '@angular/material/dialog'; import { MatIconModule } from '@angular/material/icon'; import { OpenSlidesTranslationModule } from 'src/app/site/modules/translations'; +import { PromptDialogModule, PromptService } from 'src/app/ui/modules/prompt-dialog'; import { ChessDialogComponent } from './components/chess-dialog/chess-dialog.component'; -import { PromptDialogModule, PromptService } from 'src/app/ui/modules/prompt-dialog'; @NgModule({ declarations: [ChessDialogComponent], - imports: [CommonModule, MatButtonModule, MatIconModule, MatDialogModule, OpenSlidesTranslationModule.forChild(), PromptDialogModule], + imports: [ + CommonModule, + MatButtonModule, + MatIconModule, + MatDialogModule, + OpenSlidesTranslationModule.forChild(), + PromptDialogModule + ], providers: [PromptService] }) export class ChessDialogModule { diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts index 3eac5208f3..34e2d2f6ff 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/components/chess-dialog/chess-dialog.component.ts @@ -1,15 +1,15 @@ import { Component, ElementRef, Inject, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { TranslateService } from '@ngx-translate/core'; import { Chess, EVENT_TYPE } from 'cm-chess/src/Chess'; import { BORDER_TYPE, Chessboard, COLOR, FEN, INPUT_EVENT_TYPE } from 'cm-chessboard/src/Chessboard'; import { PromotionDialog } from 'cm-chessboard/src/extensions/promotion-dialog/PromotionDialog'; - -import { BaseGameDialogComponent, State } from '../../../../components/base-game-dialog/base-game-dialog'; -import { ActiveMeetingService } from 'src/app/site/pages/meetings/services/active-meeting.service'; +import { Id } from 'src/app/domain/definitions/key-types'; import { NotifyResponse, NotifyService } from 'src/app/gateways/notify.service'; +import { ActiveMeetingService } from 'src/app/site/pages/meetings/services/active-meeting.service'; import { OperatorService } from 'src/app/site/services/operator.service'; -import { TranslateService } from '@ngx-translate/core'; -import { MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { Id } from 'src/app/domain/definitions/key-types'; + +import { BaseGameDialogComponent, State } from '../../../../components/base-game-dialog/base-game-dialog'; interface ChessDialogConfig { userId?: Id; diff --git a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts index 3324e7987d..96e65a3c4c 100644 --- a/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts +++ b/client/src/app/ui/modules/sidenav/modules/easter-egg/modules/chess-dialog/services/chess-challenge.service.ts @@ -1,27 +1,40 @@ import { Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; +import { TranslateService } from '@ngx-translate/core'; import { NotifyResponse, NotifyService } from 'src/app/gateways/notify.service'; +import { mediumDialogSettings } from 'src/app/infrastructure/utils/dialog-settings'; import { OperatorService } from 'src/app/site/services/operator.service'; import { PromptService } from 'src/app/ui/modules/prompt-dialog'; -import { mediumDialogSettings } from 'src/app/infrastructure/utils/dialog-settings'; -import { TranslateService } from '@ngx-translate/core'; + import { ChessDialogModule } from '../chess-dialog.module'; @Injectable({ providedIn: ChessDialogModule }) export class ChessChallengeService { - constructor(private notifyService: NotifyService, private op: OperatorService, private dialog: MatDialog, private translate: TranslateService, private prompt: PromptService) {} + constructor( + private notifyService: NotifyService, + private op: OperatorService, + private dialog: MatDialog, + private translate: TranslateService, + private prompt: PromptService + ) {} public startListening(): void { - this.notifyService.getMessageObservable(`chess_challenge`).subscribe(async (notify: NotifyResponse<{ name: string }>) => { - if (!notify.sendByThisUser) { - const title = notify.message.name + ` ` + this.translate.instant(`challenged you to a chess match!`); - const content = this.translate.instant(`Do you accept?`); - if (await this.prompt.open(title, content)) { - this.dialog.open(ChessDialogModule.getComponent(), { ...mediumDialogSettings, data: { notify } }) + this.notifyService + .getMessageObservable(`chess_challenge`) + .subscribe(async (notify: NotifyResponse<{ name: string }>) => { + if (!notify.sendByThisUser) { + const title = + notify.message.name + ` ` + this.translate.instant(`challenged you to a chess match!`); + const content = this.translate.instant(`Do you accept?`); + if (await this.prompt.open(title, content)) { + this.dialog.open(ChessDialogModule.getComponent(), { + ...mediumDialogSettings, + data: { notify } + }); + } } - } - }); + }); } }