added methods and socket listeners for group joining and leaving, #2588
parent
501935d359
commit
9fa3675424
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
/* globals define, ajaxify, socket */
|
||||
|
||||
define('forum/groups/list', function() {
|
||||
var Groups = {};
|
||||
|
||||
Groups.init = function() {
|
||||
var groupsEl = $('.groups.row');
|
||||
|
||||
// Group joining and leaving
|
||||
groupsEl.on('click', '[data-action]', function() {
|
||||
var action = $(this).attr('data-action'),
|
||||
groupName = $(this).parents('[data-group]').attr('data-group');
|
||||
|
||||
socket.emit('groups.' + action, {
|
||||
groupName: groupName
|
||||
}, function(err) {
|
||||
if (!err) {
|
||||
ajaxify.refresh();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return Groups;
|
||||
});
|
@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var groups = require('../groups'),
|
||||
|
||||
SocketGroups = {};
|
||||
|
||||
SocketGroups.join = function(socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
groups.join(data.groupName, socket.uid, callback);
|
||||
};
|
||||
|
||||
SocketGroups.leave = function(socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
groups.leave(data.groupName, socket.uid, callback);
|
||||
};
|
||||
|
||||
module.exports = SocketGroups;
|
Loading…
Reference in New Issue