let simul hosts leave the game page
This commit is contained in:
parent
ca527c5961
commit
5f3f67b212
|
@ -151,6 +151,10 @@ export default class RoundController {
|
|||
this.redraw();
|
||||
};
|
||||
|
||||
private isSimulHost = () => {
|
||||
return this.data.simul && this.data.simul.hostId === this.opts.userId;
|
||||
};
|
||||
|
||||
makeCgHooks = () => ({
|
||||
onUserMove: this.onUserMove,
|
||||
onUserNewPiece: this.onUserNewPiece,
|
||||
|
@ -642,12 +646,17 @@ export default class RoundController {
|
|||
this.setTitle();
|
||||
|
||||
window.addEventListener('beforeunload', e => {
|
||||
if (li.hasToReload || this.data.blind || !game.playable(this.data) || !this.data.clock || this.data.opponent.ai) return;
|
||||
document.body.classList.remove('fpmenu');
|
||||
this.socket.send('bye2');
|
||||
const msg = 'There is a game in progress!';
|
||||
(e || window.event).returnValue = msg;
|
||||
return msg;
|
||||
if (li.hasToReload ||
|
||||
this.data.blind ||
|
||||
!game.playable(this.data) ||
|
||||
!this.data.clock ||
|
||||
this.data.opponent.ai ||
|
||||
this.isSimulHost()) return;
|
||||
document.body.classList.remove('fpmenu');
|
||||
this.socket.send('bye2');
|
||||
const msg = 'There is a game in progress!';
|
||||
(e || window.event).returnValue = msg;
|
||||
return msg;
|
||||
});
|
||||
|
||||
window.Mousetrap.bind(['esc'], () => this.chessground.cancelMove());
|
||||
|
|
Loading…
Reference in a new issue