Fix to error condition that breaks the feed

zio/stable
Paul Frazee 2022-12-20 09:02:38 -06:00
parent 0401dfc5d3
commit 71e4b3d756
1 changed files with 2 additions and 1 deletions

View File

@ -607,9 +607,10 @@ function preprocessFeed(feed: FeedItem[]): FeedItemWithThreadMeta[] {
slice.length, slice.length,
) )
const targetDate = new Date(removed[removed.length - 1].indexedAt) const targetDate = new Date(removed[removed.length - 1].indexedAt)
const newIndex = reorg.findIndex( let newIndex = reorg.findIndex(
item => new Date(item.indexedAt) < targetDate, item => new Date(item.indexedAt) < targetDate,
) )
if (newIndex === -1) newIndex = 0
reorg.splice(newIndex, 0, ...removed) reorg.splice(newIndex, 0, ...removed)
slice.index = newIndex slice.index = newIndex
} }