Trying a better disconnect event

This commit is contained in:
Kasper Rynning-Tønnesen
2018-03-12 19:44:37 +01:00
parent 0df26727da
commit f337ad3197
2 changed files with 12 additions and 1 deletions

View File

@@ -374,6 +374,13 @@ module.exports = function() {
List.left_channel(coll, guid, short_id, in_list, socket, false); List.left_channel(coll, guid, short_id, in_list, socket, false);
}); });
socket.on("left_channel", function(msg) {
if(msg.hasOwnProperty("channel") && msg.channel != "" && typeof(msg.channel) == "string") {
coll = msg.channel;
List.left_channel(coll, guid, short_id, in_list, socket, false);
}
})
socket.on('reconnect_failed', function() socket.on('reconnect_failed', function()
{ {
List.left_channel(coll, guid, short_id, in_list, socket, false); List.left_channel(coll, guid, short_id, in_list, socket, false);

View File

@@ -536,6 +536,7 @@ var Channel = {
var host = window.location.hostname.split("."); var host = window.location.hostname.split(".");
window.location.hostname = host[host.length -1]; window.location.hostname = host[host.length -1];
}*/ }*/
var channel_before_move = chan.toLowerCase();
clearTimeout(timed_remove_check); clearTimeout(timed_remove_check);
changing_to_frontpage = true; changing_to_frontpage = true;
$.contextMenu( 'destroy', ".playlist-element" ); $.contextMenu( 'destroy', ".playlist-element" );
@@ -579,7 +580,10 @@ var Channel = {
//socket.emit("change_channel"); //socket.emit("change_channel");
//removeAllListeners(); //removeAllListeners();
//socket.removeEventListener(id); //socket.removeEventListener(id);
socket.disconnect(); socket.emit("left_channel", {
channel: channel_before_move
});
//socket.disconnect();
} else { } else {
socket.removeEventListener("chat.all"); socket.removeEventListener("chat.all");
socket.removeEventListener("chat"); socket.removeEventListener("chat");