Skip to content

Node.js based forum software built for the modern web

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

Julian Lame640a41a7839
diff --git a/public/src/admin/manage/groups.js b/public/src/admin/manage/groups.js
index c61c64aaf0..b7b181776a 100644
--- a/public/src/admin/manage/groups.js
+++ b/public/src/admin/manage/groups.js
@@ -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;
diff --git a/public/src/client/groups/details.js b/public/src/client/groups/details.js
index 4680fa7171..3e804bbc84 100644
--- a/public/src/client/groups/details.js
+++ b/public/src/client/groups/details.js
@@ -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) {
- app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
- ajaxify.go('groups');
- } else {
- app.alertError(err.message);
- }
- });
+ api.del(`/groups/${slugify(groupName)}`, {}).then(() => {
+ app.alertSuccess('[[groups:event.deleted, ' + utils.escapeHTML(groupName) + ']]');
+ ajaxify.go('groups');
+ }).catch(app.alertError);
}
});
}