Skip to content

A self-hosted media server and file management system

fix: document title should reflect video and folder correctly now

aminnausine094238809eb
diff --git a/resources/js/stores/ContentStore.js b/resources/js/stores/ContentStore.js
index 9cc38550..caf51264 100755
--- a/resources/js/stores/ContentStore.js
+++ b/resources/js/stores/ContentStore.js
@@ -102,18 +102,19 @@ export const useContentStore = defineStore('Content', () => {
function playlistFind(id) {
let result = stateFilteredPlaylist.value.length > 0 ? stateFilteredPlaylist.value[0] : {};
- if (id && stateVideo.value.id === id) return;
+ if (id && stateVideo.value.id === id) return false;
if (!isNaN(parseInt(id))) {
result = stateFilteredPlaylist.value.find((video) => {
return video.id === id;
});
}
- if (!result) toast.add('Invalid Video', { type: 'danger', description: 'Selected video cannot be found...' });
- else {
- stateVideo.value = result;
- document.title = `${stateFolder.value.name} · ${stateVideo.value?.title ?? stateVideo.value?.name}`;
+ if (!result) {
+ toast.add('Invalid Video', { type: 'danger', description: 'Selected video cannot be found...' });
+ return false;
}
+ stateVideo.value = result;
+ return true;
}
// needs to go in the computed property
diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vue
index fecae7de..ce133585 100755
--- a/resources/js/views/VideoView.vue
+++ b/resources/js/views/VideoView.vue
@@ -36,8 +36,8 @@ const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFol
searchQuery: Ref<string>;
stateFilteredPlaylist: Ref<VideoResource[]>;
stateDirectory: Ref<CategoryResource>;
- stateVideo: Ref<VideoResource | { id?: number; metadata?: Metadata; path?: string }>;
- stateFolder: Ref<FolderResource | any>;
+ stateVideo: Ref<VideoResource>;
+ stateFolder: Ref<FolderResource>;
};
const handleVideoDetailsUpdate = (res: any) => {
@@ -127,8 +127,10 @@ const handleSearch = (query: string) => {
};
const handleVideoAction = (e: Event, id: number, action: 'edit' | 'share') => {
- let video = stateFolder.value?.videos.find((video: VideoResource) => video.id === id);
- if (video) cachedVideo.value = video;
+ if (!stateFolder.value?.videos) return;
+
+ let video = stateFolder.value.videos.find((video: VideoResource) => video.id === id);
+ if (video) cachedVideo.value = video; // idk what this does as removing it does not change functionality
if (action === 'edit') editVideoModal.toggleModal();
else shareVideoModal.toggleModal();
@@ -143,6 +145,13 @@ const setFolderAsPageTitle = () => {
pageTitle.value = title;
};
+const setVideoAsDocumentTitle = () => {
+ const folderTitle = stateFolder.value.series?.title ?? stateFolder.value.name;
+ const videoTitle = stateVideo.value?.metadata?.title ?? stateVideo.value?.name;
+ if (!folderTitle || !videoTitle) return;
+ document.title = `${folderTitle} · ${videoTitle}`;
+};
+
//#endregion
onMounted(async () => {
@@ -154,9 +163,8 @@ onMounted(async () => {
watch(
() => route.query.video,
(newVideo) => {
- if (stateFolder.value.name === route.params.folder) {
- playlistFind(newVideo);
- }
+ if (stateFolder.value.name !== route.params.folder || !playlistFind(newVideo)) return;
+ setVideoAsDocumentTitle();
},
{ immediate: false },
);
@@ -164,6 +172,7 @@ watch(() => route.params.folder, reload, { immediate: false });
watch(() => route.params.category, reload, { immediate: false });
watch(() => selectedSideBar.value, cycleSideBar, { immediate: false });
watch(() => stateFolder.value, setFolderAsPageTitle);
+watch(() => stateVideo.value, setVideoAsDocumentTitle, { immediate: true });
</script>
<template>