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

Method renderGrouped

src/bases/TaskListView.ts:1738–1816  ·  view source on GitHub ↗
(taskNotes: TaskInfo[])

Source from the content-addressed store, hash-verified

1736 }
1737
1738 private async renderGrouped(taskNotes: TaskInfo[]): Promise<void> {
1739 const visibleProperties = this.getVisibleProperties();
1740 const groups = this.dataAdapter.getGroupedData() as TaskListGroup[];
1741
1742 // Apply search filter
1743 const filteredTasks = this.applySearchFilter(taskNotes);
1744 this.setExpandedRelationshipTaskScope(filteredTasks);
1745 const renderTasks = this.getTopLevelRenderTasks(filteredTasks);
1746 const candidateTasks = this.getTopLevelRenderTasks(taskNotes);
1747 this.setCurrentVisibleTaskPaths(renderTasks);
1748
1749 // Show "no results" if search returned empty but we had tasks
1750 if (this.isSearchWithNoResults(filteredTasks, taskNotes.length)) {
1751 this.clearAllTaskElements();
1752 this.sortScopeTaskPaths.clear();
1753 this.sortScopeCandidateTaskPaths.clear();
1754 if (this.itemsContainer) {
1755 this.renderSearchNoResults(this.itemsContainer);
1756 }
1757 return;
1758 }
1759
1760 const targetDate = createUTCDateFromLocalCalendarDate(new Date());
1761 this.currentTargetDate = targetDate;
1762 const cardOptions = this.getCardOptions(targetDate);
1763 this.applyGroupingSnapshot(this.createGroupedHierarchySnapshot(groups, renderTasks));
1764
1765 // Build flattened list of items using shared method
1766 const pathToProps = this.subGroupPropertyId
1767 ? buildTaskListPathProperties(this.dataAdapter.extractDataItems())
1768 : new Map<string, Record<string, unknown>>();
1769 const items = buildTaskListGroupedRenderItems({
1770 groups,
1771 taskNotes: renderTasks,
1772 subGroupPropertyId: this.subGroupPropertyId,
1773 pathToProps,
1774 collapsedGroups: this.collapsedGroups,
1775 collapsedSubGroups: this.collapsedSubGroups,
1776 convertGroupKeyToString: (key) => this.dataAdapter.convertGroupKeyToString(key),
1777 });
1778 this.setSortScopeCandidatePaths(
1779 buildTaskListGroupedScopePaths(groups, candidateTasks, (key) =>
1780 this.dataAdapter.convertGroupKeyToString(key)
1781 )
1782 );
1783
1784 // Use virtual scrolling if we have many items
1785 const shouldUseVirtualScrolling = items.length >= this.VIRTUAL_SCROLL_THRESHOLD;
1786
1787 // If already using virtual scrolling and still need it, just update items
1788 if (this.useVirtualScrolling && shouldUseVirtualScrolling && this.virtualScroller) {
1789 await this.renderGroupedVirtual(items, visibleProperties, cardOptions);
1790 this.lastFlatPaths = taskNotes.map((task) => task.path);
1791 return;
1792 }
1793
1794 // Otherwise, need to switch rendering mode or initial render
1795 this.itemsContainer!.empty();

Callers 1

renderMethod · 0.95

Tested by

no test coverage detected