From 54069f6bf1b3b7f326ee35c226f0e78bde396775 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Fri, 24 Nov 2023 16:17:25 -0300 Subject: [PATCH] Allow restoring last mission name --- src/App.vue | 9 ++++++++- src/stores/mission.ts | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index 9abeb431e..c874442f7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -54,7 +54,14 @@ Mission configuration - +
+ +
diff --git a/src/stores/mission.ts b/src/stores/mission.ts index 23cc3366a..7742229bf 100644 --- a/src/stores/mission.ts +++ b/src/stores/mission.ts @@ -1,13 +1,16 @@ import { useStorage } from '@vueuse/core' import { defineStore } from 'pinia' -import { reactive, ref } from 'vue' +import { reactive, ref, watch } from 'vue' import type { Waypoint, WaypointCoordinates } from '@/types/mission' export const useMissionStore = defineStore('mission', () => { const missionName = ref('') + const lastMissionName = useStorage('cockpit-last-mission-name', '') const missionStartTime = useStorage('cockpit-mission-start-time', new Date()) + watch(missionName, () => (lastMissionName.value = missionName.value)) + const currentPlanningWaypoints = reactive([]) const moveWaypoint = (id: string, newCoordinates: WaypointCoordinates): void => { @@ -21,5 +24,5 @@ export const useMissionStore = defineStore('mission', () => { ) } - return { missionName, missionStartTime, currentPlanningWaypoints, moveWaypoint } + return { missionName, lastMissionName, missionStartTime, currentPlanningWaypoints, moveWaypoint } })