Skip to content

Commit

Permalink
Merge pull request #6006 from jwarwick/filter
Browse files Browse the repository at this point in the history
Added game count in game lobby, plus indication of filtering
  • Loading branch information
jwarwick authored Aug 2, 2021
2 parents 9200f50 + 9379aa0 commit a58cf9f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/cljs/nr/gamelobby.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,20 @@

(defn game-list [user {:keys [room games gameid password-game editing]}]
(let [roomgames (r/track (fn [] (filter #(= (:room %) room) @games)))
filtered-games (r/track #(filter-blocked-games @user @roomgames (:visible-formats @app-state)))]
[:div.game-list
(if (empty? @filtered-games)
[:h4 (tr [:lobby.no-games "No games"])]
(doall
(for [game @filtered-games]
^{:key (:gameid game)}
[game-row (assoc game :current-game @gameid :password-game password-game :editing editing)])))]))
filtered-games (r/track #(filter-blocked-games @user @roomgames (:visible-formats @app-state)))
is-filtered? (not= (count slug->format) (count (:visible-formats @app-state)))
n (count @filtered-games)
game-count-str (tr [:lobby.game-count] n)]
[:<>
[:div.game-count
[:h4 (str game-count-str (when is-filtered? (str " " (tr [:lobby.filtered "(filtered)"]))))]]
[:div.game-list
(if (empty? @filtered-games)
[:h4 (tr [:lobby.no-games "No games"])]
(doall
(for [game @filtered-games]
^{:key (:gameid game)}
[game-row (assoc game :current-game @gameid :password-game password-game :editing editing)])))]]))

(defn format-visible? [slug] (contains? (:visible-formats @app-state) slug))

Expand Down
4 changes: 3 additions & 1 deletion src/cljs/nr/translations.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@
:not-allowed "Not allowed"
:aborted "Connection aborted"
:lobby.api-access "Allow API access to game information"
:lobby.api-requires-key "(Requires an API Key in Settings)"}
:lobby.api-requires-key "(Requires an API Key in Settings)"
:game-count (fn [[cnt]] (str cnt (if (= 1 cnt) " Game" " Games")))
:filtered "(filtered)"}
:settings
{:invalid-password "Invalid login or password"
:invalid-email "No account with that email address exists"
Expand Down
3 changes: 3 additions & 0 deletions src/css/lobby.styl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
&.current
color: gold-base

.game-count
padding: 0 15px

.game-list
padding: 0 15px
overflow: auto
Expand Down

0 comments on commit a58cf9f

Please sign in to comment.