From 50cd28d576e2ef5815b5f013145e56006eeef82b Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 9 Jan 2024 13:43:52 -0300 Subject: [PATCH] controller: mapping-import: Move `sweetalert` modal raise to component calling the function --- src/stores/controller.ts | 8 +++----- src/views/ConfigurationJoystickView.vue | 12 +++++++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/stores/controller.ts b/src/stores/controller.ts index 775a17f40..79940ed2f 100644 --- a/src/stores/controller.ts +++ b/src/stores/controller.ts @@ -253,18 +253,16 @@ export const useControllerStore = defineStore('controller', () => { const importFunctionsMappingFromVehicle = async (vehicleAddress: string): Promise => { const newMappings = await getKeyDataFromCockpitVehicleStorage(vehicleAddress, protocolMappingsKey) if (!newMappings) { - Swal.fire({ icon: 'error', text: 'Could not import functions mapping from vehicle. No data available.' }) - return + throw new Error('Could not import functions mapping from vehicle. No data available.') } + newMappings.forEach((mapping: JoystickProtocolActionsMapping) => { if (!mapping || !mapping['name'] || !mapping['axesCorrespondencies'] || !mapping['buttonsCorrespondencies']) { - Swal.fire({ icon: 'error', text: 'Could not import joystick funtions from vehicle. Invalid data.' }) - return + throw new Error('Could not import joystick funtions from vehicle. Invalid data.') } }) // @ts-ignore: We check for the necessary fields in the if before protocolMappings.value = newMappings - Swal.fire({ icon: 'success', text: 'Joystick functions mapping imported from vehicle.' }) } return { diff --git a/src/views/ConfigurationJoystickView.vue b/src/views/ConfigurationJoystickView.vue index bf6a3687f..81f5fb4fc 100644 --- a/src/views/ConfigurationJoystickView.vue +++ b/src/views/ConfigurationJoystickView.vue @@ -160,7 +160,7 @@ @@ -273,6 +273,7 @@