-
- console.log("click challenge");
- console.log(c);
-
- // In all cases, the challenge is consumed:
- ArrayFun.remove(this.challenges, ch => ch.id == c.id);
-
- if (c.from.sid == this.st.user.sid //live
- || (this.st.user.id > 0 && c.from.id == this.st.user.id)) //corr
- {
- // It's my challenge: cancel it
- this.sendSomethingTo(c.to, "deletechallenge", {cid:c.id});
- if (c.type == "corr")
- {
- ajax(
- "/challenges",
- "DELETE",
- {id: this.challenges[cIdx].id}
- );
- }
- }
- else //accept (or refuse) a challenge
+ const myChallenge = (c.from.sid == this.st.user.sid //live
+ || (this.st.user.id > 0 && c.from.id == this.st.user.id)); //corr
+ if (!myChallenge)