mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-01 20:22:29 +00:00
feature(dialog) cancel -> tryToCatch
This commit is contained in:
parent
7e98ad725d
commit
ef38bd7aa3
7 changed files with 58 additions and 47 deletions
|
|
@ -255,7 +255,7 @@ Operation.extract = () => {
|
|||
*
|
||||
* @currentFile
|
||||
*/
|
||||
function promptDelete() {
|
||||
async function promptDelete() {
|
||||
if (noFilesCheck())
|
||||
return;
|
||||
|
||||
|
|
@ -291,11 +291,12 @@ function promptDelete() {
|
|||
msg = msgAsk + msgSel + type + name + '?';
|
||||
}
|
||||
|
||||
const cancel = false;
|
||||
const [cancel] = await Dialog.confirm(msg);
|
||||
|
||||
Dialog.confirm(msg, {cancel}).then(() => {
|
||||
deleteSilent(files);
|
||||
});
|
||||
if (cancel)
|
||||
return;
|
||||
|
||||
deleteSilent(files);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -380,9 +381,12 @@ function _processFiles(options, data) {
|
|||
const title = isCopy ? 'Copy' : 'Rename/Move';
|
||||
const operation = isCopy ? copyFn : moveFn;
|
||||
|
||||
if (shouldAsk && config(option))
|
||||
return message(title, to, names.map(encode))
|
||||
.then(ask);
|
||||
if (shouldAsk && config(option)) {
|
||||
const [cancel, to] = message(title, to, names.map(encode));
|
||||
|
||||
if (!cancel)
|
||||
ask(to);
|
||||
}
|
||||
|
||||
ask(to);
|
||||
|
||||
|
|
@ -492,7 +496,7 @@ function twopack(operation, type) {
|
|||
});
|
||||
}
|
||||
|
||||
function message(msg, to, names) {
|
||||
async function message(msg, to, names) {
|
||||
const n = names.length;
|
||||
const [name] = names;
|
||||
|
||||
|
|
@ -505,9 +509,7 @@ function message(msg, to, names) {
|
|||
|
||||
msg += ' to';
|
||||
|
||||
const cancel = false;
|
||||
|
||||
return Dialog.prompt(msg, to, {cancel});
|
||||
return Dialog.prompt(msg, to);
|
||||
}
|
||||
|
||||
function load(callback) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ module.exports = (options) => (emitter) => {
|
|||
callback();
|
||||
},
|
||||
|
||||
error: (error) => {
|
||||
error: async (error) => {
|
||||
lastError = error;
|
||||
|
||||
if (noContinue) {
|
||||
|
|
@ -71,13 +71,13 @@ module.exports = (options) => (emitter) => {
|
|||
return;
|
||||
}
|
||||
|
||||
Dialog.confirm(error + '\n Continue?')
|
||||
.then(() => {
|
||||
emitter.continue();
|
||||
}, () => {
|
||||
emitter.abort();
|
||||
progress.remove();
|
||||
});
|
||||
const [cancel] = await Dialog.confirm(error + '\n Continue?');
|
||||
|
||||
if (!cancel)
|
||||
emitter.continue();
|
||||
|
||||
emitter.abort();
|
||||
progress.remove();
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue