mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-24 16:55:24 +03:00
Centralize timer cleanup
This commit is contained in:
parent
4d3f7b1c5f
commit
1a30f95176
1 changed files with 5 additions and 3 deletions
|
@ -461,9 +461,6 @@ const MSP = {
|
|||
return;
|
||||
}
|
||||
|
||||
// Clear the existing timer before retry
|
||||
clearTimeout(requestObj.timer);
|
||||
|
||||
serial.send(bufferOut, (sendInfo) => {
|
||||
if (sendInfo.bytesSent === bufferOut.byteLength) {
|
||||
requestObj.timer = setTimeout(() => {
|
||||
|
@ -480,6 +477,11 @@ const MSP = {
|
|||
},
|
||||
|
||||
_removeRequestFromCallbacks(requestObj) {
|
||||
// Clear the timer if it exists
|
||||
if (requestObj.timer) {
|
||||
clearTimeout(requestObj.timer);
|
||||
}
|
||||
|
||||
const index = this.callbacks.indexOf(requestObj);
|
||||
if (index > -1) {
|
||||
this.callbacks.splice(index, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue