diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 3b7a0d5fc..ffaf9ccb4 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -34,7 +34,6 @@ import type { } from '@/libs/vehicle/types' import * as Vehicle from '@/libs/vehicle/vehicle' import { VehicleFactory } from '@/libs/vehicle/vehicle-factory' -import { Alert, AlertLevel } from '@/types/alert' import { type MetadataFile } from '@/types/ardupilot-metadata' import { type JoystickState, @@ -44,7 +43,6 @@ import { } from '@/types/joystick' import type { MissionLoadingCallback, Waypoint } from '@/types/mission' -import { useAlertStore } from './alert' import { useControllerStore } from './controller' /** @@ -96,8 +94,6 @@ class CustomizableParameter { } export const useMainVehicleStore = defineStore('main-vehicle', () => { - const alertStore = useAlertStore() - const cpuLoad = ref() const globalAddress = useStorage('cockpit-vehicle-address', defaultGlobalAddress) const _mainConnectionURI = new CustomizableParameter(() => { @@ -247,7 +243,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) diff --git a/src/stores/vehicleAlerter.ts b/src/stores/vehicleAlerter.ts index df2a46591..cd3f5c030 100644 --- a/src/stores/vehicleAlerter.ts +++ b/src/stores/vehicleAlerter.ts @@ -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}`)) + } + ) })