X-Git-Url: https://git.auder.net/images/pieces/Cwda/bt.svg?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=fb3ed63030d33e2b04ce4c0dddc5b34721bc7d8c;hb=bebcc8d45532e67902175f69084a08040f06855f;hp=ac2cb27e2ab8599a76d166d0fb01e3e885f8bcd4;hpb=66d03f23c9ce085877c3f7272db44dc382762b5a;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index ac2cb27e..fb3ed630 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -143,9 +143,24 @@ export default { "GET", {uid: this.st.user.id}, response => { - console.log(response.challenges); - // TODO: post-treatment on challenges ? - Array.prototype.push.apply(this.challenges, response.challenges); + // Gather all senders names, and then retrieve full identity: + // (TODO [perf]: some might be online...) + const uids = response.challenges.map(c => { return c.uid }); + ajax("/users", + "GET", + { ids: uids }, + names => { + this.challenges = this.challenges.concat( + response.challenges.map(c => { + // (just players names in fact) + const from = {name: names[c.uid], id: c.uid}; + const type = this.classifyObject(c); + const vname = this.getVname(c.vid); + return Object.assign({}, c, {type: type, vname: vname, from: from}); + }) + ) + } + ); } ); } @@ -398,6 +413,8 @@ export default { if (!!error) return alert(error); const ctype = this.classifyObject(this.newchallenge); + if (ctype == "corr" && this.st.user.id <= 0) + return alert("Please log in to play correspondance games"); // NOTE: "from" information is not required here let chall = Object.assign({}, this.newchallenge); const finishAddChallenge = (cid,warnDisconnected) => { @@ -441,7 +458,7 @@ export default { ajax( "/challenges", "POST", - chall, + { chall: chall }, response => { finishAddChallenge(response.cid); } ); }