501d493ca4
Default = Participating: thread replies notify only when you've posted in the thread or are @mentioned; per-thread override to All / Mentions-only / Mute via a bell menu in the thread panel header. Modes sync across devices in io.lotus.thread_notifications account data (pruned on write: left rooms, >180d, cap 200/room). Muted threads: no notifications/sounds, chip badge suppressed (+BellMute glyph), and their counts are subtracted from the room's sidebar badge (client-side; clamped ≥0). Also fixes the thread notification path itself: thread replies are now owned by exactly ONE handler (room-level ThreadEvent.NewReply via a new useRoomsListener hook, with per-thread dedupe, panel-aware focus suppression, and per-thread OS tag coalescing) — the existing RoomEvent.Timeline handlers in the notifier and the unread binder are explicitly thread-guarded, eliminating the previously un-gated/double path. Room badges now also refresh live on RoomEvent.UnreadNotifications (surgical per-room PUT; fixes thread-badge lag). Pure decision core shouldNotifyThreadReply (13-case matrix) + prune + unread subtraction: +32 tests (648 total). E2EE caveat documented: mentions-only may under-notify pre-decryption (same class as the existing path). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import { Badge, Box, Chip, Icon, Icons, Text, config } from 'folds';
|
|
import { MatrixEvent, Room } from 'matrix-js-sdk';
|
|
import { useThreadSummary } from '../../../hooks/useThreadSummary';
|
|
import { useSetting } from '../../../state/hooks/settings';
|
|
import { settingsAtom } from '../../../state/settings';
|
|
import { timeDayMonthYear, timeHourMinute, today } from '../../../utils/time';
|
|
import { ThreadNotificationMode } from '../../../utils/threadNotifications';
|
|
|
|
type ThreadSummaryProps = {
|
|
rootEvent: MatrixEvent;
|
|
room: Room;
|
|
onOpen: (threadId: string) => void;
|
|
};
|
|
export function ThreadSummary({ rootEvent, room, onOpen }: ThreadSummaryProps) {
|
|
const { summary, unread, mode } = useThreadSummary(rootEvent, room);
|
|
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
|
|
|
if (!summary || summary.count === 0) return null;
|
|
|
|
const { count, latestTs } = summary;
|
|
const latestStr =
|
|
latestTs !== undefined
|
|
? today(latestTs)
|
|
? timeHourMinute(latestTs, hour24Clock)
|
|
: timeDayMonthYear(latestTs)
|
|
: undefined;
|
|
|
|
return (
|
|
<Box style={{ marginTop: config.space.S200 }}>
|
|
<Chip
|
|
variant="SurfaceVariant"
|
|
radii="300"
|
|
before={<Icon size="50" src={Icons.Thread} />}
|
|
after={
|
|
unread > 0 ? <Badge variant="Success" fill="Solid" radii="Pill" size="200" /> : undefined
|
|
}
|
|
onClick={() => {
|
|
const threadId = rootEvent.getId();
|
|
if (threadId) onOpen(threadId);
|
|
}}
|
|
>
|
|
<Text size="T200">
|
|
{count === 1 ? '1 reply' : `${count} replies`}
|
|
{latestStr ? ` · ${latestStr}` : ''}
|
|
</Text>
|
|
{mode === ThreadNotificationMode.Mute && <Icon size="50" src={Icons.BellMute} />}
|
|
</Chip>
|
|
</Box>
|
|
);
|
|
}
|