refactor(api): update group deletion calls to use write API

v1.18.x
Julian Lam 4 years ago
parent 4919e5968d
commit e640a41a78

@ -2,8 +2,9 @@
define('admin/manage/groups', [ define('admin/manage/groups', [
'categorySelector', 'categorySelector',
'slugify',
'api', 'api',
], function (categorySelector, api) { ], function (categorySelector, slugify, api) {
var Groups = {}; var Groups = {};
var intervalId = 0; var intervalId = 0;
@ -61,15 +62,7 @@ define('admin/manage/groups', [
case 'delete': case 'delete':
bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) { bootbox.confirm('[[admin/manage/groups:alerts.confirm-delete]]', function (confirm) {
if (confirm) { if (confirm) {
socket.emit('groups.delete', { api.del(`/groups/${slugify(groupName)}`, {}).then(ajaxify.refresh).catch(app.alertError);
groupName: groupName,
}, function (err) {
if (err) {
return app.alertError(err.message);
}
ajaxify.refresh();
});
} }
}); });
break; break;

@ -229,16 +229,10 @@ define('forum/groups/details', [
if (confirm) { if (confirm) {
bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) { bootbox.prompt('Please enter the name of this group in order to delete it:', function (response) {
if (response === groupName) { if (response === groupName) {
socket.emit('groups.delete', { api.del(`/groups/${slugify(groupName)}`, {}).then(() => {
groupName: groupName,
}, function (err) {
if (!err) {
app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]'); app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
ajaxify.go('groups'); ajaxify.go('groups');
} else { }).catch(app.alertError);
app.alertError(err.message);
}
});
} }
}); });
} }

Loading…
Cancel
Save