Merge pull request #1739 from thelounge/xpaw/inactive-scroll
Do not keep scroll to bottom in inactive channels
This commit is contained in:
commit
5ffeb04343
@ -4,6 +4,7 @@ const $ = require("jquery");
|
|||||||
const options = require("./options");
|
const options = require("./options");
|
||||||
const socket = require("./socket");
|
const socket = require("./socket");
|
||||||
const templates = require("../views");
|
const templates = require("../views");
|
||||||
|
const chat = $("#chat");
|
||||||
const input = $("#input");
|
const input = $("#input");
|
||||||
const Mousetrap = require("mousetrap");
|
const Mousetrap = require("mousetrap");
|
||||||
|
|
||||||
@ -29,8 +30,11 @@ function renderPreview(preview, msg) {
|
|||||||
preview.shown = preview.shown && options.shouldOpenMessagePreview(preview.type);
|
preview.shown = preview.shown && options.shouldOpenMessagePreview(preview.type);
|
||||||
|
|
||||||
const container = msg.closest(".chat");
|
const container = msg.closest(".chat");
|
||||||
|
const channelId = container.data("id");
|
||||||
|
const activeChannelId = chat.find(".chan.active").data("id");
|
||||||
|
|
||||||
let bottom = false;
|
let bottom = false;
|
||||||
if (container.length) {
|
if (container.length && activeChannelId === channelId) {
|
||||||
bottom = container.isScrollBottom();
|
bottom = container.isScrollBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,12 +45,14 @@ function renderPreview(preview, msg) {
|
|||||||
previewContainer
|
previewContainer
|
||||||
.append(templates.msg_preview({preview: preview}));
|
.append(templates.msg_preview({preview: preview}));
|
||||||
|
|
||||||
|
if (activeChannelId === channelId) {
|
||||||
if (preview.shown && bottom) {
|
if (preview.shown && bottom) {
|
||||||
handleImageInPreview(msg.find(".toggle-content"), container);
|
handleImageInPreview(msg.find(".toggle-content"), container);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.trigger("keepToBottom");
|
container.trigger("keepToBottom");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$("#chat").on("click", ".text .toggle-button", function() {
|
$("#chat").on("click", ".text .toggle-button", function() {
|
||||||
const self = $(this);
|
const self = $(this);
|
||||||
|
@ -46,7 +46,9 @@ function processReceivedMessage(data) {
|
|||||||
data.msg
|
data.msg
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (activeChannelId === targetId) {
|
||||||
container.trigger("keepToBottom");
|
container.trigger("keepToBottom");
|
||||||
|
}
|
||||||
|
|
||||||
notifyMessage(targetId, channel, data);
|
notifyMessage(targetId, channel, data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user