Skip to content

Commit

Permalink
fix(birdie): breadcrumb navigation selects files (#328)
Browse files Browse the repository at this point in the history
* fix(birdie): breadcrumb navigation selects files

* fix(birdie): wording changes
  • Loading branch information
sylviacx authored Oct 16, 2024
1 parent 363f5a8 commit 91d9efb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions birdie/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,10 @@
const goBack = async (index: number) => {
ancestry = ancestry.slice(0, index + 1);
$currentRoot = ancestry.join('/');
$selectedFile = null;
const parentFiles = await getFiles(ancestry.slice(0, index).join('/'));
$selectedFile = parentFiles.find((f) => f.name === ancestry[index]) ?? null;
commits = [];
selectedFiles = [];
await refreshFiles();
Expand Down Expand Up @@ -566,12 +569,12 @@
});
};
const addCurrentRootToFileTree = async (node: Node, subFolders: string[]): Promise<Node> => {
const addSelectedFilePathToFileTree = async (node: Node, subFolders: string[]): Promise<Node> => {
if (node.value.fileType === FileType.File) return node;
const updatedChildFiles = await getFiles(node.value.path);
let updatedChildNodes: Node[] = [];
if (subFolders.length === 0) {
// we're at the deepest level of the current root
// we're at the deepest subfolder level
// update our children and "forget" anything deeper than this
updatedChildFiles.forEach((child) => {
updatedChildNodes.push({
Expand Down Expand Up @@ -601,7 +604,7 @@
updatedChildNodes = await Promise.all(
updatedChildNodes.map((child) => {
if (child.value.name === subFolders[0]) {
return addCurrentRootToFileTree(child, subFolders.slice(1));
return addSelectedFilePathToFileTree(child, subFolders.slice(1));
}
return child;
})
Expand All @@ -619,7 +622,7 @@
rootNode.set(parsedFileTree);
}
if ($selectedFile) {
$rootNode = await addCurrentRootToFileTree(get(rootNode), $selectedFile.path.split('/'));
$rootNode = await addSelectedFilePathToFileTree(get(rootNode), $selectedFile.path.split('/'));
}
};
Expand Down

0 comments on commit 91d9efb

Please sign in to comment.