refactor(views/board): store both branch and note

This commit is contained in:
Elian Doran
2025-07-19 20:34:54 +03:00
parent f69878b082
commit a428ea7beb
2 changed files with 15 additions and 7 deletions

View File

@@ -1,8 +1,13 @@
import FBranch from "../../../entities/fbranch";
import FNote from "../../../entities/fnote";
type ColumnMap = Map<string, {
branch: FBranch;
note: FNote;
}[]>;
export async function getBoardData(parentNote: FNote, groupByColumn: string) {
const byColumn: Map<string, FBranch[]> = new Map();
const byColumn: ColumnMap = new Map();
await recursiveGroupBy(parentNote.getChildBranches(), byColumn, groupByColumn);
@@ -11,7 +16,7 @@ export async function getBoardData(parentNote: FNote, groupByColumn: string) {
};
}
async function recursiveGroupBy(branches: FBranch[], byColumn: Map<string, FBranch[]>, groupByColumn: string) {
async function recursiveGroupBy(branches: FBranch[], byColumn: ColumnMap, groupByColumn: string) {
for (const branch of branches) {
const note = await branch.getNote();
if (!note) {
@@ -26,6 +31,9 @@ async function recursiveGroupBy(branches: FBranch[], byColumn: Map<string, FBran
if (!byColumn.has(group)) {
byColumn.set(group, []);
}
byColumn.get(group)!.push(branch);
byColumn.get(group)!.push({
branch,
note
});
}
}

View File

@@ -123,8 +123,8 @@ export default class BoardView extends ViewMode<StateInfo> {
const data = await getBoardData(this.parentNote, "status");
for (const column of data.byColumn.keys()) {
const columnBranches = data.byColumn.get(column);
if (!columnBranches) {
const columnItems = data.byColumn.get(column);
if (!columnItems) {
continue;
}
@@ -145,8 +145,8 @@ export default class BoardView extends ViewMode<StateInfo> {
// Setup drop zone for the column
this.setupColumnDropZone($columnEl, column);
for (const branch of columnBranches) {
const note = await branch.getNote();
for (const item of columnItems) {
const note = item.note;
if (!note) {
continue;
}