Task #389: Notification sounds + vibration with per-user customization

DB
- Added 7 user pref columns; vibration is now per-channel
  (vibrationEnabledOrder + vibrationEnabledMeeting). Defaults: ding/chime
  sounds, vibration on, mute off, volume 70.

API
- PATCH /auth/me/notification-preferences (requireAuth, whitelisted partial
  update, integer guard for volume). buildAuthUser exposes all new fields.
- OpenAPI spec updated; orval client + zod regenerated.

Frontend
- Static sound library: 8 short WAV assets under public/sounds/ + manifest
  (notification-sound-manifest.ts) mapping id -> labelKey -> URL.
- HTMLAudio-based player (notification-sounds.ts) with throttle, unlock,
  cache, and AUTOPLAY_BLOCKED_EVENT dispatch when play is denied pre-gesture.
- Settings popover: global mute, volume, slot tabs (orders/meetings) with
  per-channel sound + per-channel vibration + per-channel toggle, sound list
  with one-tap previews. Concurrency-safe optimistic updates (monotonic seq
  counter). RTL-correct toggle knob transforms.
- QuickMuteButton: one-tap topbar mute control (Volume2/VolumeX) with
  confirmation toast.
- useAudioUnlock: unlocks audio on first interaction.
- useAutoplayHint: toasts a localized "click anywhere to enable" hint when
  the player reports a blocked play attempt.
- Socket hook plays the right per-channel sound + vibration on
  notification_created (orders, executive_meeting) when the tab is hidden.
- UpcomingMeetingAlert: plays meeting reminder once per new eligible
  meeting (deduped by meetingId, survives 30s polling refetches).
- AR/EN translations added.

Pre-existing TS errors in executive-meetings.ts (font_settings) and
pre-existing test workflow failures are unrelated.
This commit is contained in:
riyadhafraa
2026-05-05 08:20:54 +00:00
parent 242f63ab26
commit 4af3917026
23 changed files with 292 additions and 189 deletions
+4 -2
View File
@@ -66,7 +66,8 @@ function buildAuthUser(
notificationSoundMeeting: user.notificationSoundMeeting,
notifyOrdersEnabled: user.notifyOrdersEnabled,
notifyMeetingsEnabled: user.notifyMeetingsEnabled,
vibrationEnabled: user.vibrationEnabled,
vibrationEnabledOrder: user.vibrationEnabledOrder,
vibrationEnabledMeeting: user.vibrationEnabledMeeting,
notificationsMuted: user.notificationsMuted,
notificationVolume: user.notificationVolume,
roles,
@@ -445,7 +446,8 @@ router.patch("/auth/me/notification-preferences", requireAuth, async (req, res):
"notificationSoundMeeting",
"notifyOrdersEnabled",
"notifyMeetingsEnabled",
"vibrationEnabled",
"vibrationEnabledOrder",
"vibrationEnabledMeeting",
"notificationsMuted",
"notificationVolume",
] as const) {