Keep each server's session state in core
What a server tab knows beyond its views - the connection lifecycle, title and status, the identity used, the microphone/speaker/away and commander flags, chat sending and the channel lookups - moves from the Swing ServerTab and ServerTabSelfState into core's ServerSession, so another frontend gets the same behaviour without copying it. ServerSession also takes over what the Swing event bridge decided on its own: clearing the model on disconnect, naming the tab after the server, showing senders under their contact names, and the chat's system lines. The bridge now only updates views. SelfState moves along, while its icons stay with the tray. A server switch no longer needs to queue behind the UI thread: the disconnect is reported synchronously, so the session is free again by the time it reconnects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -69,7 +69,7 @@ final class ServerTabPane extends JPanel {
|
||||
updating = true;
|
||||
try {
|
||||
tabbed.removeAll();
|
||||
for (ServerTab tab : tabs) tabbed.addTab(tab.title(), tab.component());
|
||||
for (ServerTab tab : tabs) tabbed.addTab(tab.session().title(), tab.component());
|
||||
if (selected != null) tabbed.setSelectedIndex(tabs.indexOf(selected));
|
||||
} finally {
|
||||
updating = false;
|
||||
@@ -121,8 +121,8 @@ final class ServerTabPane extends JPanel {
|
||||
if (!tabbedMode) return;
|
||||
for (int i = 0; i < tabs.size(); i++) {
|
||||
ServerTab tab = tabs.get(i);
|
||||
tabbed.setTitleAt(i, tab.title());
|
||||
tabbed.setToolTipTextAt(i, tab.status());
|
||||
tabbed.setTitleAt(i, tab.session().title());
|
||||
tabbed.setToolTipTextAt(i, tab.session().status());
|
||||
tabbed.setTabComponentAt(i, buildTabComponent(tab, tab == micTab));
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ final class ServerTabPane extends JPanel {
|
||||
removeAll();
|
||||
tabbed.removeAll();
|
||||
if (wantTabs) {
|
||||
for (ServerTab tab : tabs) tabbed.addTab(tab.title(), tab.component());
|
||||
for (ServerTab tab : tabs) tabbed.addTab(tab.session().title(), tab.component());
|
||||
add(tabbed, BorderLayout.CENTER);
|
||||
} else if (!tabs.isEmpty()) {
|
||||
add(tabs.get(0).component(), BorderLayout.CENTER);
|
||||
@@ -157,9 +157,9 @@ final class ServerTabPane extends JPanel {
|
||||
cell.setOpaque(false);
|
||||
cell.setBorder(new ScaledEmptyBorder(1, 0, 1, 0));
|
||||
|
||||
JLabel label = new JLabel(tab.title(), hasMic ? Icons.micActiveSmall() : null, JLabel.LEADING);
|
||||
JLabel label = new JLabel(tab.session().title(), hasMic ? Icons.micActiveSmall() : null, JLabel.LEADING);
|
||||
label.setFont(Theme.uiFont());
|
||||
label.setToolTipText(hasMic ? "Speaking on this server" : tab.status());
|
||||
label.setToolTipText(hasMic ? "Speaking on this server" : tab.session().status());
|
||||
// A label with a tooltip swallows mouse events, so select the tab explicitly.
|
||||
label.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user