From 010688006a53d9ce06ea6d02c71ba02003717a5b Mon Sep 17 00:00:00 2001 From: Devon Doyle Date: Fri, 22 Mar 2024 20:19:51 -0400 Subject: [PATCH] [Client] Fix issue with clearing multitag buffer (#1299) * fix improper state reference * add parentheses for clarity * fix buffer array reactivity + loop optimization --- photon-client/src/components/dashboard/tabs/TargetsTab.vue | 2 +- photon-client/src/stores/StateStore.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/photon-client/src/components/dashboard/tabs/TargetsTab.vue b/photon-client/src/components/dashboard/tabs/TargetsTab.vue index 1e2caf8936..f37bcc78e3 100644 --- a/photon-client/src/components/dashboard/tabs/TargetsTab.vue +++ b/photon-client/src/components/dashboard/tabs/TargetsTab.vue @@ -28,7 +28,7 @@ const calculateStdDev = (values: number[]): number => { }; const resetCurrentBuffer = () => { // Need to clear the array in place - while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop(); + if (useStateStore().currentMultitagBuffer) useStateStore().currentMultitagBuffer!.length = 0; }; diff --git a/photon-client/src/stores/StateStore.ts b/photon-client/src/stores/StateStore.ts index 47ec05eb82..3a7376e12b 100644 --- a/photon-client/src/stores/StateStore.ts +++ b/photon-client/src/stores/StateStore.ts @@ -84,7 +84,8 @@ export const useStateStore = defineStore("state", { return this.backendResults[this.currentCameraIndex.toString()]; }, currentMultitagBuffer(): MultitagResult[] | undefined { - return this.multitagResultBuffer[this.currentCameraIndex.toString()]; + if (!this.multitagResultBuffer[this.currentCameraIndex]) this.multitagResultBuffer[this.currentCameraIndex] = []; + return this.multitagResultBuffer[this.currentCameraIndex]; } }, actions: {