Skip to content

Commit

Permalink
[Client] Fix issue with clearing multitag buffer (PhotonVision#1299)
Browse files Browse the repository at this point in the history
* fix improper state reference

* add parentheses for clarity

* fix buffer array reactivity + loop optimization
  • Loading branch information
DevonRD authored Mar 23, 2024
1 parent 2d8b1ec commit 0106880
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion photon-client/src/components/dashboard/tabs/TargetsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion photon-client/src/stores/StateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 0106880

Please sign in to comment.