Skip to content

Commit

Permalink
video-library: Do not auto-mount dialog on startup
Browse files Browse the repository at this point in the history
As it deals with heavy data, we have to take more care with it, and not load it when not necessary.
  • Loading branch information
rafaellehmkuhl committed Jan 30, 2025
1 parent a26a388 commit 89e88b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
</v-app>
<About v-if="showAboutDialog" @update:show-about-dialog="showAboutDialog = $event" />
<Tutorial :show-tutorial="interfaceStore.isTutorialVisible" />
<VideoLibraryModal :open-modal="interfaceStore.isVideoLibraryVisible" />
<VideoLibraryModal v-if="interfaceStore.isVideoLibraryVisible" :open-modal="interfaceStore.isVideoLibraryVisible" />
<VehicleDiscoveryDialog v-model="showDiscoveryDialog" show-auto-search-option />
<UpdateNotification v-if="isElectron()" />
</template>
Expand Down
27 changes: 6 additions & 21 deletions src/components/VideoLibraryModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,6 @@ const videoStore = useVideoStore()
const interfaceStore = useAppInterfaceStore()
const { showSnackbar } = useSnackbar()
const props = defineProps({
openModal: Boolean,
})
const emits = defineEmits(['update:openModal'])
const { showDialog, closeDialog } = useInteractionDialog()
const { width: windowWidth } = useWindowSize()
Expand All @@ -520,7 +515,7 @@ interface HammerInstances {
/* eslint-enable jsdoc/require-jsdoc */
const availableVideos = ref<VideoLibraryFile[]>([])
const availableLogFiles = ref<VideoLibraryLogFile[]>([])
const isVisible = ref(props.openModal)
const isVisible = ref(true)
const selectedVideos = ref<VideoLibraryFile[]>([])
const videoPlayerRef = ref<HTMLVideoElement | null>(null)
const currentTab = ref('videos')
Expand Down Expand Up @@ -611,7 +606,6 @@ const openVideoFolder = (): void => {
const closeModal = (): void => {
isVisible.value = false
emits('update:openModal', false)
currentTab.value = 'videos'
deselectAllVideos()
lastSelectedVideo.value = null
Expand Down Expand Up @@ -971,7 +965,6 @@ watch(
)
watch(isVisible, (newValue) => {
emits('update:openModal', newValue)
if (!newValue) {
resetProgressBars()
isMultipleSelectionMode.value = false
Expand All @@ -981,17 +974,6 @@ watch(isVisible, (newValue) => {
}
})
watch(
() => props.openModal,
async (newVal) => {
isVisible.value = newVal
if (newVal === true) {
await fetchVideosAndLogData()
showOnScreenProgress.value = false
}
}
)
const loadVideoBlobIntoPlayer = async (videoFileName: string): Promise<void> => {
loadingVideoBlob.value = true
Expand Down Expand Up @@ -1031,7 +1013,7 @@ watch(
unloadVideoBlob()
}
},
{ immediate: true, deep: true }
{ deep: true }
)
// Keep last processed video selected after refresh
Expand Down Expand Up @@ -1114,8 +1096,11 @@ watch(
)
onMounted(async () => {
loadingData.value = true
await fetchVideosAndLogData()
if (availableVideos.value.length > 0) {
await loadVideoBlobIntoPlayer(availableVideos.value[0].fileName)
}
showOnScreenProgress.value = false
})
onBeforeUnmount(() => {
Expand Down

0 comments on commit 89e88b4

Please sign in to comment.