Repository: faforever/downlords-faf-client
Issue: Chat filter is no longer applied for people joining

When the chat user list is filtered by a name in the search field, this filter is no longer applied to people joining afterwards.

I say "no longer" because I'm 99% sure I explicitly implemented this case, and that it worked :-)


Changed files:
src/main/java/com/faforever/client/chat/ChannelTabController.java, src/main/java/com/faforever/client/chat/FilterUserController.java

diff --git a/src/main/java/com/faforever/client/chat/ChannelTabController.java b/src/main/java/com/faforever/client/chat/ChannelTabController.java
index 66a22aba..84bb0818 100644
--- a/src/main/java/com/faforever/client/chat/ChannelTabController.java
+++ b/src/main/java/com/faforever/client/chat/ChannelTabController.java
@@ -418,8 +418,17 @@ public class ChannelTabController extends AbstractChatTabController {
     userToChatUserControls.putIfAbsent(username, new HashMap<>(targetPanesForUser.size(), 1));
 
     for (Pane pane : targetPanesForUser) {
-      createChatUserControlForPlayerIfNecessary(pane, player);
+      ChatUserItemController chatUserItemController = createChatUserControlForPlayerIfNecessary(pane, player);
+
+      // Apply filter if exists
+      if (!userSearchTextField.textProperty().get().isEmpty()) {
+        chatUserItemController.setVisible(isUsernameMatch(chatUserItemController));
+      }
+      if (filterUserPopup.isShowing()) {
+        filterUserController.filterUser(chatUserItemController);
+      }
     }
+
   }
 
   private Pane getPaneForSocialStatus(SocialStatus socialStatus) {
diff --git a/src/main/java/com/faforever/client/chat/FilterUserController.java b/src/main/java/com/faforever/client/chat/FilterUserController.java
index 1ce4cbea..e672596a 100644
--- a/src/main/java/com/faforever/client/chat/FilterUserController.java
+++ b/src/main/java/com/faforever/client/chat/FilterUserController.java
@@ -64,14 +64,12 @@ public class FilterUserController {
     for (Map<Pane, ChatUserItemController> chatUserControlMap : userToChatUserControls.values()) {
       for (Map.Entry<Pane, ChatUserItemController> chatUserControlEntry : chatUserControlMap.entrySet()) {
         ChatUserItemController chatUserItemController = chatUserControlEntry.getValue();
-        boolean display;
-        display = filterUser(chatUserItemController);
-        chatUserItemController.setVisible(display);
+        chatUserItemController.setVisible(filterUser(chatUserItemController));
       }
     }
   }
 
-  private boolean filterUser(ChatUserItemController chatUserItemController) {
+  boolean filterUser(ChatUserItemController chatUserItemController) {
     return channelTabController.isUsernameMatch(chatUserItemController)
         && isInClan(chatUserItemController)
         && isBoundedByRating(chatUserItemController)
@@ -95,6 +93,10 @@ public class FilterUserController {
 
   @VisibleForTesting
   boolean isBoundedByRating(ChatUserItemController chatUserItemController) {
+    if (minRatingFilterField.getText().isEmpty() && maxRatingFilterField.getText().isEmpty()) {
+      return true;
+    }
+
     int globalRating = RatingUtil.getGlobalRating(chatUserItemController.getPlayerInfoBean());
     int minRating;
     int maxRating;