feat: add notification sound volume slider (#2391)
* feat: add notification sound volume slider Custom audio files vary widely in loudness; the new 0-100% slider in Settings → Notifications lets the user lower an over-amplified sound without re-encoding the file. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * fix: harden notification sound volume setting --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
Neil
parent
e49bb2a175
commit
cbf2a52e5d
@@ -1233,7 +1233,7 @@ export type PreloadApi = {
|
||||
openSystemSettings: () => Promise<void>
|
||||
getPermissionStatus: () => Promise<NotificationPermissionStatusResult>
|
||||
requestPermission: () => Promise<NotificationPermissionStatusResult>
|
||||
playSound: (options?: { force?: boolean }) => Promise<NotificationSoundResult>
|
||||
playSound: (options?: { force?: boolean; volume?: number }) => Promise<NotificationSoundResult>
|
||||
}
|
||||
onboarding: {
|
||||
get: () => Promise<OnboardingState>
|
||||
|
||||
@@ -1315,7 +1315,10 @@ const api = {
|
||||
ipcRenderer.invoke('notifications:getPermissionStatus'),
|
||||
requestPermission: (): Promise<NotificationPermissionStatusResult> =>
|
||||
ipcRenderer.invoke('notifications:requestPermission'),
|
||||
playSound: async (options?: { force?: boolean }): Promise<NotificationSoundResult> => {
|
||||
playSound: async (options?: {
|
||||
force?: boolean
|
||||
volume?: number
|
||||
}): Promise<NotificationSoundResult> => {
|
||||
try {
|
||||
// Why: drop replays while the sound is still ringing. The "test"
|
||||
// button bypasses with force so the user always hears a confirmation.
|
||||
@@ -1356,6 +1359,9 @@ const api = {
|
||||
// the sound from the start instead of stacking overlapping copies.
|
||||
// Matches GNOME canberra and VS Code AccessibilitySignalService.
|
||||
audio.currentTime = 0
|
||||
if (typeof options?.volume === 'number' && Number.isFinite(options.volume)) {
|
||||
audio.volume = Math.min(1, Math.max(0, options.volume / 100))
|
||||
}
|
||||
isNotificationSoundPlaying = true
|
||||
const release = (): void => {
|
||||
isNotificationSoundPlaying = false
|
||||
|
||||
Reference in New Issue
Block a user