mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-25 17:04:16 +00:00
refactor(edit-names) refresh
This commit is contained in:
parent
5ec7d838ac
commit
84478220e9
1 changed files with 16 additions and 11 deletions
|
|
@ -5,12 +5,15 @@
|
|||
const currify = require('currify/legacy');
|
||||
const exec = require('execon');
|
||||
|
||||
const reject = Promise.reject.bind(Promise);
|
||||
|
||||
CloudCmd.EditNames = function EditNamesProto(callback) {
|
||||
const Info = DOM.CurrentInfo;
|
||||
const Dialog = DOM.Dialog;
|
||||
|
||||
const TITLE = 'Edit Names';
|
||||
const alert = currify(Dialog.alert, TITLE);
|
||||
const refresh = currify(_refresh);
|
||||
|
||||
const EditNames = this;
|
||||
let Menu, MenuIO;
|
||||
|
|
@ -98,21 +101,23 @@ CloudCmd.EditNames = function EditNamesProto(callback) {
|
|||
.getValue()
|
||||
.split('\n');
|
||||
|
||||
const reject = Promise.reject.bind(Promise);
|
||||
const root = CloudCmd.config('root');
|
||||
|
||||
Promise.resolve(root)
|
||||
.then(rename(dir, from, to))
|
||||
.then((res) => {
|
||||
if (res.status === 404)
|
||||
return res.text().then(reject);
|
||||
|
||||
const currentName = to[nameIndex];
|
||||
|
||||
CloudCmd.refresh({
|
||||
currentName
|
||||
});
|
||||
}).catch(alert);
|
||||
.then(refresh(to, nameIndex))
|
||||
.catch(alert);
|
||||
}
|
||||
|
||||
function _refresh(to, nameIndex, res) {
|
||||
if (res.status === 404)
|
||||
return res.text().then(reject);
|
||||
|
||||
const currentName = to[nameIndex];
|
||||
|
||||
CloudCmd.refresh({
|
||||
currentName
|
||||
});
|
||||
}
|
||||
|
||||
function getDir(root, dir) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue