6 th {{ st.tr["Variant"] }}
8 th {{ st.tr["Cadence"] }}
11 v-for="c in sortedChallenges"
12 :class="{toyou:c.priority==1,fromyou:c.priority==2}"
13 @click="$emit('click-challenge',c)"
21 import { store } from "@/store";
23 name: "my-challenge-list",
24 props: ["challenges"],
31 sortedChallenges: function() {
32 // Show in order: challenges I sent, challenges I received, other challenges
33 let minAdded = Number.MAX_SAFE_INTEGER;
35 let augmentedChalls = this.challenges.map(c => {
37 if (!!c.to && c.to == this.st.user.name) priority = 1;
38 else if (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id)
40 if (c.added < minAdded) minAdded = c.added;
41 if (c.added > maxAdded) maxAdded = c.added;
42 return Object.assign({}, c, { priority: priority });
44 const deltaAdded = maxAdded - minAdded;
45 return augmentedChalls.sort((c1, c2) => {
46 return c2.priority - c1.priority + (c2.added - c1.added) / deltaAdded;
51 withWho: function(c) {
52 if (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id)
53 return c.to || this.st.tr["Any player"];
54 return c.from.name || "@nonymous";
60 <style lang="sass" scoped>
61 // NOTE: the style applied to <tr> element doesn't work
65 background-color: #fcd785