From 6120eeefa55d55ff46b508dbfa8214fc1f21b338 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 Jun 2022 01:20:28 +0200 Subject: Sort active games with your turn first. --- server.js | 3 ++- views/head.pug | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 342e9a1..710879f 100644 --- a/server.js +++ b/server.js @@ -1036,7 +1036,7 @@ function annotate_game(game, user_id) { if (p.user_id === user_id) { your_role = p.role your_count++ - if (p_is_active || (p_is_owner && game.is_ready)) + if ((p_is_active || p_is_owner) && game.is_ready) game.your_turn = true } @@ -1093,6 +1093,7 @@ function sort_your_turn(a, b) { app.get('/games/active', must_be_logged_in, function (req, res) { let games = QUERY_LIST_ACTIVE_GAMES_OF_USER.all({ user_id: req.user.user_id }) annotate_games(games, req.user.user_id) + games.sort(sort_your_turn) res.render('games_active.pug', { user: req.user, who: req.user, games: games }) }) diff --git a/views/head.pug b/views/head.pug index 005a4b2..08f2660 100644 --- a/views/head.pug +++ b/views/head.pug @@ -61,7 +61,7 @@ mixin gamelist(list,hide_title=0) case item.status when 0 - if item.is_yours && item.is_ready + if item.is_ready && item.your_turn a(class="command" href=`/join/${item.game_id}`) Start else a(class="command" href=`/join/${item.game_id}`) Join -- cgit v1.2.3