Skip to content

SuspendingEntryList manually maps entries to strip _sortMs on every render #577

@brendanlong

Description

@brendanlong

This is related to #580 and a PR fixing this should target the tanstack-db branch.

Problem

In src/components/entries/SuspendingEntryList.tsx:124-144, the component manually maps SortedEntryListItem[] to a new array of objects that strips _sortMs (and score/implicitScore):

const entries = useMemo(
  () =>
    stableEntries.map((entry) => ({
      id: entry.id,
      feedId: entry.feedId,
      subscriptionId: entry.subscriptionId,
      type: entry.type,
      url: entry.url,
      title: entry.title,
      author: entry.author,
      summary: entry.summary,
      publishedAt: entry.publishedAt,
      fetchedAt: entry.fetchedAt,
      read: entry.read,
      starred: entry.starred,
      feedTitle: entry.feedTitle,
      siteName: entry.siteName,
    })),
  [stableEntries]
);

This creates a new array of new objects on every stableEntries change. It also manually enumerates every field, which means it can silently get out of sync with the EntryListData type if fields are added/removed.

Suggestion

Since TypeScript has structural typing, extra properties on objects are generally fine when passed as props. stableEntries could likely be passed directly as externalEntries without the mapping, since EntryList only accesses the fields it needs.

If stripping the extra properties is intentional (to avoid passing unnecessary data to child components), consider using a type assertion or a simpler spread-and-omit pattern instead of manually listing every field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions