Merge pull request #438 from SableClient/fix/thread-drawer-server-side-backfill
fix(threads): skip classic-sync backfill when server-side thread support is active
This commit is contained in:
2 files changed
+21
-4
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix thread drawer flooding console with "Ignoring event" warnings when server-side thread support is enabled.
|
||||
@@ -428,13 +428,25 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
|
||||
|
||||
const rootEvent = room.findEventById(threadRootId);
|
||||
|
||||
// When the drawer is opened with classic sync, room.createThread() may have
|
||||
// been called with empty initialEvents so thread.events only has the root.
|
||||
// Backfill events from the main room timeline into the Thread object so the
|
||||
// authoritative source is populated for subsequent renders and receipts.
|
||||
// When the drawer is opened with classic sync (no server-side thread support),
|
||||
// room.createThread() may have been called with empty initialEvents so
|
||||
// thread.events only has the root. Backfill events from the main room
|
||||
// timeline so the authoritative source is populated for subsequent renders.
|
||||
//
|
||||
// IMPORTANT: skip this backfill when server-side thread support is active
|
||||
// (initialEventsFetched starts false). In that case the SDK will call
|
||||
// updateThreadMetadata() → resetLiveTimeline() + paginateEventTimeline()
|
||||
// automatically. Calling thread.addEvents() ourselves first would trigger
|
||||
// that same cascade prematurely and cause a flood of
|
||||
// "EventTimelineSet.addEventToTimeline: Ignoring event=…" warnings because
|
||||
// canContain() fails while the timeline is in the middle of being reset and
|
||||
// repopulated.
|
||||
useEffect(() => {
|
||||
const thread = room.getThread(threadRootId);
|
||||
if (!thread) return;
|
||||
// initialEventsFetched === false ↔ Thread.hasServerSideSupport is set.
|
||||
// The SDK handles initialization itself; our manual backfill must not run.
|
||||
if (!thread.initialEventsFetched) return;
|
||||
const hasRepliesInThread = thread.events.some(
|
||||
(ev) => ev.getId() !== threadRootId && !reactionOrEditEvent(ev)
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user