From 43eefcf1c5f90d9820d849a46d3d36ac90a08e27 Mon Sep 17 00:00:00 2001 From: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:02:18 -0400 Subject: [PATCH] Correctly stringify numbers in textboxes (#921) * fix an issue where the fov isnt reset on error * Fix issue with incorrectly reading fov on update * Properly handle NPE in case of error * Fix issue with vuetify comps not converting strings to numbers * Formatting fixes --- .../src/components/cameras/CameraSettingsCard.vue | 15 +++++++++------ .../src/components/common/cv-range-slider.vue | 7 ++++++- photon-client/src/components/common/cv-slider.vue | 2 +- .../org/photonvision/server/RequestHandler.java | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/photon-client/src/components/cameras/CameraSettingsCard.vue b/photon-client/src/components/cameras/CameraSettingsCard.vue index 7edcf954f8..cc40394b77 100644 --- a/photon-client/src/components/cameras/CameraSettingsCard.vue +++ b/photon-client/src/components/cameras/CameraSettingsCard.vue @@ -3,20 +3,22 @@ import CvSelect from "@/components/common/cv-select.vue"; import CvNumberInput from "@/components/common/cv-number-input.vue"; import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore"; import { useStateStore } from "@/stores/StateStore"; -import { ref } from "vue"; +import { ref, watchEffect } from "vue"; -const currentFov = ref(useCameraSettingsStore().currentCameraSettings.fov.value); +const currentFov = ref(); const saveCameraSettings = () => { useCameraSettingsStore() - .updateCameraSettings({ fov: currentFov.value }, true) + .updateCameraSettings({ fov: currentFov.value }, false) .then((response) => { + useCameraSettingsStore().currentCameraSettings.fov.value = currentFov.value; useStateStore().showSnackbarMessage({ color: "success", message: response.data.text || response.data }); }) .catch((error) => { + currentFov.value = useCameraSettingsStore().currentCameraSettings.fov.value; if (error.response) { useStateStore().showSnackbarMessage({ color: "error", @@ -33,11 +35,12 @@ const saveCameraSettings = () => { message: "An error occurred while trying to process the request." }); } - }) - .finally(() => { - useCameraSettingsStore().currentCameraSettings.fov.value = currentFov.value; }); }; + +watchEffect(() => { + currentFov.value = useCameraSettingsStore().currentCameraSettings.fov.value; +});