From 70df5e43bb7aa1c67a54a2db9970b6d5cd8c24fe Mon Sep 17 00:00:00 2001 From: MarcSpector Date: Wed, 19 Jun 2024 20:38:37 +0300 Subject: [PATCH] use `isCloseable` condition for remember chat tab --- .../java/com/faforever/client/chat/ChatController.java | 10 +++++----- .../java/com/faforever/client/chat/ChatNavigation.java | 4 ---- src/main/resources/theme/chat/chat.fxml | 2 +- .../com/faforever/client/chat/ChatControllerTest.java | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/faforever/client/chat/ChatController.java b/src/main/java/com/faforever/client/chat/ChatController.java index b2646bdbe2..9976f52a80 100644 --- a/src/main/java/com/faforever/client/chat/ChatController.java +++ b/src/main/java/com/faforever/client/chat/ChatController.java @@ -26,8 +26,6 @@ @RequiredArgsConstructor public class ChatController extends NodeController { - public static String ADD_CHANNEL_TAB_ID = "_add_channel_tab_"; - private final ChatService chatService; private final UiService uiService; private final FxApplicationThreadExecutor fxApplicationThreadExecutor; @@ -44,7 +42,6 @@ public class ChatController extends NodeController { public AnchorPane chatRoot; public TabPane tabPane; - public Tab addChannelTab; public Pane connectingProgressPane; public VBox noOpenTabsContainer; public TextField channelNameTextField; @@ -55,14 +52,17 @@ public class ChatController extends NodeController { @Override protected void onInitialize() { super.onInitialize(); - addChannelTab.setId(ADD_CHANNEL_TAB_ID); openedTabs = tabPane.getTabs(); chatService.addChannelsListener(new WeakMapChangeListener<>(channelChangeListener)); chatService.getChannels().forEach(this::onChannelJoined); chatService.connectionStateProperty().when(showing).subscribe(this::onConnectionStateChange); - tabPane.getSelectionModel().selectedItemProperty().subscribe(tab -> chatNavigation.setLastOpenedTabId(tab.getId())); + tabPane.getSelectionModel().selectedItemProperty().subscribe(tab -> { + if (tab.isClosable()) { + chatNavigation.setLastOpenedTabId(tab.getId()); + } + }); } private void onChannelLeft(ChatChannel chatChannel) { diff --git a/src/main/java/com/faforever/client/chat/ChatNavigation.java b/src/main/java/com/faforever/client/chat/ChatNavigation.java index 7943ee8aa2..b951484793 100644 --- a/src/main/java/com/faforever/client/chat/ChatNavigation.java +++ b/src/main/java/com/faforever/client/chat/ChatNavigation.java @@ -26,10 +26,6 @@ public String getLastOpenedTabId() { } public void setLastOpenedTabId(String tabId) { - if (ChatController.ADD_CHANNEL_TAB_ID.equals(tabId)) { - return; - } - currentTabs.forEach(tab -> tab.setSelected(tab.getId().equals(tabId))); } diff --git a/src/main/resources/theme/chat/chat.fxml b/src/main/resources/theme/chat/chat.fxml index 8f5304e22f..f73513ae87 100644 --- a/src/main/resources/theme/chat/chat.fxml +++ b/src/main/resources/theme/chat/chat.fxml @@ -14,7 +14,7 @@ - +