Skip to content

Commit

Permalink
fix: 🐛 prevent simultaneous refreshes
Browse files Browse the repository at this point in the history
  • Loading branch information
meisZWFLZ committed Jan 2, 2024
1 parent 6f6bf0f commit 01ef415
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/VexDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,9 @@ export class V5SerialDevice extends VexSerialDevice {
constructor(defaultSerial: Serial) {
super(defaultSerial);

let isLastRefreshComplete: boolean = true;
setInterval(() => {
if (this.autoRefresh) {
if (this.autoRefresh && isLastRefreshComplete) {
if (!this.isConnected) {
this.state.brain.isAvailable = false;
return;
Expand All @@ -850,7 +851,8 @@ export class V5SerialDevice extends VexSerialDevice {
this.pauseRefreshOnFileTransfer &&
!this.state._isFileTransferring
) {
void this.refresh();
isLastRefreshComplete = false;
void this.refresh().finally(() => (isLastRefreshComplete = true));
}
}
}, 200);
Expand Down

0 comments on commit 01ef415

Please sign in to comment.