Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no file in directory bug #35

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@
readFileAndChildren(directory.children!);
const extensionsSort = new Map([...fileData.entries()].sort((a, b) => b[1] - a[1]));

// If can't find any file in the directory, display empty header
if (!extensionsSort.size) {
const alert = document.getElementById("empty");
alert.classList.remove("hidden");
const displayOption = document.getElementById("displayOption");
displayOption.style.display = "none";
}
else {
const displayOption = document.getElementById("displayOption");
displayOption.style.display = "block";
}

chart.data = {
labels: Array.from(extensionsSort.keys()).map(e => JSON.parse(e).name + " File"),
datasets: [{
Expand Down Expand Up @@ -162,7 +174,8 @@

<main class="flex flex-col justify-center items-start h-full">
<h1 class="main-header font-bold py-2">File Makeup for {cwd}</h1>
<Dropdown>
<h2 id="empty" class="hidden"> No files were found in the directory {cwd} </h2>
<Dropdown id="displayOption">
<Option on:click={() => {isFile = true; update()}}>Display File Count</Option>
<Option on:click={() => {isFile = false; update()}}>Display Byte Count</Option>
</Dropdown>
Expand Down