mirror of
https://github.com/Stone-Red-Code/Decho.git
synced 2026-09-04 00:46:11 +02:00
Add new channels to UI when created and update connecting status logic
This commit is contained in:
@@ -778,7 +778,22 @@ public sealed class ConnectionService : IDisposable
|
|||||||
{
|
{
|
||||||
ChannelModel? existing = entry.Server.Channels.FirstOrDefault(c =>
|
ChannelModel? existing = entry.Server.Channels.FirstOrDefault(c =>
|
||||||
string.Equals(c.Name, channel.Name, StringComparison.OrdinalIgnoreCase));
|
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 =>
|
conn.ForceDisconnected += reason =>
|
||||||
@@ -796,7 +811,7 @@ public sealed class ConnectionService : IDisposable
|
|||||||
conn.ConnectionStatusChanged += status =>
|
conn.ConnectionStatusChanged += status =>
|
||||||
{
|
{
|
||||||
entry.Server.IsConnected = status == "Connected";
|
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);
|
ServerStateChanged?.Invoke(entry.Server);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -625,6 +625,18 @@ public sealed class MainWindowViewModel : ViewModelBase
|
|||||||
StatusText = $"Error: {error}";
|
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)
|
private async Task RefreshOnlineUsersAsync(string serverUrl, string channelName)
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public sealed class ServerViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
_ = this.RaiseAndSetIfChanged(ref _isConnecting, value);
|
_ = this.RaiseAndSetIfChanged(ref _isConnecting, value);
|
||||||
this.RaisePropertyChanged(nameof(ConnectionStatusText));
|
this.RaisePropertyChanged(nameof(ConnectionStatusText));
|
||||||
|
this.RaisePropertyChanged(nameof(ConnectionStatusColor));
|
||||||
this.RaisePropertyChanged(nameof(ShowConnectionControls));
|
this.RaisePropertyChanged(nameof(ShowConnectionControls));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<TextBlock FontWeight="Bold"
|
<TextBlock FontWeight="Bold"
|
||||||
FontSize="13"
|
FontSize="13"
|
||||||
Margin="8 6"
|
Margin="8 6"
|
||||||
Text="{Binding OnlineUserCount, StringFormat='Online — {0}'}" />
|
Text="{Binding OnlineUserCount, StringFormat='Users - {0}'}" />
|
||||||
<ItemsControl ItemsSource="{Binding OnlineUsers}">
|
<ItemsControl ItemsSource="{Binding OnlineUsers}">
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate x:DataType="vm:UserViewModel">
|
<DataTemplate x:DataType="vm:UserViewModel">
|
||||||
|
|||||||
Reference in New Issue
Block a user