Task #389: Notification sounds + vibration with per-user customization
DB - Added user pref columns; vibration is per-channel (vibrationEnabledOrder + vibrationEnabledMeeting). Defaults: ding/chime sounds, vibration on, mute off. Volume uses the device system level — no persisted volume field. 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 + 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). Skipped when the tab is currently visible — sound only fires when backgrounded. - 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:
@@ -118,11 +118,6 @@ export interface UpdateNotificationPreferencesBody {
|
||||
vibrationEnabledOrder?: boolean;
|
||||
vibrationEnabledMeeting?: boolean;
|
||||
notificationsMuted?: boolean;
|
||||
/**
|
||||
* @minimum 0
|
||||
* @maximum 100
|
||||
*/
|
||||
notificationVolume?: number;
|
||||
}
|
||||
|
||||
export interface UpdateClockHour12Body {
|
||||
@@ -164,7 +159,6 @@ export interface AuthUser {
|
||||
vibrationEnabledOrder: boolean;
|
||||
vibrationEnabledMeeting: boolean;
|
||||
notificationsMuted: boolean;
|
||||
notificationVolume: number;
|
||||
roles: string[];
|
||||
groups: GroupSummary[];
|
||||
createdAt: string;
|
||||
|
||||
@@ -3010,10 +3010,6 @@ components:
|
||||
type: boolean
|
||||
notificationsMuted:
|
||||
type: boolean
|
||||
notificationVolume:
|
||||
type: integer
|
||||
minimum: 0
|
||||
maximum: 100
|
||||
|
||||
UpdateClockHour12Body:
|
||||
type: object
|
||||
@@ -3063,8 +3059,6 @@ components:
|
||||
type: boolean
|
||||
notificationsMuted:
|
||||
type: boolean
|
||||
notificationVolume:
|
||||
type: integer
|
||||
roles:
|
||||
type: array
|
||||
items:
|
||||
@@ -3089,7 +3083,6 @@ components:
|
||||
- vibrationEnabledOrder
|
||||
- vibrationEnabledMeeting
|
||||
- notificationsMuted
|
||||
- notificationVolume
|
||||
- roles
|
||||
- groups
|
||||
- createdAt
|
||||
|
||||
@@ -79,7 +79,6 @@ export const LoginResponse = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
@@ -193,7 +192,6 @@ export const GetMeResponse = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
@@ -256,7 +254,6 @@ export const UpdateLanguageResponse = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
@@ -326,7 +323,6 @@ export const UpdateClockStyleResponse = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
@@ -342,9 +338,6 @@ export const UpdateClockStyleResponse = zod.object({
|
||||
/**
|
||||
* @summary Update notification sound, vibration & mute preferences
|
||||
*/
|
||||
export const updateNotificationPreferencesBodyNotificationVolumeMin = 0;
|
||||
export const updateNotificationPreferencesBodyNotificationVolumeMax = 100;
|
||||
|
||||
export const UpdateNotificationPreferencesBody = zod.object({
|
||||
notificationSoundOrder: zod
|
||||
.enum(["ding", "chime", "bell", "knock", "pop", "alert", "beep", "soft"])
|
||||
@@ -357,11 +350,6 @@ export const UpdateNotificationPreferencesBody = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean().optional(),
|
||||
vibrationEnabledMeeting: zod.boolean().optional(),
|
||||
notificationsMuted: zod.boolean().optional(),
|
||||
notificationVolume: zod
|
||||
.number()
|
||||
.min(updateNotificationPreferencesBodyNotificationVolumeMin)
|
||||
.max(updateNotificationPreferencesBodyNotificationVolumeMax)
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const UpdateNotificationPreferencesResponse = zod.object({
|
||||
@@ -407,7 +395,6 @@ export const UpdateNotificationPreferencesResponse = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
@@ -475,7 +462,6 @@ export const UpdateClockHour12Response = zod.object({
|
||||
vibrationEnabledOrder: zod.boolean(),
|
||||
vibrationEnabledMeeting: zod.boolean(),
|
||||
notificationsMuted: zod.boolean(),
|
||||
notificationVolume: zod.number(),
|
||||
roles: zod.array(zod.string()),
|
||||
groups: zod.array(
|
||||
zod.object({
|
||||
|
||||
@@ -21,7 +21,6 @@ export const usersTable = pgTable("users", {
|
||||
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(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date()),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user