re: issue #652, this took longer than expected...

v1.18.x
Julian Lam 11 years ago
parent 45e7d64aeb
commit 69c1ec97c9

@ -51,6 +51,32 @@ var socket,
reconnectEl.html('<i class="fa fa-check"></i>');
reconnecting = false;
// Rejoin room that was left when we disconnected
var url_parts = document.location.pathname.slice(RELATIVE_PATH.length).split('/').slice(1),
room;
switch(url_parts[0]) {
case 'user':
room = 'user/' + templates.get('theirid');
case 'topic':
room = 'topic_' + url_parts[1];
break;
case 'category':
room = 'category_' + url_parts[1];
break;
case 'recent': // intentional fall-through
case 'unread':
room = 'recent_posts';
break;
case 'admin':
room = 'admin';
break;
default:
room = 'global';
break;
}
app.enterRoom(room, true);
setTimeout(function() {
reconnectEl.removeClass('active');
}, 3000);
@ -248,9 +274,9 @@ var socket,
});
};
app.enterRoom = function (room) {
app.enterRoom = function (room, force) {
if (socket) {
if (app.currentRoom === room) {
if (app.currentRoom === room && !force) {
return;
}

@ -163,9 +163,8 @@ websockets.init = function(io) {
return anonCount;
}
var uids = getUidsInRoom(rooms[roomName]);
var anonymousCount = getAnonymousCount(roomName);
var uids = getUidsInRoom(rooms[roomName]),
anonymousCount = getAnonymousCount(roomName);
if (uids.length === 0) {
io.sockets.in(roomName).emit('api:get_users_in_room', { users: [], anonymousCount: anonymousCount });
@ -184,19 +183,19 @@ websockets.init = function(io) {
}
socket.join(data.enter);
rooms[data.enter] = rooms[data.enter] || {};
if (uid) {
rooms[data.enter][socket.id] = uid;
if (data.leave && rooms[data.leave] && rooms[data.leave][socket.id]) {
if (data.leave && rooms[data.leave] && rooms[data.leave][socket.id] && data.enter !== data.leave) {
delete rooms[data.leave][socket.id];
}
}
if (data.leave)
if (data.leave) {
updateRoomBrowsingText(data.leave);
}
updateRoomBrowsingText(data.enter);

Loading…
Cancel
Save