feat: implement notification sound functionality with user customization options

This commit is contained in:
HueByte
2026-02-19 22:03:16 +01:00
parent b508a5854a
commit 7a8b5f02d3
15 changed files with 236 additions and 35 deletions
+26 -1
View File
@@ -21,6 +21,7 @@ public sealed class AppOrchestrator : IDisposable
private readonly IApplication _app;
private readonly MainWindow _mainWindow;
private readonly CommandHandler _commandHandler;
private readonly NotificationSoundService _notificationSound;
private EchoHubConnection? _connection;
private ApiClient? _apiClient;
@@ -41,6 +42,7 @@ public sealed class AppOrchestrator : IDisposable
_config = config;
_mainWindow = new MainWindow(app);
_commandHandler = new CommandHandler();
_notificationSound = new NotificationSoundService(config.Notifications);
WireMainWindowEvents();
WireCommandHandlerEvents();
@@ -572,7 +574,9 @@ public sealed class AppOrchestrator : IDisposable
var editResult = ProfileEditDialog.Show(_app,
currentProfile?.DisplayName,
currentProfile?.Bio,
currentProfile?.NicknameColor);
currentProfile?.NicknameColor,
_config.Notifications.Enabled,
_config.Notifications.Volume);
if (editResult is null) return;
@@ -633,6 +637,18 @@ public sealed class AppOrchestrator : IDisposable
}
}
if (editResult.NotificationSoundEnabled.HasValue)
{
_config.Notifications.Enabled = editResult.NotificationSoundEnabled.Value;
_notificationSound.SetEnabled(editResult.NotificationSoundEnabled.Value);
}
if (editResult.NotificationVolume.HasValue)
{
_config.Notifications.Volume = editResult.NotificationVolume.Value;
_notificationSound.SetVolume(editResult.NotificationVolume.Value);
}
_config.DefaultPreset = new AccountPreset
{
DisplayName = editResult.DisplayName,
@@ -768,8 +784,17 @@ public sealed class AppOrchestrator : IDisposable
private void WireConnectionEvents(EchoHubConnection connection)
{
connection.OnMessageReceived += message =>
{
InvokeUI(() => _mainWindow.AddMessage(message));
if (!string.IsNullOrEmpty(_currentUsername)
&& !message.SenderUsername.Equals(_currentUsername, StringComparison.OrdinalIgnoreCase)
&& message.Content.Contains($"@{_currentUsername}", StringComparison.OrdinalIgnoreCase))
{
_ = _notificationSound.PlayAsync();
}
};
connection.OnUserJoined += (channelName, username) =>
{
InvokeUI(() => _mainWindow.AddSystemMessage(channelName, $"{username} joined the channel"));