mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
feat: implement channel membership management and ensure default channels are public
This commit is contained in:
@@ -712,12 +712,10 @@ public sealed class AppOrchestrator : IDisposable
|
||||
_joinedChannels.Add(channel.Name);
|
||||
var history = await _connection!.JoinChannelAsync(channel.Name);
|
||||
|
||||
// Refresh the channel list and ensure private channels show up
|
||||
var channels = await _apiClient.GetChannelsAsync();
|
||||
InvokeUI(() =>
|
||||
{
|
||||
_mainWindow.SetChannels(channels);
|
||||
_mainWindow.EnsureChannelInList(channel.Name);
|
||||
_mainWindow.SetChannelTopic(channel.Name, channel.Topic);
|
||||
_mainWindow.SwitchToChannel(channel.Name);
|
||||
if (history.Count > 0)
|
||||
_mainWindow.LoadHistory(channel.Name, history);
|
||||
@@ -756,10 +754,9 @@ public sealed class AppOrchestrator : IDisposable
|
||||
await _apiClient!.DeleteChannelAsync(channel);
|
||||
_joinedChannels.Remove(channel);
|
||||
|
||||
var channels = await _apiClient.GetChannelsAsync();
|
||||
InvokeUI(() =>
|
||||
{
|
||||
_mainWindow.SetChannels(channels);
|
||||
_mainWindow.RemoveChannel(channel);
|
||||
_mainWindow.SwitchToChannel(HubConstants.DefaultChannel);
|
||||
_mainWindow.AddSystemMessage(HubConstants.DefaultChannel, $"Channel #{channel} has been deleted.");
|
||||
});
|
||||
@@ -844,6 +841,16 @@ public sealed class AppOrchestrator : IDisposable
|
||||
});
|
||||
};
|
||||
|
||||
connection.OnChannelUpdated += channel =>
|
||||
{
|
||||
InvokeUI(() =>
|
||||
{
|
||||
if (channel.IsPublic)
|
||||
_mainWindow.EnsureChannelInList(channel.Name);
|
||||
_mainWindow.SetChannelTopic(channel.Name, channel.Topic);
|
||||
});
|
||||
};
|
||||
|
||||
connection.OnError += errorMessage =>
|
||||
InvokeUI(() => _mainWindow.ShowError(errorMessage));
|
||||
|
||||
|
||||
@@ -596,6 +596,16 @@ public sealed class MainWindow : Runnable
|
||||
RefreshChannelList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a channel from the left panel list.
|
||||
/// </summary>
|
||||
public void RemoveChannel(string channelName)
|
||||
{
|
||||
_channelNames.Remove(channelName);
|
||||
_channelTopics.Remove(channelName);
|
||||
RefreshChannelList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the topic for a specific channel.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user