mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1349538 - JSONView should not open more than 1 filePicker at the same time, r=honza
This commit is contained in:
parent
bc21c019f3
commit
2f37beddea
@ -51,10 +51,8 @@ var JsonView = {
|
||||
*/
|
||||
onSave: function (message) {
|
||||
JsonViewUtils.getTargetFile().then(file => {
|
||||
if (file) {
|
||||
JsonViewUtils.saveToFile(file, message.data);
|
||||
}
|
||||
});
|
||||
JsonViewUtils.saveToFile(file, message.data);
|
||||
}, () => {});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -19,11 +19,20 @@ const OPEN_FLAGS = {
|
||||
EXCL: parseInt("0x80", 16)
|
||||
};
|
||||
|
||||
let filePickerShown = false;
|
||||
|
||||
/**
|
||||
* Open File Save As dialog and let the user to pick proper file location.
|
||||
*/
|
||||
exports.getTargetFile = function () {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (filePickerShown) {
|
||||
reject(null);
|
||||
return;
|
||||
}
|
||||
|
||||
filePickerShown = true;
|
||||
|
||||
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
|
||||
let win = getMostRecentBrowserWindow();
|
||||
@ -34,10 +43,12 @@ exports.getTargetFile = function () {
|
||||
fp.filterIndex = 0;
|
||||
|
||||
fp.open(rv => {
|
||||
filePickerShown = false;
|
||||
|
||||
if (rv == Ci.nsIFilePicker.returnOK || rv == Ci.nsIFilePicker.returnReplace) {
|
||||
resolve(fp.file);
|
||||
} else {
|
||||
resolve(null);
|
||||
reject(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user