Skip to content

Commit

Permalink
App: Startup dialogs: Implement changes to run under dialog queue
Browse files Browse the repository at this point in the history
Signed-off-by: Arturo Manzoli <[email protected]>
  • Loading branch information
ArturoManzoli committed Jan 27, 2025
1 parent 8e8c3a5 commit 2b70ec8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
21 changes: 6 additions & 15 deletions src/components/Tutorial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,15 @@ import { useMainVehicleStore } from '@/stores/mainVehicle'
import GlassModal from './GlassModal.vue'
const { showSnackbar } = useSnackbar()
const interfaceStore = useAppInterfaceStore()
const vehicleStore = useMainVehicleStore()
const props = defineProps<{
/**
*
*/
showTutorial?: boolean
}>()
const emits = defineEmits(['update:showTutorial'])
const showTutorial = ref(props.showTutorial || false)
const userHasSeenTutorial = useBlueOsStorage('cockpit-has-seen-tutorial', false)
const showTutorial = ref(false)
const currentTutorialStep = ref(1)
const isVehicleConnectedVisible = ref(false)
const tallContent = ref(false)
const userHasSeenTutorial = useBlueOsStorage('cockpit-has-seen-tutorial', false)
const steps = [
{
Expand Down Expand Up @@ -345,7 +337,6 @@ const handleStepChangeDown = (newStep: number): void => {
const dontShowTutorialAgain = (): void => {
userHasSeenTutorial.value = true
showTutorial.value = false
emits('update:showTutorial', false)
showSnackbar({
message: 'This guide can be reopened via the Settings > General menu',
variant: 'info',
Expand All @@ -356,8 +347,6 @@ const dontShowTutorialAgain = (): void => {
const alwaysShowTutorialOnStartup = (): void => {
userHasSeenTutorial.value = false
showTutorial.value = true
emits('update:showTutorial', true)
}
const nextTutorialStep = (): void => {
Expand All @@ -379,7 +368,7 @@ const closeTutorial = (): void => {
showTutorial.value = false
interfaceStore.componentToHighlight = 'none'
currentTutorialStep.value = 1
emits('update:showTutorial', false)
interfaceStore.isTutorialVisible = false
}
const setVehicleConnectedVisible = (): void => {
Expand All @@ -403,6 +392,7 @@ const handleKeydown = (event: KeyboardEvent): void => {
watch(
() => interfaceStore.isTutorialVisible,
(val) => {
console.log('🚀 ~ val:', val)
showTutorial.value = val
}
)
Expand Down Expand Up @@ -435,6 +425,7 @@ onMounted(() => {
onBeforeUnmount(() => {
window.removeEventListener('keydown', handleKeydown)
interfaceStore.isTutorialVisible = false
})
</script>
<style>
Expand Down
17 changes: 14 additions & 3 deletions src/components/UpdateNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
</template>
</v-progress-linear>
</template>
<template #actions> <v-btn variant="text" size="small" @click="showUpdateDialog = false">Close</v-btn> </template>
</InteractionDialog>
</template>

Expand All @@ -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('')
Expand Down Expand Up @@ -75,7 +79,10 @@ onBeforeMount(() => {
dialogVariant.value = 'info'
dialogActions.value = []
showProgress.value = false
showUpdateDialog.value = true
if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) {
showUpdateDialog.value = true
return
}
})
window.electronAPI.onUpdateNotAvailable(() => {
Expand Down Expand Up @@ -144,7 +151,9 @@ onBeforeMount(() => {
return
}
showUpdateDialog.value = true
if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) {
showUpdateDialog.value = true
}
})
window.electronAPI.onDownloadProgress((progressInfo) => {
Expand Down Expand Up @@ -175,7 +184,9 @@ onBeforeMount(() => {
},
},
]
showUpdateDialog.value = true
if (interfaceStore.activeDialog?.id === 'UpdateNotification' || interfaceStore.activeDialog === undefined) {
showUpdateDialog.value = true
}
})
})
</script>
23 changes: 17 additions & 6 deletions src/components/VehicleDiscoveryDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@

<script setup lang="ts">
import { useStorage } from '@vueuse/core'
import { ref, watch } from 'vue'
import { computed, ref, watch } from 'vue'
import { useSnackbar } from '@/composables/snackbar'
import vehicleDiscover, { NetworkVehicle } from '@/libs/electron/vehicle-discovery'
import { reloadCockpit } from '@/libs/utils'
import { useAppInterfaceStore } from '@/stores/appInterface'
import { useMainVehicleStore } from '@/stores/mainVehicle'
import InteractionDialog, { Action } from './InteractionDialog.vue'
const interfaceStore = useAppInterfaceStore()
const props = defineProps<{
/**
*
Expand All @@ -69,13 +72,14 @@ const props = defineProps<{
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void
(e: 'close'): void
}>()
const { showSnackbar } = useSnackbar()
const mainVehicleStore = useMainVehicleStore()
const discoveryService = vehicleDiscover
const isOpen = ref(props.modelValue)
const isOpen = ref(false)
const searching = ref(false)
const searched = ref(false)
const vehicles = ref<NetworkVehicle[]>([])
Expand All @@ -85,7 +89,7 @@ const originalActions = [
{
text: 'Close',
action: () => {
isOpen.value = false
handleCloseDialog()
},
},
]
Expand All @@ -105,7 +109,6 @@ watch(
isOpen.value = value
}
)
watch(isOpen, (value) => {
emit('update:modelValue', value)
})
Expand All @@ -114,14 +117,17 @@ const searchVehicles = async (): Promise<void> => {
searching.value = true
disableButtons()
vehicles.value = await discoveryService.findVehicles()
handleCloseDialog()
searching.value = false
enableButtons()
searched.value = true
}
const selectVehicle = async (address: string): Promise<void> => {
mainVehicleStore.globalAddress = address
isOpen.value = false
handleCloseDialog()
await reloadCockpit()
showSnackbar({ message: 'Vehicle address updated', variant: 'success', duration: 5000 })
}
Expand All @@ -130,10 +136,15 @@ const preventFutureAutoSearchs = (): void => {
preventAutoSearch.value = true
disableButtons()
setTimeout(() => {
isOpen.value = false
handleCloseDialog()
}, 5000)
}
const handleCloseDialog = (): void => {
isOpen.value = false
emit('close')
}
const disableButtons = (): void => {
dialogActions.value = originalActions.map((action) => ({ ...action, disabled: true }))
}
Expand Down

0 comments on commit 2b70ec8

Please sign in to comment.