Merge pull request #1549 from thelounge/xpaw/fix-default-chan
Fix opening first channel on server start
This commit is contained in:
commit
e165d51e60
@ -50,7 +50,7 @@ socket.on("init", function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function openCorrectChannel(clientActive, serverActive) {
|
function openCorrectChannel(clientActive, serverActive) {
|
||||||
let target;
|
let target = $();
|
||||||
|
|
||||||
// Open last active channel
|
// Open last active channel
|
||||||
if (clientActive > 0) {
|
if (clientActive > 0) {
|
||||||
@ -58,17 +58,22 @@ function openCorrectChannel(clientActive, serverActive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open window provided in location.hash
|
// 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) + "']");
|
target = $("#footer, #sidebar").find("[data-target='" + escape(window.location.hash) + "']");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open last active channel according to the server
|
// Open last active channel according to the server
|
||||||
if (!target) {
|
if (serverActive > 0 && target.length === 0) {
|
||||||
target = sidebar.find("[data-id='" + serverActive + "']");
|
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 channel is found, open it
|
||||||
if (target) {
|
if (target.length > 0) {
|
||||||
target.trigger("click", {
|
target.trigger("click", {
|
||||||
replaceHistory: true
|
replaceHistory: true
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ Chan.Type = {
|
|||||||
SPECIAL: "special",
|
SPECIAL: "special",
|
||||||
};
|
};
|
||||||
|
|
||||||
var id = 0;
|
let id = 1;
|
||||||
|
|
||||||
function Chan(attr) {
|
function Chan(attr) {
|
||||||
_.defaults(this, attr, {
|
_.defaults(this, attr, {
|
||||||
|
@ -5,7 +5,7 @@ var Chan = require("./chan");
|
|||||||
|
|
||||||
module.exports = Network;
|
module.exports = Network;
|
||||||
|
|
||||||
var id = 0;
|
let id = 1;
|
||||||
|
|
||||||
function Network(attr) {
|
function Network(attr) {
|
||||||
_.defaults(this, attr, {
|
_.defaults(this, attr, {
|
||||||
|
Loading…
Reference in New Issue
Block a user