mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(client) refresh: promisify
This commit is contained in:
parent
9ff5982a5b
commit
1b174d5f2f
3 changed files with 13 additions and 12 deletions
|
|
@ -7,6 +7,7 @@ const inherits = require('inherits');
|
|||
const rendy = require('rendy/legacy');
|
||||
const exec = require('execon');
|
||||
const load = require('load.js');
|
||||
const {promisify} = require('es6-promisify');
|
||||
|
||||
const pascalCase = require('just-pascal-case');
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
|
|
@ -318,7 +319,7 @@ function CloudCmdProto(DOM) {
|
|||
func(...args);
|
||||
};
|
||||
|
||||
this.refresh = (options = {}, callback) => {
|
||||
this.refresh = promisify((options = {}, callback) => {
|
||||
if (!callback && typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
|
|
@ -340,7 +341,7 @@ function CloudCmdProto(DOM) {
|
|||
noCurrent,
|
||||
currentName,
|
||||
}, callback);
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Функция загружает json-данные о Файловой Системе
|
||||
|
|
|
|||
|
|
@ -319,15 +319,15 @@ function deleteSilent(files = DOM.getActiveFiles()) {
|
|||
const currentName = DOM.getCurrentName();
|
||||
const nextCurrentName = getNextCurrentName(currentName, names, removedNames);
|
||||
|
||||
deleteFn(path + query, removedNames, () => {
|
||||
CloudCmd.refresh(() => {
|
||||
const names = Info.files.map(DOM.getCurrentName);
|
||||
const isCurrent = names.includes(currentName);
|
||||
|
||||
const name = isCurrent ? currentName : nextCurrentName;
|
||||
|
||||
DOM.setCurrentByName(name);
|
||||
});
|
||||
deleteFn(path + query, removedNames, async () => {
|
||||
await CloudCmd.refresh();
|
||||
|
||||
const names = Info.files.map(DOM.getCurrentName);
|
||||
const isCurrent = names.includes(currentName);
|
||||
|
||||
const name = isCurrent ? currentName : nextCurrentName;
|
||||
|
||||
DOM.setCurrentByName(name);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
if (e)
|
||||
return Dialog.alert(e);
|
||||
|
||||
await tryToPromisify(CloudCmd.refresh);
|
||||
await CloudCmd.refresh();
|
||||
DOM.setCurrentByName('.cloudcmd.menu.js');
|
||||
|
||||
await CloudCmd.EditFile.show();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue