Skip to content

Commit

Permalink
Add vehicle disconnection alert
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Aug 22, 2023
1 parent 8ecfaa7 commit c6b3ccb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/stores/mainVehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
modes.value = mainVehicle.value.modesAvailable()
icon.value = mainVehicle.value.icon()
configurationPages.value = mainVehicle.value.configurationPages()
alertStore.pushAlert(new Alert(AlertLevel.Success, 'Vehicle connected'))

mainVehicle.value.onAltitude.add((newAltitude: Altitude) => {
Object.assign(altitude, newAltitude)
Expand Down
9 changes: 9 additions & 0 deletions src/stores/vehicleAlerter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,13 @@ export const useVehicleAlerterStore = defineStore('vehicle-alerter', () => {
alertStore.pushAlert(new Alert(AlertLevel.Info, `Vehicle ${state}`))
}
)

watch(
() => vehicleStore.isVehicleOnline,
(isOnlineNow) => {
const alertLevel = isOnlineNow ? AlertLevel.Success : AlertLevel.Error
const alertMessage = isOnlineNow ? 'connected' : 'disconnected'
alertStore.pushAlert(new Alert(alertLevel, `Vehicle ${alertMessage}`))
}
)
})

0 comments on commit c6b3ccb

Please sign in to comment.