mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 07:42:24 -08:00
fix(timeline): suppress dividers when the underlying event renders null (#720)
## Summary Closes #701. Stops the timeline from rendering bare day-dividers / new-message dividers when the underlying event was filtered out at render time. The orphan-divider pattern in the issue's screenshot was caused by `useProcessedTimeline` attaching `willRenderDayDivider` to events that `useTimelineEventRenderer` later returned `null` for (e.g. membership / profile-change events when `hideMembershipEvents` or `hideNickAvatarEvents` are on). The render layer would still emit the divider but skip the event under it. ## Why this matters 7w1's diagnosis on the issue: "this is specifically an issue ... when there's rooms with lots of hidden events (e.g. joins/leaves, profile changes) and no other messages, such as announcement channels." The render now matches that — when an event renders to `null`, its divider is skipped too. ## Diff `src/app/features/room/RoomTimeline.tsx`: ```tsx +const showDividers = renderedEvent !== null; -const dividers = ( +const dividers = showDividers ? ( <> {eventData.willRenderDayDivider && ( ... )} {eventData.willRenderNewDivider && ( ... )} </> -); +) : null; ``` 8 lines added, 2 changed. ## Edge case + follow-up If a day's first hook-eligible event is rendered-null but a later event renders correctly, the day-divider is lost for that day. That's strictly better than an orphan divider in the announcement-channel symptom case, and the proper fix (`useProcessedTimeline` propagates the divider forward to the first event whose renderer prediction is non-null) is a larger refactor that can land separately. Happy to follow up with that if you'd prefer not to take the small fix first. ## Verification - `pnpm tsc --noEmit` — `No errors found`. - Manual smoke test path (per issue 7w1 comment): an announcement-style room dominated by profile-change events stops showing bare day-dividers between them. A normal chat with mixed messages and joins still renders dividers correctly because the day's first message-event is the one carrying the divider, and that event renders fine. This contribution was developed with AI assistance (Claude Code).
This commit is contained in:
2 files changed
+15
-8
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Suppress timeline dividers when there's no rendered events between them.
|
||||
@@ -420,7 +420,7 @@ export function RoomTimeline({
|
||||
useEffect(() => {
|
||||
if (!eventId) return;
|
||||
setIsReady(false);
|
||||
timelineSyncRef.current.loadEventTimeline(eventId);
|
||||
void timelineSyncRef.current.loadEventTimeline(eventId);
|
||||
}, [eventId, room.roomId]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -536,7 +536,7 @@ export function RoomTimeline({
|
||||
}
|
||||
timelineSync.setFocusItem({ index: focusRawIndex, scrollTo: false, highlight: true });
|
||||
} else {
|
||||
timelineSync.loadEventTimeline(anchorId);
|
||||
void timelineSync.loadEventTimeline(anchorId);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -680,14 +680,14 @@ export function RoomTimeline({
|
||||
}
|
||||
|
||||
if (offset < 500 && canPaginateBackRef.current && backwardStatusRef.current === 'idle') {
|
||||
timelineSyncRef.current.handleTimelinePagination(true);
|
||||
void timelineSyncRef.current.handleTimelinePagination(true);
|
||||
}
|
||||
if (
|
||||
distanceFromBottom < 500 &&
|
||||
!liveTimelineLinkedRef.current &&
|
||||
forwardStatusRef.current === 'idle'
|
||||
) {
|
||||
timelineSyncRef.current.handleTimelinePagination(false);
|
||||
void timelineSyncRef.current.handleTimelinePagination(false);
|
||||
}
|
||||
},
|
||||
[setAtBottom]
|
||||
@@ -825,7 +825,7 @@ export function RoomTimeline({
|
||||
backwardStatusRef.current === 'idle' &&
|
||||
v.scrollSize <= v.viewportSize
|
||||
) {
|
||||
timelineSyncRef.current.handleTimelinePagination(true);
|
||||
void timelineSyncRef.current.handleTimelinePagination(true);
|
||||
}
|
||||
}, [timelineSync.eventsLength, timelineSync.backwardStatus]);
|
||||
|
||||
@@ -855,7 +855,7 @@ export function RoomTimeline({
|
||||
const hasRealScrollRoom = v.scrollSize > v.viewportSize + 300;
|
||||
|
||||
if (!hasRealScrollRoom || (atTop && noVisibleGrowth)) {
|
||||
timelineSyncRef.current.handleTimelinePagination(true);
|
||||
void timelineSyncRef.current.handleTimelinePagination(true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -955,7 +955,9 @@ export function RoomTimeline({
|
||||
eventData.collapsed
|
||||
);
|
||||
|
||||
const dividers = (
|
||||
const showDividers = renderedEvent !== null;
|
||||
|
||||
const dividers = showDividers ? (
|
||||
<>
|
||||
{eventData.willRenderDayDivider && (
|
||||
<MessageBase space={messageSpacing}>
|
||||
@@ -976,7 +978,7 @@ export function RoomTimeline({
|
||||
</MessageBase>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
) : null;
|
||||
|
||||
if (index === 0) {
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user