Remove scroll code from more event

This commit is contained in:
Pavel Djundik 2018-07-12 13:59:03 +03:00 committed by Pavel Djundik
parent a138237155
commit a5625ba203

View File

@ -1,17 +1,9 @@
"use strict";
const $ = require("jquery");
const socket = require("../socket");
const {vueApp, findChannel} = require("../vue");
const {findChannel} = require("../vue");
socket.on("more", function(data) {
let chan = $("#chat #chan-" + data.chan);
chan = chan.find(".messages");
// get the scrollable wrapper around messages
const scrollable = chan.closest(".chat");
const heightOld = chan.height() - scrollable.scrollTop();
const channel = findChannel(data.chan);
if (!channel) {
@ -21,10 +13,4 @@ socket.on("more", function(data) {
channel.channel.moreHistoryAvailable = data.moreHistoryAvailable;
channel.channel.messages.unshift(...data.messages);
channel.channel.historyLoading = false;
vueApp.$nextTick(() => {
// restore scroll position
const position = chan.height() - heightOld;
scrollable.finish().scrollTop(position);
});
});