Fix Berolina en passant
[vchess.git] / client / src / views / Hall.vue
index c943ff5..2b0a148 100644 (file)
@@ -476,7 +476,10 @@ export default {
           // Disconnect means no more tmpIds:
           if (data.code == "disconnect") {
             // Remove the live challenge sent by this player:
-            ArrayFun.remove(this.challenges, c => c.from.sid == data.from);
+            ArrayFun.remove(
+              this.challenges,
+              c => c.type == "live" && c.from.sid == data.from
+            );
           } else {
             // Remove the matching live game if now unreachable
             const gid = data.page.match(/[a-zA-Z0-9]+$/)[0];
@@ -703,7 +706,7 @@ export default {
       }
     },
     newChallenge: async function() {
-      if (this.newchallenge.cadence.match(/^[0-9]+$/))
+      if (!!(this.newchallenge.cadence.match(/^[0-9]+$/)))
         this.newchallenge.cadence += "+0"; //assume minutes, no increment
       const ctype = this.classifyObject(this.newchallenge);
       // TODO: cadence still unchecked so ctype could be wrong...
@@ -809,6 +812,8 @@ export default {
         const oppsid = this.getOppsid(c);
         if (oppsid)
           this.send("refusechallenge", { data: c.id, target: oppsid });
+        if (c.type == "corr")
+          ajax("/challenges", "DELETE", { id: c.id });
       }
       this.send("deletechallenge", { data: c.id });
     },
@@ -847,9 +852,8 @@ export default {
       }
       else {
         // My challenge
-        if (c.type == "corr") {
+        if (c.type == "corr")
           ajax("/challenges", "DELETE", { id: c.id });
-        }
         this.send("deletechallenge", { data: c.id });
       }
       // In all cases, the challenge is consumed: