Repository: faforever/downlords-faf-client
Issue: 1v1 ladder games pops up in Play tab for a split second.

I was watching what games was hosted, and I saw a game pop up and disappear almost immediately
named "PlayerX" vs "PlayerY". The game was hosted on Ranaoke abyss. I quickly suspected it was a ladder game. And indeed it was checked the replay 1v1 ladder rating of players.

TL;DR
Ladder matches shows up on hosted games tab for split second.

I guess you can filter them out of popping up somehow? Maybe from the featured mod in the data?

Not a huge issue but hey I report what I find lol


Changed files:
src/main/java/com/faforever/client/game/GamesController.java, src/main/java/com/faforever/client/game/GameType.java

diff --git a/src/main/java/com/faforever/client/game/GameType.java b/src/main/java/com/faforever/client/game/GameType.java
index 9de8e0e7..fb467ffa 100644
--- a/src/main/java/com/faforever/client/game/GameType.java
+++ b/src/main/java/com/faforever/client/game/GameType.java
@@ -5,8 +5,10 @@ import java.util.Map;
 
 public enum GameType {
   FAF("faf"),
+  FAF_BETA("fafbeta"),
   BALANCE_TESTING("balancetesting"),
-  LADDER_1V1("ladder1v1");
+  LADDER_1V1("ladder1v1"),
+  COOP("coop");
 
   public static final GameType DEFAULT = FAF;
 
diff --git a/src/main/java/com/faforever/client/game/GamesController.java b/src/main/java/com/faforever/client/game/GamesController.java
index db551323..11fb665d 100644
--- a/src/main/java/com/faforever/client/game/GamesController.java
+++ b/src/main/java/com/faforever/client/game/GamesController.java
@@ -43,6 +43,8 @@ import org.springframework.context.ApplicationContext;
 import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import java.lang.invoke.MethodHandles;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Predicate;
@@ -53,7 +55,16 @@ import static javafx.beans.binding.Bindings.createStringBinding;
 
 public class GamesController {
 
-  private static final Predicate<GameInfoBean> OPEN_GAMES_PREDICATE = gameInfoBean -> gameInfoBean.getStatus() == GameState.OPEN;
+  private static final Collection<String> DISPLAYED_FEATURED_MODS = Arrays.asList(
+      GameType.FAF.getString(),
+      GameType.FAF_BETA.getString(),
+      GameType.BALANCE_TESTING.getString()
+  );
+
+  private static final Predicate<GameInfoBean> OPEN_CUSTOM_GAMES_PREDICATE = gameInfoBean ->
+      gameInfoBean.getStatus() == GameState.OPEN
+          && DISPLAYED_FEATURED_MODS.contains(gameInfoBean.getFeaturedMod());
+
   private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
   @FXML
@@ -127,7 +138,7 @@ public class GamesController {
     ObservableList<GameInfoBean> gameInfoBeans = gameService.getGameInfoBeans();
 
     filteredItems = new FilteredList<>(gameInfoBeans);
-    filteredItems.setPredicate(OPEN_GAMES_PREDICATE);
+    filteredItems.setPredicate(OPEN_CUSTOM_GAMES_PREDICATE);
 
     if (tilesButton.getId().equals(preferencesService.getPreferences().getGamesViewMode())) {
       viewToggleGroup.selectToggle(tilesButton);
@@ -147,9 +158,9 @@ public class GamesController {
     CheckBox checkBox = (CheckBox) actionEvent.getSource();
     boolean selected = checkBox.isSelected();
     if (selected) {
-      filteredItems.setPredicate(OPEN_GAMES_PREDICATE);
+      filteredItems.setPredicate(OPEN_CUSTOM_GAMES_PREDICATE);
     } else {
-      filteredItems.setPredicate(OPEN_GAMES_PREDICATE.and(gameInfoBean -> !gameInfoBean.getPasswordProtected()));
+      filteredItems.setPredicate(OPEN_CUSTOM_GAMES_PREDICATE.and(gameInfoBean -> !gameInfoBean.getPasswordProtected()));
     }
   }