Skip to content

Commit 8704c70

Browse files
committed
Change the location of the macOS judgment
1 parent 7e5a93a commit 8704c70

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/js/protocols/WebSerial.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class WebSerial extends EventTarget {
5555
navigator.serial.addEventListener("connect", (e) => this.handleNewDevice(e.target));
5656
navigator.serial.addEventListener("disconnect", (e) => this.handleRemovedDevice(e.target));
5757
}
58-
this.isMac = /macintosh|mac os x/i.test(navigator.userAgent);
5958
this.isNeedBatchWrite = false;
6059
this.loadDevices();
6160
}
@@ -334,11 +333,12 @@ class WebSerial extends EventTarget {
334333
}
335334

336335
checkIsNeedBatchWrite() {
337-
return this.isMac && vendorIdNames[this.connectionInfo.usbVendorId] === "AT32";
336+
const isMac = /macintosh|mac os x/i.test(navigator.userAgent);
337+
return isMac && vendorIdNames[this.connectionInfo.usbVendorId] === "AT32";
338338
}
339339

340340
async batchWrite(data) {
341-
// AT32 on macOS requires smaller chunks (63 bytes) to work correctly due to
341+
// AT32 on macOS requires smaller chunks (63 bytes) to work correctly due to
342342
// USB buffer size limitations in the macOS implementation
343343
const batchWriteSize = 63;
344344
let remainingData = data;

0 commit comments

Comments
 (0)