Better challenge display: 'with' instead of 'from'
[vchess.git] / client / src / components / ChallengeList.vue
index ed49067..a350c70 100644 (file)
@@ -4,7 +4,7 @@ div
     thead
       tr
         th {{ st.tr["Variant"] }}
-        th {{ st.tr["From"] }}
+        th {{ st.tr["With"] }}
         th {{ st.tr["Cadence"] }}
     tbody
       tr(
@@ -13,7 +13,7 @@ div
         @click="$emit('click-challenge',c)"
       )
         td {{ c.vname }}
-        td {{ c.from.name || "@nonymous" }}
+        td {{ withWho(c) }}
         td {{ c.cadence }}
 </template>
 
@@ -46,6 +46,13 @@ export default {
         return c2.priority - c1.priority + (c2.added - c1.added) / deltaAdded;
       });
     }
+  },
+  methods: {
+    withWho: function(c) {
+      if (c.from.sid == this.st.user.sid || c.from.id == this.st.user.id)
+        return c.to || this.st.tr["Any player"];
+      return c.from.name || "@nonymous";
+    }
   }
 };
 </script>