From e1366c0aea0ad886dfd716cac7885739b386e211 Mon Sep 17 00:00:00 2001
From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com>
Date: Fri, 17 Jul 2026 02:45:46 +0200
Subject: [PATCH] Add new channels to UI when created and update connecting
status logic
---
src/Decho/Services/ConnectionService.cs | 19 +++++++++++++++++--
src/Decho/ViewModels/MainWindowViewModel.cs | 12 ++++++++++++
src/Decho/ViewModels/ServerViewModel.cs | 1 +
src/Decho/Views/OnlineUsersView.axaml | 2 +-
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/src/Decho/Services/ConnectionService.cs b/src/Decho/Services/ConnectionService.cs
index 7365bee..6471256 100644
--- a/src/Decho/Services/ConnectionService.cs
+++ b/src/Decho/Services/ConnectionService.cs
@@ -778,7 +778,22 @@ public sealed class ConnectionService : IDisposable
{
ChannelModel? existing = entry.Server.Channels.FirstOrDefault(c =>
string.Equals(c.Name, channel.Name, StringComparison.OrdinalIgnoreCase));
- _ = existing?.Topic = channel.Topic;
+ if (existing is not null)
+ {
+ _ = existing.Topic = channel.Topic;
+ }
+ else
+ {
+ var model = new ChannelModel(
+ channel.Id.ToString(),
+ channel.Name,
+ [],
+ channel.Topic,
+ channel.IsPublic,
+ channel.IsProtected);
+ entry.Server.Channels.Add(model);
+ ChannelAdded?.Invoke(entry.Server.ServerUrl, model);
+ }
};
conn.ForceDisconnected += reason =>
@@ -796,7 +811,7 @@ public sealed class ConnectionService : IDisposable
conn.ConnectionStatusChanged += status =>
{
entry.Server.IsConnected = status == "Connected";
- entry.Server.IsConnecting = status is "Connecting..." or "Authenticating...";
+ entry.Server.IsConnecting = status is "Connecting..." or "Authenticating..." or "Reconnecting...";
ServerStateChanged?.Invoke(entry.Server);
};
}
diff --git a/src/Decho/ViewModels/MainWindowViewModel.cs b/src/Decho/ViewModels/MainWindowViewModel.cs
index dd08431..32a40ae 100644
--- a/src/Decho/ViewModels/MainWindowViewModel.cs
+++ b/src/Decho/ViewModels/MainWindowViewModel.cs
@@ -625,6 +625,18 @@ public sealed class MainWindowViewModel : ViewModelBase
StatusText = $"Error: {error}";
});
};
+
+ ConnectionService.ChannelAdded += (serverUrl, channel) =>
+ {
+ Avalonia.Threading.Dispatcher.UIThread.Post(() =>
+ {
+ ServerViewModel? serverVm = Sidebar.GetServer(serverUrl);
+ if (serverVm is not null && serverVm.Channels.All(c => c.Name != channel.Name))
+ {
+ serverVm.Channels.Add(new ChannelViewModel(channel));
+ }
+ });
+ };
}
private async Task RefreshOnlineUsersAsync(string serverUrl, string channelName)
diff --git a/src/Decho/ViewModels/ServerViewModel.cs b/src/Decho/ViewModels/ServerViewModel.cs
index dc62523..3bc168c 100644
--- a/src/Decho/ViewModels/ServerViewModel.cs
+++ b/src/Decho/ViewModels/ServerViewModel.cs
@@ -100,6 +100,7 @@ public sealed class ServerViewModel : ViewModelBase
{
_ = this.RaiseAndSetIfChanged(ref _isConnecting, value);
this.RaisePropertyChanged(nameof(ConnectionStatusText));
+ this.RaisePropertyChanged(nameof(ConnectionStatusColor));
this.RaisePropertyChanged(nameof(ShowConnectionControls));
}
}
diff --git a/src/Decho/Views/OnlineUsersView.axaml b/src/Decho/Views/OnlineUsersView.axaml
index a00cbdd..1e5aa16 100644
--- a/src/Decho/Views/OnlineUsersView.axaml
+++ b/src/Decho/Views/OnlineUsersView.axaml
@@ -11,7 +11,7 @@
+ Text="{Binding OnlineUserCount, StringFormat='Users - {0}'}" />