refactor(client) refresh: promisify

This commit is contained in:
coderaiser 2019-05-17 19:19:51 +03:00
parent 9ff5982a5b
commit 1b174d5f2f
3 changed files with 13 additions and 12 deletions

View file

@ -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-данные о Файловой Системе

View file

@ -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);
});
}

View file

@ -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();