Merge pull request #1549 from thelounge/xpaw/fix-default-chan

Fix opening first channel on server start
This commit is contained in:
Jérémie Astori 2017-09-20 21:30:24 -04:00 committed by GitHub
commit e165d51e60
3 changed files with 11 additions and 6 deletions

View file

@ -50,7 +50,7 @@ socket.on("init", function(data) {
});
function openCorrectChannel(clientActive, serverActive) {
let target;
let target = $();
// Open last active channel
if (clientActive > 0) {
@ -58,17 +58,22 @@ function openCorrectChannel(clientActive, serverActive) {
}
// Open window provided in location.hash
if (!target && window.location.hash) {
if (target.length === 0 && window.location.hash) {
target = $("#footer, #sidebar").find("[data-target='" + escape(window.location.hash) + "']");
}
// Open last active channel according to the server
if (!target) {
if (serverActive > 0 && target.length === 0) {
target = sidebar.find("[data-id='" + serverActive + "']");
}
// Open first available channel
if (target.length === 0) {
target = sidebar.find(".chan").first();
}
// If target channel is found, open it
if (target) {
if (target.length > 0) {
target.trigger("click", {
replaceHistory: true
});

View file

@ -14,7 +14,7 @@ Chan.Type = {
SPECIAL: "special",
};
var id = 0;
let id = 1;
function Chan(attr) {
_.defaults(this, attr, {

View file

@ -5,7 +5,7 @@ var Chan = require("./chan");
module.exports = Network;
var id = 0;
let id = 1;
function Network(attr) {
_.defaults(this, attr, {