From e08a46f0c64d11c6f62561f7861356f14b011ae2 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 25 Jan 2023 17:49:22 -0600 Subject: [PATCH] Add a sanity check to avoid bad references, close #77 --- src/state/models/feed-view.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/state/models/feed-view.ts b/src/state/models/feed-view.ts index a7e3c615..d8eb95ef 100644 --- a/src/state/models/feed-view.ts +++ b/src/state/models/feed-view.ts @@ -609,7 +609,10 @@ function preprocessFeed(feed: FeedViewPost[]): FeedViewPostWithThreadMeta[] { for (const slice of threadSlices) { if (slice.length > 3) { reorg.splice(slice.index - removedCount + 1, slice.length - 3) - reorg[slice.index - removedCount]._isThreadChildElided = true + if (reorg[slice.index - removedCount]) { + // ^ sanity check + reorg[slice.index - removedCount]._isThreadChildElided = true + } removedCount += slice.length - 3 } }