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:
@@ -115,7 +115,8 @@ export interface UpdateNotificationPreferencesBody {
|
||||
notificationSoundMeeting?: NotificationSoundId;
|
||||
notifyOrdersEnabled?: boolean;
|
||||
notifyMeetingsEnabled?: boolean;
|
||||
vibrationEnabled?: boolean;
|
||||
vibrationEnabledOrder?: boolean;
|
||||
vibrationEnabledMeeting?: boolean;
|
||||
notificationsMuted?: boolean;
|
||||
/**
|
||||
* @minimum 0
|
||||
@@ -160,7 +161,8 @@ export interface AuthUser {
|
||||
notificationSoundMeeting: NotificationSoundId;
|
||||
notifyOrdersEnabled: boolean;
|
||||
notifyMeetingsEnabled: boolean;
|
||||
vibrationEnabled: boolean;
|
||||
vibrationEnabledOrder: boolean;
|
||||
vibrationEnabledMeeting: boolean;
|
||||
notificationsMuted: boolean;
|
||||
notificationVolume: number;
|
||||
roles: string[];
|
||||
|
||||
@@ -3004,7 +3004,9 @@ components:
|
||||
type: boolean
|
||||
notifyMeetingsEnabled:
|
||||
type: boolean
|
||||
vibrationEnabled:
|
||||
vibrationEnabledOrder:
|
||||
type: boolean
|
||||
vibrationEnabledMeeting:
|
||||
type: boolean
|
||||
notificationsMuted:
|
||||
type: boolean
|
||||
@@ -3055,7 +3057,9 @@ components:
|
||||
type: boolean
|
||||
notifyMeetingsEnabled:
|
||||
type: boolean
|
||||
vibrationEnabled:
|
||||
vibrationEnabledOrder:
|
||||
type: boolean
|
||||
vibrationEnabledMeeting:
|
||||
type: boolean
|
||||
notificationsMuted:
|
||||
type: boolean
|
||||
@@ -3082,7 +3086,8 @@ components:
|
||||
- notificationSoundMeeting
|
||||
- notifyOrdersEnabled
|
||||
- notifyMeetingsEnabled
|
||||
- vibrationEnabled
|
||||
- vibrationEnabledOrder
|
||||
- vibrationEnabledMeeting
|
||||
- notificationsMuted
|
||||
- notificationVolume
|
||||
- roles
|
||||
|
||||
@@ -76,7 +76,8 @@ export const LoginResponse = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
@@ -189,7 +190,8 @@ export const GetMeResponse = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
@@ -251,7 +253,8 @@ export const UpdateLanguageResponse = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
@@ -320,7 +323,8 @@ export const UpdateClockStyleResponse = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
@@ -350,7 +354,8 @@ export const UpdateNotificationPreferencesBody = zod.object({
|
||||
.optional(),
|
||||
notifyOrdersEnabled: zod.boolean().optional(),
|
||||
notifyMeetingsEnabled: zod.boolean().optional(),
|
||||
vibrationEnabled: zod.boolean().optional(),
|
||||
vibrationEnabledOrder: zod.boolean().optional(),
|
||||
vibrationEnabledMeeting: zod.boolean().optional(),
|
||||
notificationsMuted: zod.boolean().optional(),
|
||||
notificationVolume: zod
|
||||
.number()
|
||||
@@ -399,7 +404,8 @@ export const UpdateNotificationPreferencesResponse = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
@@ -466,7 +472,8 @@ export const UpdateClockHour12Response = zod.object({
|
||||
]),
|
||||
notifyOrdersEnabled: zod.boolean(),
|
||||
notifyMeetingsEnabled: zod.boolean(),
|
||||
vibrationEnabled: zod.boolean(),
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
|
||||
@@ -18,7 +18,8 @@ export const usersTable = pgTable("users", {
|
||||
notificationSoundMeeting: varchar("notification_sound_meeting", { length: 30 }).notNull().default("chime"),
|
||||
notifyOrdersEnabled: boolean("notify_orders_enabled").notNull().default(true),
|
||||
notifyMeetingsEnabled: boolean("notify_meetings_enabled").notNull().default(true),
|
||||
vibrationEnabled: boolean("vibration_enabled").notNull().default(true),
|
||||
vibrationEnabledOrder: boolean("vibration_enabled_order").notNull().default(true),
|
||||
vibrationEnabledMeeting: boolean("vibration_enabled_meeting").notNull().default(true),
|
||||
notificationsMuted: boolean("notifications_muted").notNull().default(false),
|
||||
notificationVolume: integer("notification_volume").notNull().default(70),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
|
||||
Reference in New Issue
Block a user