mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
feature(dialog) cancel -> tryToCatch
This commit is contained in:
parent
7e98ad725d
commit
ef38bd7aa3
7 changed files with 58 additions and 47 deletions
|
|
@ -180,17 +180,18 @@ function setMsgChanged(name) {
|
|||
|
||||
module.exports.isChanged = isChanged;
|
||||
|
||||
function isChanged() {
|
||||
async function isChanged() {
|
||||
const editor = CloudCmd.Edit.getEditor();
|
||||
const is = editor.isChanged();
|
||||
|
||||
if (!is)
|
||||
return;
|
||||
|
||||
const cancel = false;
|
||||
Dialog.confirm(MSG_CHANGED, {cancel})
|
||||
.then(() => {
|
||||
editor.save();
|
||||
});
|
||||
const [cancel] = await Dialog.confirm(MSG_CHANGED);
|
||||
|
||||
if (cancel)
|
||||
return;
|
||||
|
||||
editor.save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
CloudCmd.EditNames = exports;
|
||||
|
||||
const smalltalk = require('smalltalk');
|
||||
const currify = require('currify/legacy');
|
||||
const exec = require('execon');
|
||||
const supermenu = require('supermenu');
|
||||
|
|
@ -69,7 +70,7 @@ function keyListener(event) {
|
|||
EditNames.hide();
|
||||
|
||||
else if (ctrlMeta && event.keyCode === Key.P)
|
||||
Dialog
|
||||
smalltalk
|
||||
.prompt('Apply pattern:', '[n][e]', {cancel: false})
|
||||
.then(applyPattern);
|
||||
|
||||
|
|
|
|||
|
|
@ -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