Skip to content

Commit 0106880

Browse files
authored
[Client] Fix issue with clearing multitag buffer (PhotonVision#1299)
* fix improper state reference * add parentheses for clarity * fix buffer array reactivity + loop optimization
1 parent 2d8b1ec commit 0106880

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

photon-client/src/components/dashboard/tabs/TargetsTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const calculateStdDev = (values: number[]): number => {
2828
};
2929
const resetCurrentBuffer = () => {
3030
// Need to clear the array in place
31-
while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop();
31+
if (useStateStore().currentMultitagBuffer) useStateStore().currentMultitagBuffer!.length = 0;
3232
};
3333
</script>
3434

photon-client/src/stores/StateStore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export const useStateStore = defineStore("state", {
8484
return this.backendResults[this.currentCameraIndex.toString()];
8585
},
8686
currentMultitagBuffer(): MultitagResult[] | undefined {
87-
return this.multitagResultBuffer[this.currentCameraIndex.toString()];
87+
if (!this.multitagResultBuffer[this.currentCameraIndex]) this.multitagResultBuffer[this.currentCameraIndex] = [];
88+
return this.multitagResultBuffer[this.currentCameraIndex];
8889
}
8990
},
9091
actions: {

0 commit comments

Comments
 (0)