MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / renderFlatVirtual

Method renderFlatVirtual

src/bases/TaskListView.ts:1514–1580  ·  view source on GitHub ↗
(
		taskNotes: TaskInfo[],
		visibleProperties: string[] | undefined,
		cardOptions: TaskCardOptions
	)

Source from the content-addressed store, hash-verified

1512 }
1513
1514 private async renderFlatVirtual(
1515 taskNotes: TaskInfo[],
1516 visibleProperties: string[] | undefined,
1517 cardOptions: TaskCardOptions
1518 ): Promise<void> {
1519 if (!this.itemsContainer) return;
1520 this.taskGroupKeys.clear(); // No groups in flat mode
1521 this.setSortScopePaths([[null, taskNotes.map((task) => task.path)]]);
1522
1523 if (!this.virtualScroller) {
1524 // Initialize virtual scroller with automatic height calculation
1525 this.resetVirtualScrollerIfCardRenderChanged(
1526 this.buildCardRenderSignature(visibleProperties, cardOptions)
1527 );
1528 this.virtualScroller = new VirtualScroller<TaskListVirtualItem>({
1529 container: this.itemsContainer,
1530 items: taskNotes,
1531 // itemHeight omitted - will be calculated automatically from sample
1532 overscan: 5,
1533 renderItem: (item: TaskListVirtualItem) => {
1534 if ("type" in item) {
1535 throw new Error("Unexpected grouped item in flat renderer");
1536 }
1537 const taskInfo = item;
1538 // Create card using lazy mode
1539 const card = createTaskCard(item, this.plugin, visibleProperties, cardOptions);
1540
1541 // Attach drag handlers for sort_order reordering
1542 this.configureCardForManualReordering(card, taskInfo, null);
1543
1544 // Cache task info for event handlers
1545 this.taskInfoCache.set(taskInfo.path, taskInfo);
1546 this.lastTaskSignatures.set(taskInfo.path, this.buildTaskSignature(taskInfo));
1547
1548 return card;
1549 },
1550 getItemKey: (item) => {
1551 if ("type" in item) {
1552 return `grouped-${item.groupKey}`;
1553 }
1554 return item.path;
1555 },
1556 });
1557
1558 // Force recalculation after DOM settles
1559 window.setTimeout(() => {
1560 this.virtualScroller?.recalculate();
1561 }, 0);
1562 } else {
1563 // Update existing virtual scroller with new items
1564 this.resetVirtualScrollerIfCardRenderChanged(
1565 this.buildCardRenderSignature(visibleProperties, cardOptions)
1566 );
1567 if (!this.virtualScroller) {
1568 await this.renderFlatVirtual(taskNotes, visibleProperties, cardOptions);
1569 return;
1570 }
1571 this.virtualScroller.updateItems(taskNotes);

Callers 1

renderFlatMethod · 0.95

Calls 11

setSortScopePathsMethod · 0.95
buildTaskSignatureMethod · 0.95
createTaskCardFunction · 0.90
recalculateMethod · 0.80
setMethod · 0.65
setTimeoutMethod · 0.65
clearMethod · 0.45
updateItemsMethod · 0.45

Tested by

no test coverage detected