mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
feat: add force disconnect handling and improve user ban notifications
This commit is contained in:
@@ -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(() =>
|
||||
|
||||
Reference in New Issue
Block a user