diff --git a/docs/core-checklist-status.md b/docs/core-checklist-status.md index 8d03abd..364ae8e 100644 --- a/docs/core-checklist-status.md +++ b/docs/core-checklist-status.md @@ -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; no mobile push infra) +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) 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/app/App.tsx b/web/src/app/App.tsx index fcac863..cbd09d1 100644 --- a/web/src/app/App.tsx +++ b/web/src/app/App.tsx @@ -11,6 +11,7 @@ import { applyAppearancePreferences, getAppPreferences } from "../utils/preferen const PENDING_INVITE_TOKEN_KEY = "bm_pending_invite_token"; const AUTH_NOTICE_KEY = "bm_auth_notice"; +const PENDING_NOTIFICATION_NAV_KEY = "bm_pending_notification_nav"; export function App() { const accessToken = useAuthStore((s) => s.accessToken); @@ -20,6 +21,7 @@ export function App() { const logout = useAuthStore((s) => s.logout); const loadChats = useChatStore((s) => s.loadChats); const setActiveChatId = useChatStore((s) => s.setActiveChatId); + const setFocusedMessage = useChatStore((s) => s.setFocusedMessage); const showToast = useUiStore((s) => s.showToast); const [joiningInvite, setJoiningInvite] = useState(false); @@ -67,6 +69,15 @@ export function App() { window.history.replaceState(null, "", "/"); }, []); + useEffect(() => { + const nav = extractNotificationNavigationFromLocation(); + if (!nav) { + return; + } + window.localStorage.setItem(PENDING_NOTIFICATION_NAV_KEY, JSON.stringify(nav)); + window.history.replaceState(null, "", "/"); + }, []); + useEffect(() => { if (!accessToken || !me || joiningInvite) { return; @@ -91,6 +102,45 @@ export function App() { })(); }, [accessToken, me, joiningInvite, loadChats, setActiveChatId, showToast]); + useEffect(() => { + if (!accessToken || !me || joiningInvite) { + return; + } + const raw = window.localStorage.getItem(PENDING_NOTIFICATION_NAV_KEY); + if (!raw) { + return; + } + let parsed: { chatId?: unknown; messageId?: unknown } | null = null; + try { + parsed = JSON.parse(raw) as { chatId?: unknown; messageId?: unknown }; + } catch { + window.localStorage.removeItem(PENDING_NOTIFICATION_NAV_KEY); + return; + } + const chatId = typeof parsed?.chatId === "number" && Number.isFinite(parsed.chatId) ? parsed.chatId : null; + const messageId = typeof parsed?.messageId === "number" && Number.isFinite(parsed.messageId) ? parsed.messageId : null; + if (!chatId) { + window.localStorage.removeItem(PENDING_NOTIFICATION_NAV_KEY); + return; + } + void (async () => { + try { + await loadChats(); + const hasChat = useChatStore.getState().chats.some((chat) => chat.id === chatId); + if (!hasChat) { + showToast("Chat from notification is unavailable"); + return; + } + setActiveChatId(chatId); + if (messageId) { + setFocusedMessage(chatId, messageId); + } + } finally { + window.localStorage.removeItem(PENDING_NOTIFICATION_NAV_KEY); + } + })(); + }, [accessToken, joiningInvite, loadChats, me, setActiveChatId, setFocusedMessage, showToast]); + if (!accessToken || !me) { return ; } @@ -126,6 +176,30 @@ function extractEmailVerificationTokenFromLocation(): string | null { return url.searchParams.get("token")?.trim() || null; } +function extractNotificationNavigationFromLocation(): { chatId: number; messageId?: number } | null { + if (typeof window === "undefined") { + return null; + } + const url = new URL(window.location.href); + const chatRaw = url.searchParams.get("chat"); + if (!chatRaw) { + return null; + } + const chatId = Number(chatRaw); + if (!Number.isFinite(chatId) || chatId <= 0) { + return null; + } + const messageRaw = url.searchParams.get("message"); + if (!messageRaw) { + return { chatId }; + } + const messageId = Number(messageRaw); + if (!Number.isFinite(messageId) || messageId <= 0) { + return { chatId }; + } + return { chatId, messageId }; +} + function inviteJoinErrorMessage(error: unknown): string { const status = getHttpStatusCode(error); if (status === 404) {