Skip to content

Commit fc5842a

Browse files
WebUSB: return promise during disconnection.
1 parent f2ff704 commit fc5842a

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

python-main.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ function web_editor(config) {
14621462
$('#flashing-overlay').keydown(function(e) {
14631463
if (e.which == 27) {
14641464
flashErrorClose();
1465-
}
1465+
}
14661466
});
14671467

14681468
// Send event
@@ -1498,17 +1498,13 @@ function web_editor(config) {
14981498

14991499
var p = Promise.resolve();
15001500

1501-
if (usePartialFlashing) {
1502-
if (window.dapwrapper) {
1503-
console.log("Disconnecting: Using Quick Flash");
1504-
p = p.then(function() { window.dapwrapper.disconnectAsync() } );
1505-
}
1501+
if (usePartialFlashing && window.dapwrapper) {
1502+
console.log('Disconnecting: Using Quick Flash');
1503+
p = p.then(function() { return window.dapwrapper.disconnectAsync() });
15061504
}
1507-
else {
1508-
if (window.daplink) {
1509-
console.log("Disconnecting: Using Full Flash");
1510-
p = p.then(function() { window.daplink.disconnect() } );
1511-
}
1505+
else if (window.daplink) {
1506+
console.log('Disconnecting: Using Full Flash');
1507+
p = p.then(function() { return window.daplink.disconnect() });
15121508
}
15131509

15141510
p.finally(function() {
@@ -1615,15 +1611,15 @@ function web_editor(config) {
16151611

16161612
function closeSerial(keepSession) {
16171613
console.log("Closing Serial Terminal");
1618-
$("#repl").empty();
1619-
$("#repl").hide();
1620-
$("#request-repl").hide();
1621-
$("#request-serial").hide();
1622-
$("#editor-container").show();
1614+
$('#repl').empty();
1615+
$('#repl').hide();
1616+
$('#request-repl').hide();
1617+
$('#request-serial').hide();
1618+
$('#editor-container').show();
16231619

1624-
var serialButton = config["translate"]["static-strings"]["buttons"]["command-serial"];
1625-
$("#command-serial").attr("title", serialButton["title"]);
1626-
$("#command-serial > .roundlabel").text(serialButton["label"]);
1620+
var serialButton = config['translate']['static-strings']['buttons']['command-serial'];
1621+
$('#command-serial').attr('title', serialButton['title']);
1622+
$('#command-serial > .roundlabel').text(serialButton['label']);
16271623

16281624
var daplink = usePartialFlashing ? window.dapwrapper.daplink : window.daplink;
16291625
daplink.stopSerialRead();
@@ -1737,8 +1733,8 @@ function web_editor(config) {
17371733
$(overlayContainer).keydown(function(e) {
17381734
if (e.which == 27) {
17391735
modalMsgClose();
1740-
}
1741-
});
1736+
}
1737+
});
17421738
}
17431739

17441740
function formatMenuContainer(parentButtonId, containerId) {

0 commit comments

Comments
 (0)