Skip to content

A self-hosted media server and file management system

fix: folder loading ui sequence is janky

aminnausin566fd1815582
diff --git a/resources/js/components/panels/FolderSidebar.vue b/resources/js/components/panels/FolderSidebar.vue
index d62f9459..7f9fbba8 100644
--- a/resources/js/components/panels/FolderSidebar.vue
+++ b/resources/js/components/panels/FolderSidebar.vue
@@ -15,6 +15,7 @@ import { TableBase } from '@/components/cedar-ui/table';
import { FLAGS } from '@/config/featureFlags';
import { cn } from '@aminnausin/cedar-ui';
+import SidebarFolderTableSkeleton from '@/components/skeleton/composites/SidebarFolderTableSkeleton.vue';
import EditFolderModal from '@/components/modals/EditFolderModal.vue';
import SidebarHeader from '@/components/headers/SidebarHeader.vue';
import FolderCard from '@/components/cards/data/FolderCard.vue';
@@ -32,7 +33,7 @@ const folderSortDir = ref<SortDir>(1);
const folderSortKey = ref<keyof FolderResource>(folderSortingOptions[0].value);
const showFilters = ref(true);
-const { stateDirectory, stateFolder } = storeToRefs(useContentStore());
+const { stateDirectory, stateFolder, isLoadingContent } = storeToRefs(useContentStore());
const breakpoints = useBreakpoints({ ...breakpointsTailwind, xs: 320, xms: 400, '3xl': 2000 });
const isDesktop = breakpoints.greaterOrEqual('lg');
@@ -91,6 +92,8 @@ const handleFolderAction = (e: Event, id: number, action: 'edit' | 'share' = 'ed
<TableBase
id="list-content-folders"
v-model="folderSearchQuery"
+ :loading="isLoadingContent"
+ :loading-placeholder="SidebarFolderTableSkeleton"
:data="filteredFolders"
:row="FolderCard"
:class="'full-height-sidebar [--table-input-height:2rem] lg:[--table-input-height:inherit]'"
diff --git a/resources/js/components/panels/VideoSidebar.vue b/resources/js/components/panels/VideoSidebar.vue
index 11d58acd..90941721 100755
--- a/resources/js/components/panels/VideoSidebar.vue
+++ b/resources/js/components/panels/VideoSidebar.vue
@@ -5,16 +5,13 @@ import { useAppStore } from '@/stores/AppStore';
import SidebarSkeleton from '@/components/skeleton/composites/SidebarSkeleton.vue';
import HistorySidebar from '@/components/panels/HistorySidebar.vue';
-defineProps<{ isLoadingFolders?: boolean }>();
-
const AppStore = useAppStore();
const FolderSidebarAsync = defineAsyncComponent(async () => await import('@/components/panels/FolderSidebar.vue'));
</script>
<template>
<Suspense v-if="AppStore.selectedSideBar === 'folders'">
- <SidebarSkeleton v-if="isLoadingFolders" />
- <FolderSidebarAsync v-else />
+ <FolderSidebarAsync />
<template #fallback>
<SidebarSkeleton />
</template>
diff --git a/resources/js/components/skeleton/composites/SidebarFolderTableSkeleton.vue b/resources/js/components/skeleton/composites/SidebarFolderTableSkeleton.vue
new file mode 100644
index 00000000..42c935db
--- /dev/null
+++ b/resources/js/components/skeleton/composites/SidebarFolderTableSkeleton.vue
@@ -0,0 +1,41 @@
+<script setup lang="ts">
+import { getScreenSizeRank } from '@/service/util';
+
+import SidebarCard from '@/components/cards/sidebar/SidebarCard.vue';
+</script>
+
+<template>
+ <div class="contents">
+ <SidebarCard v-for="i in getScreenSizeRank() > 3 ? 12 : 6" :key="i" class="animate-pulse p-0 lg:h-20 lg:p-3">
+ <div
+ :class="[
+ 'bg-foreground-1/20 sm:aspect-2-3',
+ 'aspect-square max-h-16 w-full rounded-t-lg object-cover',
+ 'sm:max-h-none sm:w-16 sm:rounded-t-none sm:rounded-l-lg sm:shadow-md',
+ 'lg:hidden',
+ 'content-auto sm:[contain-intrinsic-size:auto_96px]',
+ ]"
+ ></div>
+ <div class="flex w-full flex-1 flex-col sm:p-3 lg:contents lg:p-0">
+ <div
+ :class="[
+ 'flex w-full flex-1 flex-col flex-wrap gap-4 p-3 text-left',
+ 'sm:min-h-18 sm:justify-between sm:p-0',
+ 'lg:min-h-0 lg:flex-row lg:justify-normal lg:gap-2',
+ 'justify-between',
+ ]"
+ >
+ <div class="flex h-fit w-full items-center gap-2">
+ <div class="bg-foreground-1/20 mr-auto h-5 flex-1 rounded lg:h-4"></div>
+ <div class="bg-foreground-1/10 size-5 rounded lg:size-4 lg:rounded-sm"></div>
+ <div class="bg-foreground-1/10 size-5 rounded lg:size-4 lg:rounded-sm"></div>
+ </div>
+ <div class="mt-auto flex h-fit w-full justify-between gap-4">
+ <div class="bg-foreground-2/10 h-4 w-32 rounded lg:h-3 lg:flex-2"></div>
+ <div class="bg-foreground-1/10 h-4 w-20 rounded lg:h-3 lg:flex-1"></div>
+ </div>
+ </div>
+ </div>
+ </SidebarCard>
+ </div>
+</template>
diff --git a/resources/js/stores/ContentStore.ts b/resources/js/stores/ContentStore.ts
index 1c45bd48..f672a468 100644
--- a/resources/js/stores/ContentStore.ts
+++ b/resources/js/stores/ContentStore.ts
@@ -52,6 +52,8 @@ export const useContentStore = defineStore('Content', () => {
const stateFolder = ref<FolderResource>(emptyFolder);
const stateVideo = ref<VideoResource>(emptyMedia);
+ const isLoadingContent = ref(false);
+
// Video search and sort and results
const videoSort = ref<SortCriteria<VideoResource>>({ column: 'title', dir: 1 });
const searchQuery = ref('');
@@ -387,6 +389,7 @@ export const useContentStore = defineStore('Content', () => {
nextVideoURL,
previousVideoURL,
currentMediaIndex,
+ isLoadingContent,
getCategory,
getFolder,
getMetadataById,
diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vue
index b86afcae..d221ca59 100755
--- a/resources/js/views/VideoView.vue
+++ b/resources/js/views/VideoView.vue
@@ -26,13 +26,11 @@ import ShareModal from '@/components/modals/ShareModal.vue';
import VideoCard from '@/components/cards/data/VideoCard.vue';
const { getFolder, getCategory, playlistFind, playlistSort } = useContentStore();
-const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder, currentMediaIndex } = storeToRefs(useContentStore());
+const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder, currentMediaIndex, isLoadingContent } = storeToRefs(useContentStore());
const { pageTitle, selectedSideBar } = storeToRefs(useAppStore());
const ambientPlayer = useTemplateRef('ambientPlayer');
-const isLoading = ref(false);
-
const modal = useModalStore();
const route = useRoute();
@@ -40,7 +38,7 @@ const mediaTypeDescription = computed(() => (stateVideo.value?.metadata?.media_t
const queryVideoId = computed(() => toParamNumber(route.query.video));
async function reload() {
- if (isLoading.value) return;
+ if (isLoadingContent.value) return;
try {
const toSingleParam = (p: string | string[]) => (Array.isArray(p) ? p[0] : p);
@@ -48,7 +46,7 @@ async function reload() {
const URL_CATEGORY = toSingleParam(route.params.category);
const URL_FOLDER = toSingleParam(route.params.folder);
- isLoading.value = true;
+ isLoadingContent.value = true;
await nextTick();
document.body.scrollTo({ top: 0, behavior: 'instant' });
@@ -60,7 +58,7 @@ async function reload() {
} catch (error) {
console.log(error);
}
- isLoading.value = false;
+ isLoadingContent.value = false;
setFolderAsPageTitle();
}
@@ -160,7 +158,7 @@ watch(() => stateVideo.value, setVideoAsDocumentTitle, { immediate: false });
:data="stateFilteredPlaylist"
:row="VideoCard"
:otherAction="handleVideoAction"
- :loading="isLoading"
+ :loading="isLoadingContent"
:useToolbar="true"
:sortAction="handleSort"
:sortingOptions="sortingOptions.filter((s) => !s.hidden)"
@@ -172,7 +170,7 @@ watch(() => stateVideo.value, setVideoAsDocumentTitle, { immediate: false });
</section>
</template>
<template v-slot:sidebar>
- <VideoSidebar :isLoadingFolders="isLoading" />
+ <VideoSidebar />
</template>
</LayoutBase>
</template>