From d6147e2653c6d1678873dfb850dbbff4ad2a8524 Mon Sep 17 00:00:00 2001 From: Arturo Manzoli Date: Tue, 7 Jan 2025 17:57:58 -0300 Subject: [PATCH] App: Startup dialogs: Implement changes to run under dialog queue Signed-off-by: Arturo Manzoli --- src/components/InteractionDialog.vue | 14 ++++++++- src/components/Tutorial.vue | 19 +++--------- src/components/UpdateNotification.vue | 35 ++++++++++++++++------- src/components/VehicleDiscoveryDialog.vue | 14 +++++++-- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/src/components/InteractionDialog.vue b/src/components/InteractionDialog.vue index c8b413a8a..a4adf7863 100644 --- a/src/components/InteractionDialog.vue +++ b/src/components/InteractionDialog.vue @@ -1,5 +1,11 @@ + @@ -37,6 +38,9 @@ import { onBeforeMount, ref } from 'vue' import InteractionDialog, { type Action } from '@/components/InteractionDialog.vue' import { app_version } from '@/libs/cosmos' import { isElectron } from '@/libs/utils' +import { useAppInterfaceStore } from '@/stores/appInterface' + +const interfaceStore = useAppInterfaceStore() const showUpdateDialog = ref(false) const dialogTitle = ref('') @@ -52,6 +56,11 @@ const updateInfo = ref({ }) const ignoredUpdateVersions = useStorage('cockpit-ignored-update-versions', []) +const handleClose = (): void => { + interfaceStore.openNextDialogOnQueue() + showUpdateDialog.value = false +} + const formatDate = (date: string): string => { return new Date(date).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }) } @@ -75,7 +84,9 @@ onBeforeMount(() => { dialogVariant.value = 'info' dialogActions.value = [] showProgress.value = false - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) window.electronAPI.onUpdateNotAvailable(() => { @@ -87,7 +98,7 @@ onBeforeMount(() => { { text: 'OK', action: () => { - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] @@ -107,7 +118,7 @@ onBeforeMount(() => { console.log(`User chose to ignore version ${updateInfo.value.version}`) ignoredUpdateVersions.value.push(updateInfo.value.version) window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, { @@ -121,7 +132,7 @@ onBeforeMount(() => { action: () => { console.log('User chose to cancel the update for the Electron app.') window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() dialogMessage.value = 'Downloading update...' }, }, @@ -132,7 +143,7 @@ onBeforeMount(() => { text: 'Not Now', action: () => { window.electronAPI!.cancelUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] @@ -140,11 +151,13 @@ onBeforeMount(() => { // Check if this version is in the ignored list if (ignoredUpdateVersions.value.includes(info.version)) { console.log(`Skipping ignored version ${info.version}.`) - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() return } - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) window.electronAPI.onDownloadProgress((progressInfo) => { @@ -164,18 +177,20 @@ onBeforeMount(() => { action: () => { console.log('User chose to install the update for the Electron app now.') window.electronAPI!.installUpdate() - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, { text: 'Later', action: () => { console.log('User chose to install the update for the Electron app later.') - showUpdateDialog.value = false + interfaceStore.openNextDialogOnQueue() }, }, ] - showUpdateDialog.value = true + if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) { + showUpdateDialog.value = true + } }) }) diff --git a/src/components/VehicleDiscoveryDialog.vue b/src/components/VehicleDiscoveryDialog.vue index 456f5fb99..1365690d1 100644 --- a/src/components/VehicleDiscoveryDialog.vue +++ b/src/components/VehicleDiscoveryDialog.vue @@ -47,15 +47,18 @@