Skip to content

A self-hosted media server and file management system

chore: code smells

aminnausin981e5bad4d2d
diff --git a/resources/js/components/video/VideoHeatmap.vue b/resources/js/components/video/VideoHeatmap.vue
index f50dd36f..8c92fc16 100644
--- a/resources/js/components/video/VideoHeatmap.vue
+++ b/resources/js/components/video/VideoHeatmap.vue
@@ -83,7 +83,7 @@ const heatMap = computed(() => {
catmullRomFitting(
props.playbackData
? [
- ...props.playbackData?.map((entry: { progress: any; count: number }) => {
+ ...props.playbackData.map((entry: { progress: any; count: number }) => {
return { x: entry.progress, y: 100 - Math.min(entry.count, 10) * 10 };
}),
{ x: 1000, y: 100 },
diff --git a/resources/js/components/video/VideoInfoPanel.vue b/resources/js/components/video/VideoInfoPanel.vue
index 26e2cd4b..83ce5620 100755
--- a/resources/js/components/video/VideoInfoPanel.vue
+++ b/resources/js/components/video/VideoInfoPanel.vue
@@ -246,12 +246,11 @@ onMounted(() => {
<p class="text-nowrap">Edit Metadata</p>
</template>
</ButtonText>
- <!-- This looks ugly
- <ButtonIcon aria-label="download" title="Download Video">
+ <ButtonIcon aria-label="download" title="Download Video" class="hidden">
<template #icon>
<ProiconsArrowDownload height="16" width="16" />
</template>
- </ButtonIcon> -->
+ </ButtonIcon>
<ButtonIcon aria-label="share" title="Share Video" @click="shareVideoModal.toggleModal()">
<template #icon>
<CircumShare1 height="16" width="16" />
diff --git a/resources/js/service/records/api.ts b/resources/js/service/records/api.ts
index 2077ed15..bf4bbf94 100644
--- a/resources/js/service/records/api.ts
+++ b/resources/js/service/records/api.ts
@@ -18,8 +18,10 @@ export default {
if (params?.limit) queryParams.set('limit', params.limit.toString());
if (params?.page) queryParams.set('page', params.page.toString());
- const queryString = queryParams.toString();
- return API.get<{ data: RecordResource[] }>(`/records${queryString ? `?${queryString}` : ''}`);
+ let queryString = queryParams.toString();
+ if (queryString) queryString = `?${queryString}`;
+
+ return API.get<{ data: RecordResource[] }>(`/records${queryString}`);
},
deleteRecord(id: number) {
diff --git a/resources/js/stores/AppStore.ts b/resources/js/stores/AppStore.ts
index c0be8592..27051d25 100644
--- a/resources/js/stores/AppStore.ts
+++ b/resources/js/stores/AppStore.ts
@@ -8,6 +8,10 @@ import { EchoConfig } from '@/echo.ts';
import ContextMenu from '@/components/pinesUI/ContextMenu.vue';
import Echo from 'laravel-echo';
+function booleanToString(val: undefined | boolean) {
+ return val ? 'true' : 'false';
+}
+
export const useAppStore = defineStore('App', () => {
const { data: rawWaitTimes, isLoading: isLoadingWaitTimes } = useGetTaskWaitTimes();
const { data: rawAppManifest } = useGetManifest();
@@ -131,10 +135,6 @@ export const useAppStore = defineStore('App', () => {
scrollLock.value = state;
}
- function booleanToString(val: undefined | boolean) {
- return val ? 'true' : 'false';
- }
-
const setContextMenu = (event: MouseEvent, options: ContextMenuType) => {
if (!options.items || options.items.length === 0) return;
contextMenuEvent.value = event;
diff --git a/resources/js/stores/ContentStore.ts b/resources/js/stores/ContentStore.ts
index 89ddb05c..d4ed99b3 100644
--- a/resources/js/stores/ContentStore.ts
+++ b/resources/js/stores/ContentStore.ts
@@ -1,5 +1,5 @@
import type { CategoryResource, FolderResource, SeriesResource, VideoResource } from '@/types/resources';
-import type { SortCriteria, SortDir, SortKey } from '@/service/sort/types';
+import type { SortCriteria, SortKey } from '@/service/sort/types';
import { formatFileSize, toFormattedDuration } from '@/service/util';
import { computed, ref, watch } from 'vue';
@@ -19,6 +19,8 @@ const emptyLibrary: CategoryResource = { id: -1, name: '', folders: [], folders_
const emptyFolder: FolderResource = { id: -1, name: '', title: '', path: '', file_count: 0, total_size: 0, is_majority_audio: false, category_id: -1, videos: [], last_scan: -1 };
const emptyMedia: VideoResource = { id: -1, name: '', path: '', view_count: 0, video_tags: [], date: '', date_created: '' };
+const DEFAULT_SORT = { column: 'name', dir: 1 };
+
export const useContentStore = defineStore('Content', () => {
const router = useRouter();
const route = useRoute();
@@ -129,8 +131,8 @@ export const useContentStore = defineStore('Content', () => {
* needs to go in the computed property
* what is this ???
*/
- function playlistSort(sort: SortCriteria<VideoResource> = { column: 'name', dir: 1 }) {
- videoSort.value = { ...videoSort.value, ...sort };
+ function playlistSort(sort: SortCriteria<VideoResource>) {
+ videoSort.value = { ...videoSort.value, ...(sort ?? DEFAULT_SORT) };
}
// #endregion
diff --git a/resources/js/views/VideoView.vue b/resources/js/views/VideoView.vue
index 9dd42d3e..282d11b3 100755
--- a/resources/js/views/VideoView.vue
+++ b/resources/js/views/VideoView.vue
@@ -3,7 +3,6 @@ import type { VideoResource } from '@/types/resources';
import type { SortDir } from '@/service/sort/types';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
-import { useRecordsLimited } from '@/service/records/useRecords';
import { useContentStore } from '@/stores/ContentStore';
import { toFormattedDate } from '@/service/util';
import { toParamNumber } from '@/util/route';
@@ -24,7 +23,6 @@ import useModal from '@/composables/useModal';
const route = useRoute();
-// const { getRecords } = useRecordsLimited();
const { selectedSideBar, pageTitle } = storeToRefs(useAppStore());
const { getFolder, getCategory, playlistFind, playlistSort, updateVideoData } = useContentStore();
const { searchQuery, stateFilteredPlaylist, stateDirectory, stateVideo, stateFolder } = storeToRefs(useContentStore());
@@ -47,11 +45,10 @@ const handleVideoDetailsUpdate = (res: any) => {
};
async function cycleSideBar(state: string) {
+ if (!state) return;
if (state === 'history') {
- // Invalidate query everytime sidebar is opened
- // getRecords();
+ // Invalidate query everytime sidebar is opened ( not anymore ? )
}
- if (!state) return;
}
async function reload() {