Removes or adds nick buttons in the nick selection if they are used by others...

Removes or adds nick buttons in the nick selection if they are used by others or the user who chose the nick leaves the quiz
parent 3bb38ba4
...@@ -95,6 +95,17 @@ export class NicknameSelectComponent implements OnInit, OnDestroy { ...@@ -95,6 +95,17 @@ export class NicknameSelectComponent implements OnInit, OnDestroy {
this._nicks = this._nicks.concat(data); this._nicks = this._nicks.concat(data);
}); });
}); });
this._messageSubscriptions.push(this.messageQueue.subscribe(MessageProtocol.Added, payload => {
this.attendeeService.addMember(payload.member);
const nickIndex = this.nicks.indexOf(payload.member.name);
if (nickIndex > -1) {
this.nicks.splice(nickIndex, 1);
}
}), this.messageQueue.subscribe(MessageProtocol.Removed, payload => {
this.attendeeService.removeMember(payload.name);
this.nicks.push(payload.name);
}));
} }
public ngOnDestroy(): void { public ngOnDestroy(): void {
...@@ -105,7 +116,6 @@ export class NicknameSelectComponent implements OnInit, OnDestroy { ...@@ -105,7 +116,6 @@ export class NicknameSelectComponent implements OnInit, OnDestroy {
private putMember(name: string): Promise<any> { private putMember(name: string): Promise<any> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
this._messageSubscriptions.push(this.messageQueue.subscribe(MessageProtocol.Added, payload => { this._messageSubscriptions.push(this.messageQueue.subscribe(MessageProtocol.Added, payload => {
this.attendeeService.addMember(payload.member);
resolve(); resolve();
})); }));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment