6 th {{ st.tr["Variant"] }}
8 th {{ st.tr["Cadence"] }}
10 tr(v-for="c in sortedChallenges" :class="{toyou:c.priority==1,fromyou:c.priority==2}" @click="$emit('click-challenge',c)")
12 td {{ c.from.name || "@nonymous" }}
17 import { store } from "@/store";
19 name: "my-challenge-list",
20 props: ["challenges"],
27 sortedChallenges: function() {
28 // Show in order: challenges I sent, challenges I received, other challenges
29 let minAdded = Number.MAX_SAFE_INTEGER
31 let augmentedChalls = this.challenges.map(c => {
33 if (!!c.to && c.to == this.st.user.name)
35 else if (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id)
37 if (c.added < minAdded)
39 if (c.added > maxAdded)
41 return Object.assign({}, c, {priority: priority});
43 const deltaAdded = maxAdded - minAdded;
44 return augmentedChalls.sort((c1,c2) => {
45 return c2.priority - c1.priority + (c2.added - c1.added) / deltaAdded;
52 <style lang="sass" scoped>
53 // TODO: understand why the style applied to <tr> element doesn't work
57 background-color: #fcd785