Now that we can receive game messages from several games at once, make sure the Game module only handles the ones for the current game

This commit is contained in:
Tissevert 2020-01-28 18:24:34 +01:00
parent 81216e3f01
commit c5e5a7c958

View file

@ -80,11 +80,13 @@ function previously(states) {
function initMessageHandlers() {
window.addEventListener('focus', catchUp);
Messaging.addEventListener(["Game"], function(o) {
delay(handleGameMessage(o.state));
if(document.hasFocus() && getQueue().length == 1) {
catchUp();
} else {
StatusHandler.set("♪");
if(o.state.public.coordinates.gameID == globalState.game.public.coordinates.gameID) {
delay(handleGameMessage(o.state));
if(document.hasFocus() && getQueue().length == 1) {
catchUp();
} else {
StatusHandler.set("♪");
}
}
});
}