Skip to content

Commit

Permalink
Set timeout for loading element
Browse files Browse the repository at this point in the history
  • Loading branch information
marySalvi committed Nov 25, 2024
1 parent d6b0b72 commit b283bb6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client/src/components/FileBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,26 @@ const directoryData: Ref<DirectoryData> = ref({
childrenYaml: [],
});
const loadingData = ref(false);
const updateDirectories = async (currentDirectory?: string) => {
directoryData.value.children = [];
directoryData.value.childrenImages = [];
directoryData.value.childrenYaml = [];
const timeout = setTimeout(() => {
loadingData.value = true;
}, 100);
const data = await getDirectoryInfo(currentDirectory);
clearTimeout(timeout);
loadingData.value = false;
directoryData.value = await {
...data,
children: data.child_directories,
childrenImages: data.child_images,
childrenYaml: data.child_yaml_files,
};
loadingData.value = false;
calculateVisibleItems();
};
updateDirectories();
Expand Down Expand Up @@ -156,10 +164,7 @@ onBeforeUnmount(() => {
</div>
</div>
<div
v-if="
directoryData.children.length == 0 &&
directoryData.childrenYaml.length == 0
"
v-if="loadingData"
class="text-center"
>
<span class="loading loading-spinner text-primary"></span>
Expand Down

0 comments on commit b283bb6

Please sign in to comment.