fix: use promises in privilege save

... instead of jQuery Deferreds
v1.18.x
Julian Lam 5 years ago
parent 7a5daff4c9
commit 9cbe9389f5

@ -115,7 +115,7 @@ define('admin/manage/privileges', [
return Privileges.setPrivilege(member, privilege, state);
});
$.when(requests).done(function () {
Promise.allSettled(requests).then(function () {
Privileges.refreshPrivilegeTable();
app.alertSuccess('[[admin/manage/privileges:alert.saved]]');
});
@ -180,23 +180,21 @@ define('admin/manage/privileges', [
};
Privileges.setPrivilege = function (member, privilege, state) {
var deferred = $.Deferred();
socket.emit('admin.categories.setPrivilege', {
cid: isNaN(cid) ? 0 : cid,
privilege: privilege,
set: state,
member: member,
}, function (err) {
if (err) {
deferred.reject(err);
return app.alertError(err.message);
}
return new Promise(function (resolve, reject) {
socket.emit('admin.categories.setPrivilege', {
cid: isNaN(cid) ? 0 : cid,
privilege: privilege,
set: state,
member: member,
}, function (err) {
if (err) {
reject(err);
return app.alertError(err.message);
}
deferred.resolve();
resolve();
});
});
return deferred.promise();
};
Privileges.addUserToPrivilegeTable = function () {

Loading…
Cancel
Save