X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=0840cd91f50fb0c3d0fea4805a6c85b4c4ebda42;hb=32f6285ee325a14286562a53baefc647201df2af;hp=eb8464ae4f15339c22863cd424aa64ec81eed592;hpb=68e19a449db7a12e0a168e99cd750d985c983ba1;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index eb8464ae..0840cd91 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -120,7 +120,7 @@ main @click="challenge(sid)" ) | {{ st.tr["Challenge"] }} - p.anonymous @nonymous ({{ anonymousCount }}) + p.anonymous @nonymous ({{ anonymousCount() }}) #chat Chat( :newChat="newChat" @@ -266,16 +266,6 @@ export default { this.loadNewchallVariant(); } }, - computed: { - anonymousCount: function() { - let count = 0; - Object.values(this.people).forEach(p => { - // Do not cound people who did not send their identity yet: - count += (!p.name && p.id === 0) ? 1 : 0; - }); - return count; - } - }, created: function() { if (this.st.variants.length > 0 && this.newchallenge.vid > 0) this.loadNewchallVariant(); @@ -436,6 +426,14 @@ export default { ["random-" + pc.randomness]: true }; }, + anonymousCount: function() { + let count = 0; + Object.values(this.people).forEach(p => { + // Do not cound people who did not send their identity yet: + count += (!p.name && p.id === 0) ? 1 : 0; + }); + return count; + }, visibilityChange: function() { // TODO: Use document.hidden? https://webplatform.news/issues/2019-03-27 this.send( @@ -903,10 +901,13 @@ export default { }, loadNewchallVariant: async function(cb) { const vname = this.getVname(this.newchallenge.vid); - const vModule = await import("@/variants/" + vname + ".js"); - this.newchallenge.V = vModule.VariantRules; - this.newchallenge.vname = vname; - if (!!cb) cb(); + await import("@/variants/" + vname + ".js") + .then((vModule) => { + window.V = vModule[vname + "Rules"]; + this.newchallenge.V = window.V; + this.newchallenge.vname = vname; + if (!!cb) cb(); + }); }, trySetNewchallDiag: function() { if (!this.newchallenge.fen) { @@ -1103,22 +1104,24 @@ export default { return; } c.accepted = true; - const vModule = await import("@/variants/" + c.vname + ".js"); - window.V = vModule.VariantRules; - if (!!c.to) { - // c.to == this.st.user.name (connected) - if (!!c.fen) { - const parsedFen = V.ParseFen(c.fen); - c.mycolor = V.GetOppCol(parsedFen.turn); - this.tchallDiag = getDiagram({ - position: parsedFen.position, - orientation: c.mycolor - }); + await import("@/variants/" + c.vname + ".js") + .then((vModule) => { + window.V = vModule[c.vname + "Rules"]; + if (!!c.to) { + // c.to == this.st.user.name (connected) + if (!!c.fen) { + const parsedFen = V.ParseFen(c.fen); + c.mycolor = V.GetOppCol(parsedFen.turn); + this.tchallDiag = getDiagram({ + position: parsedFen.position, + orientation: c.mycolor + }); + } + this.curChallToAccept = c; + document.getElementById("modalAccept").checked = true; } - this.curChallToAccept = c; - document.getElementById("modalAccept").checked = true; - } - else this.finishProcessingChallenge(c); + else this.finishProcessingChallenge(c); + }); } else { // My challenge