Skip to content

Commit 720ea6b

Browse files
committed
Sort online list
1 parent 2feec01 commit 720ea6b

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/components/Lobby.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</td>
4343
<td id="lobby-users-list" class="lobby-users-list">
4444
<ul id="lobby-users" class="lobby-users">
45-
<li v-for="user in users" id="lobby-user" class="lobby-user">
45+
<li v-for="user in sortedUsers" id="lobby-user" class="lobby-user">
4646
<label>
4747
<input v-model="selected_opponent" v-if="user.userId != currentUser.id" type="radio"
4848
:value="user.userId" name="user_selection" /> {{user.name}}
@@ -305,7 +305,17 @@ export default {
305305
CardshifterServerAPI.sendMessage(new CardshifterServerAPI.messageTypes.ServerQueryMessage("USERS", ""));
306306
CardshifterServerAPI.sendMessage(new CardshifterServerAPI.messageTypes.ServerQueryMessage("MODS", ""));
307307
},
308-
computed: {},
308+
computed: {
309+
sortedUsers() {
310+
let list = this.users.slice();
311+
list.sort((a, b) => {
312+
if (a.name > b.name) return 1;
313+
if (a.name < b.name) return -1;
314+
return 0;
315+
});
316+
return list;
317+
}
318+
},
309319
beforeDestroy() {
310320
CardshifterServerAPI.$off("type:userstatus", this.updateUserList);
311321
CardshifterServerAPI.$off("type:chat", this.addChatMessage);

0 commit comments

Comments
 (0)