Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion js/common/ble-file-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ class FileTransferClient extends BLEFileTransferClient {
constructor(bleDevice, bufferSize, workflow = null) {
super(bleDevice, bufferSize);
this._workflow = workflow;
this.fileChangeAttempts = 0;
}

_signalMutatingOp() {
// Even a failed operation may have changed the board's files.
this.fileChangeAttempts++;
if (this._workflow && typeof this._workflow.markMutatingOp === 'function') {
this._workflow.markMutatingOp();
}
Expand Down Expand Up @@ -100,4 +103,4 @@ class FileTransferClient extends BLEFileTransferClient {
}
}

export {FileTransferClient};
export {FileTransferClient};
8 changes: 5 additions & 3 deletions js/common/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ function getUrlParam(name, remove = true) {
}

// Switch to a new url with the current document state and reload the page if the host and path are the same
function switchUrl(url, documentState, backend = null) {
function switchUrl(url, documentState, backend = null, {preserveUnloadWarning = false} = {}) {
let params ={state: encodeURIComponent(JSON.stringify(documentState))}
if (backend) {
params.backend = backend;
}
let server = makeUrl(url, params);
let oldHost = window.location.host;
let oldPath = window.location.pathname;
window.onbeforeunload = () => {};
if (!preserveUnloadWarning) {
window.onbeforeunload = () => {};
}
window.location.href = server;
let serverUrl = new URL(server);
if (serverUrl.host == oldHost && serverUrl.pathname == oldPath) {
Expand Down Expand Up @@ -204,4 +206,4 @@ export {
readUploadedFileAsArrayBuffer,
loadSetting,
saveSetting
};
};
Loading