fix bug with restoring moderator when restarting game

This commit is contained in:
AlecM33
2022-12-27 15:56:13 -05:00
parent f7b028bc05
commit 8ac678a1d7
8 changed files with 57 additions and 31 deletions

View File

@@ -1,4 +1,5 @@
import { globals } from '../../config/globals.js';
import { Confirmation } from '../front_end_components/Confirmation.js';
export class GameTimerManager {
constructor (stateBucket, socket) {
@@ -88,11 +89,18 @@ export class GameTimerManager {
}
displayExpiredTime () {
const currentBtn = document.querySelector('#play-pause img');
const currentBtn = document.querySelector('#timer-container-moderator #play-pause img');
if (currentBtn) {
currentBtn.removeEventListener('click', this.pauseListener);
currentBtn.removeEventListener('click', this.playListener);
currentBtn.remove();
currentBtn.classList.add('disabled');
currentBtn.setAttribute('src', '/images/play-pause-placeholder.svg');
} else {
document.querySelector('#play-pause-placeholder')?.remove();
const placeholderBtn = document.createElement('img');
placeholderBtn.setAttribute('src', '../images/play-pause-placeholder.svg');
placeholderBtn.classList.add('disabled');
document.getElementById('play-pause').appendChild(placeholderBtn);
}
const timer = document.getElementById('game-timer');
@@ -123,6 +131,12 @@ export class GameTimerManager {
}
});
}
if (!socket.hasListeners(globals.COMMANDS.END_TIMER)) {
socket.on(globals.COMMANDS.END_TIMER, () => {
Confirmation('The timer has expired!');
});
}
}
swapToPlayButton () {