Skip to content

Commit

Permalink
Merge branch 'omp-jb53949' into 'master'
Browse files Browse the repository at this point in the history
[embedlite-components] Remove message listener if filepicker was cancelled. Contributes to JB#53949

See merge request mer-core/embedlite-components!130
  • Loading branch information
llewelld committed Jun 2, 2021
2 parents 82bd88a + 677ba59 commit 013be0a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jscomps/FilePicker.js
Expand Up @@ -248,7 +248,14 @@ FilePicker.prototype = {

this._promptActive = false;

if (!this._filePath) {
if (!this._filePath || !accepted) {
try {
this._callback.done(Ci.nsIFilePicker.returnCancel);
Services.embedlite.removeMessageListener("filepickerresponse", this);
delete this._callback;
} catch (e) {
Logger.warn("FilePicker: cancelling filepicker failed", e)
}
return;
}

Expand All @@ -265,8 +272,7 @@ FilePicker.prototype = {
promise.then(domFile => {
this._domFiles.push(domFile);
if (this._callback && (this._domFiles.length === this._filePath.length)) {
this._callback.done(this._filePath && accepted ?
Ci.nsIFilePicker.returnOK : Ci.nsIFilePicker.returnCancel);
this._callback.done(Ci.nsIFilePicker.returnOK);
Services.embedlite.removeMessageListener("filepickerresponse", this);
delete this._callback;
}
Expand Down

0 comments on commit 013be0a

Please sign in to comment.