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

This commit is contained in:
Julian Lam
2020-12-21 15:10:12 -05:00
parent 4919e5968d
commit e640a41a78
2 changed files with 7 additions and 20 deletions

View File

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

View File

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