Skip to content

Commit

Permalink
perf: reduce the number of items rendered on the first render
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Nov 18, 2024
1 parent 7b61df0 commit 6704d61
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apps/renderer/src/modules/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ const scrollSeekConfiguration: ScrollSeekConfiguration = {
exit: (velocity) => Math.abs(velocity) < 1000,
}

const INITIAL_ITEM_COUNTS = {
[FeedViewType.Articles]: 10,
[FeedViewType.Pictures]: 20,
[FeedViewType.Videos]: 20,
[FeedViewType.SocialMedia]: 5,
[FeedViewType.Notifications]: 10,
[FeedViewType.Audios]: 10,
}

export type VirtuosoComponentProps = { onlyShowArchivedButton: boolean }
type VirtuosoComponentPropsContext = { context?: VirtuosoComponentProps }

Expand Down Expand Up @@ -139,8 +148,10 @@ function EntryColumnImpl() {

const scrollRef = useRef<HTMLDivElement>(null)
const virtuosoOptions = {
initialItemCount: INITIAL_ITEM_COUNTS[view],
components: {
List: EntryListContent,

Footer: useCallback(
({ context }: VirtuosoComponentPropsContext) => {
if (!isFetchingNextPage) {
Expand Down

0 comments on commit 6704d61

Please sign in to comment.