settings styling and sound disabled not working bugfix

This commit is contained in:
choco
2025-10-09 20:21:01 +02:00
parent cd817487e4
commit 85ecea6391
4 changed files with 990 additions and 640 deletions

View File

@@ -75,7 +75,7 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
}
}
if (notification.SoundEffectId.HasValue && _configService.Current.EnableNotificationSounds)
if (notification.SoundEffectId.HasValue)
{
PlayNotificationSound(notification.SoundEffectId.Value);
}
@@ -90,7 +90,7 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
Message = $"{senderName} wants to pair with you.",
Type = NotificationType.PairRequest,
Duration = TimeSpan.FromSeconds(180),
SoundEffectId = NotificationSounds.PairRequest,
SoundEffectId = !_configService.Current.DisablePairRequestSound ? _configService.Current.PairRequestSoundId : null,
Actions = new List<LightlessNotificationAction>
{
new()
@@ -286,39 +286,37 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
private uint? GetSoundEffectId(NotificationType type, uint? overrideSoundId)
{
if (!_configService.Current.EnableNotificationSounds)
return null;
if (overrideSoundId.HasValue)
return overrideSoundId;
if (_configService.Current.UseCustomSounds)
{
return type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(type)
};
}
return NotificationSounds.GetDefaultSound(type);
// Check if this specific notification type is disabled
bool isDisabled = type switch
{
NotificationType.Info => _configService.Current.DisableInfoSound,
NotificationType.Warning => _configService.Current.DisableWarningSound,
NotificationType.Error => _configService.Current.DisableErrorSound,
_ => false
};
if (isDisabled)
return null;
// Return the configured sound for this type
return type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(type)
};
}
private void PlayNotificationSound(uint soundEffectId)
{
try
{
try
{
UIGlobals.PlayChatSoundEffect(soundEffectId);
_logger.LogDebug("Played notification sound effect {SoundId} via ChatGui", soundEffectId);
}
catch (Exception chatEx)
{
_logger.LogWarning(chatEx, "Failed to play sound via ChatGui for ID {SoundId}", soundEffectId);
}
UIGlobals.PlayChatSoundEffect(soundEffectId);
_logger.LogDebug("Played notification sound effect {SoundId} via ChatGui", soundEffectId);
}
catch (Exception ex)
{
@@ -390,27 +388,8 @@ public class NotificationService : DisposableMediatorSubscriberBase, IHostedServ
private void ShowLightlessNotification(NotificationMessage msg)
{
var duration = msg.TimeShownOnScreen ?? TimeSpan.FromSeconds(_configService.Current.DefaultNotificationDurationSeconds);
uint? soundId = null;
if (_configService.Current.EnableNotificationSounds)
{
if (_configService.Current.UseCustomSounds)
{
soundId = msg.Type switch
{
NotificationType.Info => _configService.Current.CustomInfoSoundId,
NotificationType.Warning => _configService.Current.CustomWarningSoundId,
NotificationType.Error => _configService.Current.CustomErrorSoundId,
_ => NotificationSounds.GetDefaultSound(msg.Type)
};
}
else
{
soundId = NotificationSounds.GetDefaultSound(msg.Type);
}
}
ShowNotification(msg.Title ?? "Lightless Sync", msg.Message ?? string.Empty, msg.Type, duration, null, soundId);
// GetSoundEffectId will handle checking if the sound is disabled
ShowNotification(msg.Title ?? "Lightless Sync", msg.Message ?? string.Empty, msg.Type, duration, null, null);
}
private void ShowToast(NotificationMessage msg)