try usng a promise

Former-commit-id: b39126fdd9a4d600741661e85e73e36c3b86bf8e
This commit is contained in:
Henrique Dias
2017-01-03 15:58:45 +00:00
parent f1f248e4d6
commit 4c4d80166c
2 changed files with 25 additions and 23 deletions

View File

@@ -130,23 +130,24 @@ listing.rename = function(event) {
let newName = event.currentTarget.querySelector('input').value,
newLink = removeLastDirectoryPartOf(link) + "/" + newName,
html = buttons.rename.querySelector('i').changeToLoading();
closePrompt(event);
webdav.rename(link, newLink, success => {
if (success) {
webdav.move(link, newLink)
.then(data => {
listing.reload(() => {
newName = btoa(newName);
selectedItems = [newName];
document.getElementById(newName).setAttribute("aria-selected", true);
listing.handleSelectionChange();
});
} else {
item.querySelector('.name').innerHTML = name;
}
closePrompt(event);
buttons.rename.querySelector('i').changeToDone(!success, html);
});
buttons.rename.querySelector('i').changeToDone(false, html);
})
.catch(error => {
item.querySelector('.name').innerHTML = name;
buttons.rename.querySelector('i').changeToDone(true, html);
});
return false;
}