X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FGame.vue;h=6cb75f47339d9e4872217817fd31c01299706e74;hp=47605c47543b76370a06a9923461aeab449fa176;hb=fd7aea36b8da702df87be3ed055f9a1f59c9f4da;hpb=317b8a5610953b30cfb84382bd13764177ce830b diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 47605c47..6cb75f47 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -106,6 +106,11 @@ export default { } }, 1000); }, + // In case variants array was't loaded when game was retrieved + "st.variants": function(variantArray) { + if (!!this.game.vname && this.game.vname == "") + this.game.vname = variantArray.filter(v => v.id == this.game.vid)[0].name; + }, }, created: function() { if (!!this.$route.params["id"]) @@ -287,7 +292,16 @@ export default { // - from remote peer (one live game I don't play, finished or not) loadGame: function(game) { const afterRetrieval = async (game) => { - const vname = this.st.variants.filter(v => v.id == game.vid)[0].name; + // NOTE: variants array might not be available yet, thus the two next lines + const variantCell = this.st.variants.filter(v => v.id == game.vid); + const vname = (variantCell.length > 0 ? variantCell[0].name : ""); + if (!game.fen) + game.fen = game.fenStart; //game wasn't started + + + // TODO: process rtime, clocks............ game.clocks doesn't exist anymore +console.log(game); + const tc = extractTime(game.timeControl); if (game.clocks[0] < 0) //game unstarted {