More reliable Discord connection + show sender name when sending challenge
[vchess.git] / client / src / views / Hall.vue
index 39b9027..fe18941 100644 (file)
@@ -315,19 +315,22 @@ export default {
         // Automatic challenge sending, for tournaments
         this.loadNewchallVariant(
           () => {
-            this.newchallenge = {
-              fen: "",
-              vid:
-                this.st.variants
-                .find(v => v.name == this.$route.query["variant"])
-                .id,
-              to: this.$route.query["challenge"],
-              color: this.$route.query["color"] || '',
-              cadence: this.$route.query["cadence"],
-              // Tournament: no randomness (TODO: for now at least)
-              randomness: 0,
-              memorize: false
-            };
+            this.newchallenge = Object.assign(
+              this.newchallenge,
+              {
+                fen: "",
+                vid:
+                  this.st.variants
+                  .find(v => v.name == this.$route.query["variant"])
+                  .id,
+                to: this.$route.query["challenge"],
+                color: this.$route.query["color"] || '',
+                cadence: this.$route.query["cadence"],
+                // Tournament: no randomness (TODO: for now at least)
+                randomness: 0,
+                memorize: false
+              }
+            );
             window.doClick("modalNewgame");
             //this.issueNewChallenge(); //NOTE: doesn't work yet.
           },
@@ -1131,7 +1134,9 @@ export default {
           this.challenges.splice(challToDelIdx, 1);
         }
         this.send("newchallenge", {
-          data: Object.assign({ from: this.st.user.sid }, chall)
+          data: Object.assign(
+            // Temporarily add sender infos to display challenge on Discord.
+            { from: this.st.user.sid, sender: this.st.user.name }, chall)
         });
         // Add new challenge:
         chall.from = {
@@ -1306,6 +1311,7 @@ export default {
         // on game just after, the main Hall will be notified.
       };
       if (c.type == "live") {
+        // TODO: ask my IP + opp IP, to add to game infos? (potential bans)
         notifyNewgame();
         this.startNewGame(gameInfo);
         // Increment game stats counter in DB