Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit f65f422

Browse files
authored
Merge pull request #736 from trey-wallis/dev
8.4.1 Former-commit-id: f924d4b
2 parents 683f2ca + ee3ad5f commit f65f422

File tree

5 files changed

+35
-46
lines changed

5 files changed

+35
-46
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"authorUrl": "https://github.com/trey-wallis",
88
"isDesktopOnly": false,
99
"fundingUrl": "https://www.buymeacoffee.com/treywallis",
10-
"version": "8.4.0"
10+
"version": "8.4.1"
1111
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dataloom",
3-
"version": "8.4.0",
3+
"version": "8.4.1",
44
"description": "Weave together data from diverse sources into a cohesive table view. Inspired by Excel Spreadsheets and Notion.so.",
55
"main": "main.js",
66
"scripts": {

src/react/loom-app/app/filter-by-search.ts

Lines changed: 27 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,46 @@ import { getTimeCellContent } from "src/shared/cell-content/time-content";
1414
import { getDateCellContent } from "src/shared/cell-content/date-cell-content";
1515
import { getCurrencyCellContent } from "src/shared/cell-content/currency-cell-content";
1616

17+
type CellWithReferences = {
18+
cell: BodyCell;
19+
column: Column;
20+
row: BodyRow;
21+
tags: Tag[];
22+
};
23+
1724
export const filterBodyRowsBySearch = (
18-
LoomState: LoomState,
25+
state: LoomState,
1926
filteredBodyRows: BodyRow[],
2027
searchText: string
2128
): BodyRow[] => {
22-
const { columns, bodyCells, bodyRows } = LoomState.model;
23-
const columnMap = new Map<string, Column>();
24-
columns.forEach((column) => columnMap.set(column.id, column));
25-
26-
const rowMap = new Map<string, BodyRow>();
27-
bodyRows.forEach((row) => rowMap.set(row.id, row));
29+
const { columns, bodyCells, bodyRows } = state.model;
2830

29-
const cellToTagMap = new Map<string, Tag[]>();
30-
bodyCells.forEach((cell) => {
31-
const column = columnMap.get(cell.columnId);
31+
const cells: CellWithReferences[] = bodyCells.map((cell) => {
32+
const column = columns.find((c) => c.id === cell.columnId);
3233
if (!column) throw new ColumNotFoundError(cell.columnId);
3334

34-
const cellTags = column.tags.filter((tag) =>
35-
cell.tagIds.includes(tag.id)
36-
);
37-
cellToTagMap.set(cell.id, cellTags);
35+
const row = bodyRows.find((r) => r.id === cell.rowId);
36+
if (!row) throw new RowNotFoundError(cell.rowId);
37+
38+
const tags = column.tags.filter((tag) => cell.tagIds.includes(tag.id));
39+
40+
return { cell, column, row, tags };
3841
});
3942

43+
if (searchText === "") return filteredBodyRows;
44+
4045
return filteredBodyRows.filter((row) => {
41-
const rowCells = bodyCells.filter((cell) => cell.rowId === row.id);
42-
return rowCells.some((cell) => {
43-
const cellTags = cellToTagMap.get(cell.id);
44-
if (!cellTags)
45-
throw new Error(`Tags not found for cell ${cell.id}`);
46-
47-
return doesCellMatch(
48-
cell,
49-
columnMap,
50-
rowMap,
51-
cellTags,
52-
searchText.toLowerCase()
53-
);
46+
const filteredCells = cells.filter((cell) => cell.row.id === row.id);
47+
return filteredCells.some((cell) => {
48+
return doesCellMatch(cell, searchText.toLowerCase());
5449
});
5550
});
5651
};
5752

58-
const doesCellMatch = (
59-
cell: BodyCell,
60-
columnMap: Map<string, Column>,
61-
rowMap: Map<string, BodyRow>,
62-
cellTags: Tag[],
63-
searchText: string
64-
) => {
65-
const column = columnMap.get(cell.columnId);
66-
if (!column) throw new ColumNotFoundError(cell.columnId);
67-
const row = rowMap.get(cell.rowId);
68-
if (!row) throw new RowNotFoundError(cell.rowId);
69-
70-
const { dateTime, markdown } = cell;
71-
const { currencyType, type, dateFormat } = column;
72-
const { lastEditedTime, creationTime } = row;
53+
const doesCellMatch = (cell: CellWithReferences, searchText: string) => {
54+
const { dateTime, markdown } = cell.cell;
55+
const { currencyType, type, dateFormat } = cell.column;
56+
const { lastEditedTime, creationTime } = cell.row;
7357

7458
switch (type) {
7559
case CellType.TEXT:
@@ -92,7 +76,7 @@ const doesCellMatch = (
9276
);
9377
case CellType.TAG:
9478
case CellType.MULTI_TAG:
95-
return matchTags(cellTags, searchText);
79+
return matchTags(cell.tags, searchText);
9680
default:
9781
throw new Error("Unsupported cell type");
9882
}

src/react/loom-app/app/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,16 @@ export default function App() {
165165
} = loomState.model;
166166
const { numFrozenColumns } = settings;
167167

168+
console.log(loomState.model.bodyRows);
168169
let filteredBodyRows = filterBodyRowsByRules(loomState);
170+
console.log(filteredBodyRows);
169171
filteredBodyRows = filterBodyRowsBySearch(
170172
loomState,
171173
filteredBodyRows,
172174
searchText
173175
);
176+
console.log(filteredBodyRows);
177+
174178
const visibleColumns = columns.filter((column) => column.isVisible);
175179

176180
let className = "dataloom-app";

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,6 @@
119119
"8.2.1": "1.2.0",
120120
"8.2.2": "1.2.0",
121121
"8.3.0": "1.2.0",
122-
"8.4.0": "1.2.0"
122+
"8.4.0": "1.2.0",
123+
"8.4.1": "1.2.0"
123124
}

0 commit comments

Comments
 (0)