Skip to content

Commit 76b49a7

Browse files
refactor(mobile): remove unused file tree walkers
1 parent 32142cf commit 76b49a7

2 files changed

Lines changed: 1 addition & 34 deletions

File tree

‎apps/mobile/src/features/files/fileTree.test.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { describe, expect, it } from "vite-plus/test";
22
import type { ProjectEntry } from "@t3tools/contracts";
33

4-
import {
5-
buildFileTree,
6-
countFileNodes,
7-
defaultExpandedTreePaths,
8-
firstFilePath,
9-
flattenFileTree,
10-
} from "./fileTree";
4+
import { buildFileTree, defaultExpandedTreePaths, flattenFileTree } from "./fileTree";
115

126
const entries = [
137
{ kind: "file", path: "README.md" },
@@ -30,8 +24,6 @@ describe("mobile file tree helpers", () => {
3024
"directory:src/components",
3125
"file:src/index.ts",
3226
]);
33-
expect(countFileNodes(tree)).toBe(4);
34-
expect(firstFilePath(tree)).toBe("src/components/App.tsx");
3527
});
3628

3729
it("flattens expanded directories and hides collapsed descendants", () => {

‎apps/mobile/src/features/files/fileTree.ts‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,6 @@ export function buildFileTree(entries: ReadonlyArray<ProjectEntry>): ReadonlyArr
117117
return [...root.children.values()].sort(compareNodes).map(freezeNode);
118118
}
119119

120-
export function countFileNodes(nodes: ReadonlyArray<FileTreeNode>): number {
121-
let count = 0;
122-
for (const node of nodes) {
123-
if (node.kind === "file") {
124-
count += 1;
125-
} else {
126-
count += countFileNodes(node.children);
127-
}
128-
}
129-
return count;
130-
}
131-
132120
export function defaultExpandedTreePaths(nodes: ReadonlyArray<FileTreeNode>): ReadonlySet<string> {
133121
const expanded = new Set<string>();
134122
for (const node of nodes) {
@@ -205,16 +193,3 @@ export function flattenFileTree(input: {
205193
}
206194
return output;
207195
}
208-
209-
export function firstFilePath(nodes: ReadonlyArray<FileTreeNode>): string | null {
210-
for (const node of nodes) {
211-
if (node.kind === "file") {
212-
return node.path;
213-
}
214-
const child = firstFilePath(node.children);
215-
if (child !== null) {
216-
return child;
217-
}
218-
}
219-
return null;
220-
}

0 commit comments

Comments
 (0)