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

Method renderFlatNormal

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

Source from the content-addressed store, hash-verified

1580 }
1581
1582 private async renderFlatNormal(
1583 taskNotes: TaskInfo[],
1584 visibleProperties: string[] | undefined,
1585 cardOptions: TaskCardOptions
1586 ): Promise<void> {
1587 if (!this.itemsContainer) return;
1588 this.lastVirtualItems = [];
1589 this.taskGroupKeys.clear(); // No groups in flat mode
1590 this.setSortScopePaths([[null, taskNotes.map((task) => task.path)]]);
1591
1592 const seenPaths = new Set<string>();
1593 const orderChanged = !this.arePathArraysEqual(taskNotes, this.lastFlatPaths);
1594 const cardRenderSignature = this.buildCardRenderSignature(visibleProperties, cardOptions);
1595 const cardRenderChanged = cardRenderSignature !== this.lastCardRenderSignature;
1596
1597 if (orderChanged) {
1598 this.itemsContainer.empty();
1599 this.currentTaskElements.clear();
1600 }
1601
1602 for (const taskInfo of taskNotes) {
1603 let cardEl = orderChanged ? null : this.currentTaskElements.get(taskInfo.path) || null;
1604 const signature = this.buildTaskSignature(taskInfo);
1605 const previousSignature = this.lastTaskSignatures.get(taskInfo.path);
1606 const needsUpdate = cardRenderChanged || signature !== previousSignature || !cardEl;
1607
1608 if (!cardEl || needsUpdate) {
1609 const newCard = createTaskCard(
1610 taskInfo,
1611 this.plugin,
1612 visibleProperties,
1613 cardOptions
1614 );
1615 if (cardEl && cardEl.isConnected) {
1616 cardEl.replaceWith(newCard);
1617 }
1618 cardEl = newCard;
1619 }
1620
1621 if (!cardEl.isConnected) {
1622 this.itemsContainer.appendChild(cardEl);
1623 }
1624
1625 if (needsUpdate) {
1626 this.configureCardForManualReordering(cardEl, taskInfo, null);
1627 }
1628
1629 this.currentTaskElements.set(taskInfo.path, cardEl);
1630 this.taskInfoCache.set(taskInfo.path, taskInfo);
1631 this.lastTaskSignatures.set(taskInfo.path, signature);
1632 seenPaths.add(taskInfo.path);
1633 }
1634
1635 if (!orderChanged && seenPaths.size !== this.currentTaskElements.size) {
1636 for (const [path, el] of this.currentTaskElements) {
1637 if (!seenPaths.has(path)) {
1638 el.remove();
1639 this.currentTaskElements.delete(path);

Callers 1

renderFlatMethod · 0.95

Calls 12

setSortScopePathsMethod · 0.95
arePathArraysEqualMethod · 0.95
buildTaskSignatureMethod · 0.95
createTaskCardFunction · 0.90
hasMethod · 0.80
getMethod · 0.65
setMethod · 0.65
deleteMethod · 0.65
clearTimeoutMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected