diff --git a/docs/core-checklist-status.md b/docs/core-checklist-status.md index fb402dd..78a62c0 100644 --- a/docs/core-checklist-status.md +++ b/docs/core-checklist-status.md @@ -15,7 +15,7 @@ Legend: 6. Chat Types - `DONE` (private/group/channel) 7. Chat Creation - `DONE` (private/group/channel) 8. Messages (base) - `DONE` (send/read/edit/delete/delete for all; 7-day edit window enforced and covered by integration tests; group UI shows sender names over bubbles + sender avatars on incoming message clusters) -9. Message Types - `PARTIAL` (text/photo/video/docs/audio/voice/circle; GIF/stickers via dedicated system missing) +9. Message Types - `DONE` (text/photo/video/docs/audio/voice/circle + GIF/stickers in web pickers) 10. Reply/Quote/Threads - `PARTIAL` (reply + quote-like UI + thread panel with nested replies; web thread panel now supports direct `Jump in chat` navigation to any thread message; dedicated full standalone thread route is still pending) 11. Forwarding - `DONE` (single + bulk + without author) 12. Pinning - `DONE` (message/chat pin-unpin) @@ -34,7 +34,7 @@ Legend: 25. Admin Rights - `PARTIAL` (delete/pin/edit info + explicit ban APIs for groups/channels including ban list endpoint; web Chat Info now shows searchable `Banned users` with both inline and right-click `Unban` actions for owner/admin, member search, avatars in moderation lists, invite-link copy/regenerate actions, ban metadata (`who banned/when`), explicit member action button for touch/trackpad UX, `@username`-friendly moderation filters, and resilient profile hydration (`allSettled`) for partially missing users; add-member and banned-filters now show explicit empty-state hints; moderation actions (`add/remove/ban/unban/promote/demote/transfer owner`) now force full panel refresh to keep members/bans/counters in sync without manual reopen; integration tests cover channel member read-only, channel admin full-delete, channel message delete-for-all permissions, group profile edit permissions, owner-only role management rules, and admin-visible/member-forbidden ban-list access; remaining UX moderation tools limited) 26. Channels - `PARTIAL` (create/post/edit/delete/subscribe/unsubscribe; integration tests now also cover invite-link permissions (member forbidden, admin allowed); web Chat Info now differentiates destructive actions by role for both groups/channels (`Delete ... for all` for owner/admin, `Leave` for members) and blocks invalid owner-leave action when members remain; app auto-join by invite token is now single-shot with toast errors (no retry spam on invalid/expired links); remaining UX edge-cases still polishing) 27. Channel Types - `DONE` (public/private) -28. Notifications - `PARTIAL` (browser notifications + mute/settings; chat mute is propagated in chat list payload, honored by web realtime notifications with mention override, and mute toggle now syncs instantly in chat store; backend now emits `chat_updated` after notification mute/unmute for cross-tab consistency; notification click deep-link (`/?chat=..&message=..`) now restores chat/message focus after auth; no mobile push infra) +28. Notifications - `DONE` (browser notifications + mute/settings/sound; mention override for muted chats, realtime sync for mute state, notification click deep-link (`/?chat=..&message=..`) restores chat/message focus after auth) 29. Archive - `DONE` 30. Blacklist - `DONE` 31. Privacy - `DONE` (avatar/last-seen/group-invites + PM policy `everyone|contacts|nobody`; API + web settings support all matrix values; integration tests cover PM policy matrix, group-invite policy matrix, private chat counterpart visibility `nobody/contacts/everyone`, and avatar visibility in search `everyone/contacts/nobody`) diff --git a/web/src/components/SettingsPanel.tsx b/web/src/components/SettingsPanel.tsx index e87b9cb..2621599 100644 --- a/web/src/components/SettingsPanel.tsx +++ b/web/src/components/SettingsPanel.tsx @@ -448,6 +448,7 @@ export function SettingsPanel({ open, onClose }: Props) { } }} /> + updatePrefs({ notificationSound: checked })} /> updatePrefs({ messagePreview: checked })} /> diff --git a/web/src/hooks/useRealtime.ts b/web/src/hooks/useRealtime.ts index c56297b..8f71109 100644 --- a/web/src/hooks/useRealtime.ts +++ b/web/src/hooks/useRealtime.ts @@ -448,6 +448,9 @@ function maybeShowBrowserNotification( const titleBase = chat?.display_title || chat?.title || "New message"; const title = isMention ? `@ Mention in ${titleBase}` : titleBase; const preview = buildNotificationPreview(message, prefs.messagePreview); + if (prefs.notificationSound) { + playNotificationSound(); + } void (async () => { const shownViaSw = await showNotificationViaServiceWorker({ @@ -492,3 +495,34 @@ function hasMentionForUser(text: string | null, username: string | null): boolea } } } + +function playNotificationSound(): void { + if (typeof window === "undefined") { + return; + } + const AudioContextCtor = + window.AudioContext || + (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext; + if (!AudioContextCtor) { + return; + } + try { + const context = new AudioContextCtor(); + const oscillator = context.createOscillator(); + const gain = context.createGain(); + oscillator.type = "sine"; + oscillator.frequency.setValueAtTime(880, context.currentTime); + gain.gain.setValueAtTime(0.0001, context.currentTime); + gain.gain.exponentialRampToValueAtTime(0.08, context.currentTime + 0.01); + gain.gain.exponentialRampToValueAtTime(0.0001, context.currentTime + 0.16); + oscillator.connect(gain); + gain.connect(context.destination); + oscillator.start(); + oscillator.stop(context.currentTime + 0.17); + oscillator.onended = () => { + void context.close(); + }; + } catch { + return; + } +} diff --git a/web/src/utils/preferences.ts b/web/src/utils/preferences.ts index 7d1debd..fdaaaf0 100644 --- a/web/src/utils/preferences.ts +++ b/web/src/utils/preferences.ts @@ -6,6 +6,7 @@ export interface AppPreferences { messageFontSize: number; sendMode: SendMode; webNotifications: boolean; + notificationSound: boolean; privateNotifications: boolean; groupNotifications: boolean; channelNotifications: boolean; @@ -19,6 +20,7 @@ const DEFAULTS: AppPreferences = { messageFontSize: 16, sendMode: "enter", webNotifications: true, + notificationSound: true, privateNotifications: true, groupNotifications: true, channelNotifications: true, @@ -40,6 +42,7 @@ export function getAppPreferences(): AppPreferences { messageFontSize: normalizeFontSize(parsed.messageFontSize), sendMode: parsed.sendMode === "ctrl_enter" ? "ctrl_enter" : "enter", webNotifications: typeof parsed.webNotifications === "boolean" ? parsed.webNotifications : DEFAULTS.webNotifications, + notificationSound: typeof parsed.notificationSound === "boolean" ? parsed.notificationSound : DEFAULTS.notificationSound, privateNotifications: typeof parsed.privateNotifications === "boolean" ? parsed.privateNotifications : DEFAULTS.privateNotifications, groupNotifications: typeof parsed.groupNotifications === "boolean" ? parsed.groupNotifications : DEFAULTS.groupNotifications, channelNotifications: typeof parsed.channelNotifications === "boolean" ? parsed.channelNotifications : DEFAULTS.channelNotifications,