diff --git a/packages/app/src/pages/session/message-timeline.tsx b/packages/app/src/pages/session/message-timeline.tsx index 930516296a..60a161200d 100644 --- a/packages/app/src/pages/session/message-timeline.tsx +++ b/packages/app/src/pages/session/message-timeline.tsx @@ -427,8 +427,7 @@ export function MessageTimeline(props: { if (rows.length === 0) return rows return reuseTimelineRows(previous, [...rows, new TimelineRow.BottomSpacer()]) }) - const timelineRowByKey = createMemo(() => new Map(timelineRows().map((row) => [TimelineRow.key(row), row] as const))) - const timelineRowKeys = createMemo(() => [...timelineRowByKey().keys()], [] as string[], { equals: sameKeys }) + const timelineRowKeys = createMemo(() => timelineRows().map(TimelineRow.key), [] as string[], { equals: sameKeys }) const virtualCache = createMemo(() => readTimelineCache(sessionKey(), timelineRowKeys())) const messageRowIndex = createMemo(() => { const result = new Map() @@ -1227,10 +1226,8 @@ export function MessageTimeline(props: { } } - function TimelineRowView(props: { rowKey: string }) { - const row = () => timelineRowByKey().get(props.rowKey)! - - return renderTimelineRow(row) + function TimelineRowView(props: { row: TimelineRow.TimelineRow }) { + return renderTimelineRow(() => props.row) } return ( @@ -1565,7 +1562,7 @@ export function MessageTimeline(props: { {(root) => ( - {(key) => } + {(row) => } )} diff --git a/patches/virtua@0.49.1.patch b/patches/virtua@0.49.1.patch index 1d8833cd7b..b51f9a7308 100644 --- a/patches/virtua@0.49.1.patch +++ b/patches/virtua@0.49.1.patch @@ -46,6 +46,31 @@ index 029201a2c8..e3c4c0ca3a 100644 scrollToIndex: scroller.$scrollToIndex, scrollTo: scroller.$scrollTo, scrollBy: scroller.$scrollBy, +@@ -1423,5 +1440,7 @@ const Virtualizer = (props) => { + } + sort([...mounted]).forEach((index) => { ++ if (index < 0 || index >= count) ++ return; + items.push(props.data[index]); + indexes.push(index); + }); +@@ -1430,5 +1449,7 @@ const Virtualizer = (props) => { + else { + for (let [i, j] = range(); i <= j; i++) { ++ if (i < 0 || i >= count) ++ continue; + items.push(props.data[i]); + indexes.push(i); + } +@@ -1579,6 +1600,8 @@ const VList = (props) => { + }); + const items = []; + for (let [i, j] = range(); i <= j; i++) { ++ if (i < 0 || i >= count) ++ continue; + items.push(props.data[i]); + } + return items; diff --git a/lib/solid/Virtualizer.d.ts b/lib/solid/Virtualizer.d.ts index 144dd7fba8..819aab92c5 100644 --- a/lib/solid/Virtualizer.d.ts