Skip to content

Commit

Permalink
clear chat navigation when chat is disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Spector committed Jun 18, 2024
1 parent e418624 commit 2c8b770
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private void onDisconnected() {
connectingProgressPane.setVisible(false);
tabPane.setVisible(false);
openedTabs.removeIf(Tab::isClosable);
chatNavigation.clear();
});
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/faforever/client/chat/ChatNavigation.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@Component
@Lazy
public class ChatNavigation { // TODO: Not a very good name of class
public class ChatNavigation {

private final LinkedHashSet<ChatTab> currentTabs = new LinkedHashSet<>();

Expand All @@ -32,4 +32,8 @@ public void setLastOpenedTabId(String tabId) {

currentTabs.forEach(tab -> tab.setSelected(tab.getId().equals(tabId)));
}

public void clear() {
currentTabs.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static javafx.collections.FXCollections.synchronizedObservableMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -124,6 +125,7 @@ public void testOnDisconnected() {
assertFalse(instance.connectingProgressPane.isVisible());
assertFalse(instance.tabPane.isVisible());
assertEquals(1, openedTabs.size());
assertNull(chatNavigation.getLastOpenedTabId());
}

@Test
Expand Down

0 comments on commit 2c8b770

Please sign in to comment.