feat: add force disconnect handling and improve user ban notifications

This commit is contained in:
HueByte
2026-02-19 22:09:54 +01:00
parent 7a8b5f02d3
commit 107152298e
3 changed files with 47 additions and 7 deletions
+15 -7
View File
@@ -830,25 +830,33 @@ public sealed class AppOrchestrator : IDisposable
InvokeUI(() =>
{
_mainWindow.AddSystemMessage(channelName, $"{username} was kicked{reasonText}");
if (username.Equals(_currentUsername, StringComparison.OrdinalIgnoreCase))
{
_mainWindow.AddSystemMessage(channelName, "You were kicked from this channel.");
}
});
};
connection.OnUserBanned += (username, reason) =>
{
var reasonText = reason is not null ? $" ({reason})" : "";
InvokeUI(() =>
{
if (username.Equals(_currentUsername, StringComparison.OrdinalIgnoreCase))
// Show ban notification for other users in the channel
if (!username.Equals(_currentUsername, StringComparison.OrdinalIgnoreCase))
{
_mainWindow.ShowError("You have been banned from this server.");
HandleDisconnect();
var channel = _mainWindow.CurrentChannel;
if (!string.IsNullOrEmpty(channel))
_mainWindow.AddSystemMessage(channel, $"{username} was banned{reasonText}");
}
});
};
connection.OnForceDisconnect += reason =>
{
InvokeUI(() =>
{
_mainWindow.ShowError(reason);
HandleDisconnect();
});
};
connection.OnMessageDeleted += (channelName, messageId) =>
{
InvokeUI(() =>