mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-09-10 07:49:16 +02:00
refactor: api module returns promise, error-first cb if cb passed in
no more separate onSuccess onError callbacks /cc @baris
This commit is contained in:
@@ -106,13 +106,14 @@ define('forum/groups/details', [
|
||||
break;
|
||||
|
||||
case 'join': // intentional fall-throughs!
|
||||
api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined, () => ajaxify.refresh(), 'default');
|
||||
api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh());
|
||||
break;
|
||||
|
||||
case 'leave':
|
||||
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined, () => ajaxify.refresh(), 'default');
|
||||
api.del('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined).then(() => ajaxify.refresh());
|
||||
break;
|
||||
|
||||
// TODO (14/10/2020): rewrite these to use api module and merge with above 2 case blocks
|
||||
case 'accept': // intentional fall-throughs!
|
||||
case 'reject':
|
||||
case 'issueInvite':
|
||||
|
||||
@@ -14,9 +14,9 @@ define('forum/groups/list', [
|
||||
if (name && name.length) {
|
||||
api.post('/groups', {
|
||||
name: name,
|
||||
}, (res) => {
|
||||
}).then((res) => {
|
||||
ajaxify.go('groups/' + res.slug);
|
||||
}, 'default');
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -82,13 +82,7 @@ define('forum/groups/memberlist', ['api'], function (api) {
|
||||
if (groupName === 'administrators') {
|
||||
socket.emit('admin.user.makeAdmins', uids, done);
|
||||
} else {
|
||||
var requests = uids.map(function (uid) {
|
||||
return api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + uid);
|
||||
});
|
||||
|
||||
$.when(requests)
|
||||
.done(done)
|
||||
.fail('default');
|
||||
Promise.all(uids.map(uid => api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + uid))).then(done);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user