import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso' import type { VaultEntry } from '../../types' import type { SortOption, SortDirection, SortConfig, RelationshipGroup } from '../../utils/noteListHelpers' import { PinnedCard } from './PinnedCard' import { RelationshipGroupSection } from './RelationshipGroupSection' import { EmptyMessage } from './TrashWarningBanner' function resolveEmptyText(isChangesView: boolean, changesError: string | null | undefined, isArchivedView: boolean, isInboxView: boolean, query: string): string { if (isChangesView && changesError) return `Failed to load changes: ${changesError}` if (isChangesView) return 'No pending changes' if (isArchivedView) return 'No archived notes' if (isInboxView) return query ? 'No matching notes' : 'All notes are organized' return query ? 'No matching notes' : 'No notes found' } export function EntityView({ entity, groups, query, collapsedGroups, sortPrefs, onToggleGroup, onSortChange, renderItem, typeEntryMap, onClickNote }: { entity: VaultEntry; groups: RelationshipGroup[]; query: string collapsedGroups: Set; sortPrefs: Record onToggleGroup: (label: string) => void; onSortChange: (label: string, opt: SortOption, dir: SortDirection) => void renderItem: (entry: VaultEntry) => React.ReactNode typeEntryMap: Record; onClickNote: (entry: VaultEntry, e: React.MouseEvent) => void }) { return (
{groups.length === 0 ? : groups.map((group) => ( onToggleGroup(group.label)} handleSortChange={onSortChange} renderItem={renderItem} /> )) }
) } export function ListView({ isArchivedView, isChangesView, isInboxView, changesError, searched, query, renderItem, virtuosoRef }: { isArchivedView?: boolean; isChangesView?: boolean; isInboxView?: boolean; changesError?: string | null searched: VaultEntry[]; query: string renderItem: (entry: VaultEntry) => React.ReactNode virtuosoRef?: React.RefObject }) { const emptyText = resolveEmptyText(!!isChangesView, changesError ?? null, !!isArchivedView, !!isInboxView, query) if (searched.length === 0) { return (
) } return ( renderItem(entry)} /> ) }