Remove some unnecessary code
This commit is contained in:
parent
8e64670b4e
commit
aea779cfdf
55
client/js/libs/jquery/stickyscroll.js
vendored
55
client/js/libs/jquery/stickyscroll.js
vendored
@ -1,55 +0,0 @@
|
|||||||
import jQuery from "jquery";
|
|
||||||
|
|
||||||
(function($) {
|
|
||||||
$.fn.unsticky = function() {
|
|
||||||
return this.trigger("unstick.sticky").off(".sticky");
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.sticky = function() {
|
|
||||||
var self = this;
|
|
||||||
var stuckToBottom = true;
|
|
||||||
var lastStick = 0;
|
|
||||||
|
|
||||||
var keepToBottom = function() {
|
|
||||||
if (stuckToBottom) {
|
|
||||||
self.scrollBottom();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(window).on("resize.sticky", keepToBottom);
|
|
||||||
self
|
|
||||||
.on("unstick.sticky", function() {
|
|
||||||
$(window).off("resize.sticky", keepToBottom);
|
|
||||||
})
|
|
||||||
.on("scroll.sticky", function() {
|
|
||||||
// When resizing, sometimes the browser sends a bunch of extra scroll events due to content
|
|
||||||
// reflow, so if we resized within 250ms we can assume it's one of those. The order of said
|
|
||||||
// events is not predictable, and scroll can happen last, so not setting stuckToBottom is
|
|
||||||
// not enough, we have to force the scroll still.
|
|
||||||
if (stuckToBottom && Date.now() - lastStick < 250) {
|
|
||||||
self.scrollBottom();
|
|
||||||
} else {
|
|
||||||
stuckToBottom = self.isScrollBottom();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on("scrollBottom.sticky", function() {
|
|
||||||
stuckToBottom = true;
|
|
||||||
lastStick = Date.now();
|
|
||||||
this.scrollTop = this.scrollHeight;
|
|
||||||
})
|
|
||||||
.on("keepToBottom.sticky", keepToBottom)
|
|
||||||
.scrollBottom();
|
|
||||||
|
|
||||||
return self;
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.scrollBottom = function() {
|
|
||||||
this.trigger("scrollBottom.sticky");
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.isScrollBottom = function() {
|
|
||||||
var el = this[0];
|
|
||||||
return el.scrollHeight - el.scrollTop - el.offsetHeight <= 30;
|
|
||||||
};
|
|
||||||
})(jQuery);
|
|
@ -11,7 +11,6 @@ const {vueApp, findChannel} = require("./vue");
|
|||||||
|
|
||||||
window.vueMounted = () => {
|
window.vueMounted = () => {
|
||||||
require("./socket-events");
|
require("./socket-events");
|
||||||
require("./libs/jquery/stickyscroll");
|
|
||||||
const slideoutMenu = require("./slideout");
|
const slideoutMenu = require("./slideout");
|
||||||
const templates = require("../views");
|
const templates = require("../views");
|
||||||
const contextMenuFactory = require("./contextMenuFactory");
|
const contextMenuFactory = require("./contextMenuFactory");
|
||||||
@ -55,7 +54,6 @@ window.vueMounted = () => {
|
|||||||
const isOpen = !viewport.hasClass("userlist-open");
|
const isOpen = !viewport.hasClass("userlist-open");
|
||||||
|
|
||||||
viewport.toggleClass("userlist-open", isOpen);
|
viewport.toggleClass("userlist-open", isOpen);
|
||||||
chat.find(".chan.active .chat").trigger("keepToBottom");
|
|
||||||
storeSidebarVisibility("thelounge.state.userlist", isOpen);
|
storeSidebarVisibility("thelounge.state.userlist", isOpen);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -97,8 +95,6 @@ window.vueMounted = () => {
|
|||||||
// because some browsers tend to incorrently round the values when using high density
|
// because some browsers tend to incorrently round the values when using high density
|
||||||
// displays or using page zoom feature
|
// displays or using page zoom feature
|
||||||
this.style.height = Math.ceil(this.scrollHeight / lineHeight) * lineHeight + "px";
|
this.style.height = Math.ceil(this.scrollHeight / lineHeight) * lineHeight + "px";
|
||||||
|
|
||||||
chat.find(".chan.active .chat").trigger("keepToBottom"); // fix growing
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)) {
|
if (navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i)) {
|
||||||
@ -177,18 +173,6 @@ window.vueMounted = () => {
|
|||||||
lastActive
|
lastActive
|
||||||
.removeClass("active");
|
.removeClass("active");
|
||||||
|
|
||||||
/*const lastActiveChan = lastActive.find(".chan.active");
|
|
||||||
|
|
||||||
if (lastActiveChan.length > 0) {
|
|
||||||
lastActiveChan
|
|
||||||
.removeClass("active")
|
|
||||||
.find(".unread-marker")
|
|
||||||
.data("unread-id", 0)
|
|
||||||
.appendTo(lastActiveChan.find(".messages"));
|
|
||||||
|
|
||||||
render.trimMessageInChannel(lastActiveChan, 100);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
const chan = $(target)
|
const chan = $(target)
|
||||||
.addClass("active")
|
.addClass("active")
|
||||||
.trigger("show");
|
.trigger("show");
|
||||||
@ -205,8 +189,6 @@ window.vueMounted = () => {
|
|||||||
const chanChat = chan.find(".chat");
|
const chanChat = chan.find(".chat");
|
||||||
|
|
||||||
if (chanChat.length > 0 && type !== "special") {
|
if (chanChat.length > 0 && type !== "special") {
|
||||||
chanChat.sticky();
|
|
||||||
|
|
||||||
// On touch devices unfocus (blur) the input to correctly close the virtual keyboard
|
// On touch devices unfocus (blur) the input to correctly close the virtual keyboard
|
||||||
// An explicit blur is required, as the keyboard may open back up if the focus remains
|
// An explicit blur is required, as the keyboard may open back up if the focus remains
|
||||||
// See https://github.com/thelounge/thelounge/issues/2257
|
// See https://github.com/thelounge/thelounge/issues/2257
|
||||||
|
@ -102,8 +102,6 @@ function appendPreview(preview, msg, template) {
|
|||||||
if (activeChannelId === channelId) {
|
if (activeChannelId === channelId) {
|
||||||
// If this preview is in active channel, hide "More" button if necessary
|
// If this preview is in active channel, hide "More" button if necessary
|
||||||
previewContent.trigger("showMoreIfNeeded");
|
previewContent.trigger("showMoreIfNeeded");
|
||||||
|
|
||||||
container.trigger("keepToBottom");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const $ = require("jquery");
|
const $ = require("jquery");
|
||||||
const socket = require("../socket");
|
const socket = require("../socket");
|
||||||
const render = require("../render");
|
|
||||||
const utils = require("../utils");
|
const utils = require("../utils");
|
||||||
const options = require("../options");
|
const options = require("../options");
|
||||||
const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage");
|
const cleanIrcMessage = require("../libs/handlebars/ircmessageparser/cleanIrcMessage");
|
||||||
@ -23,6 +22,10 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.on("msg", function(data) {
|
socket.on("msg", function(data) {
|
||||||
|
if (utils.lastMessageId < data.msg.id) {
|
||||||
|
utils.lastMessageId = data.msg.id;
|
||||||
|
}
|
||||||
|
|
||||||
// We set a maximum timeout of 2 seconds so that messages don't take too long to appear.
|
// We set a maximum timeout of 2 seconds so that messages don't take too long to appear.
|
||||||
utils.requestIdleCallback(() => processReceivedMessage(data), 2000);
|
utils.requestIdleCallback(() => processReceivedMessage(data), 2000);
|
||||||
});
|
});
|
||||||
@ -54,7 +57,6 @@ function processReceivedMessage(data) {
|
|||||||
|
|
||||||
const scrollContainer = channelContainer.find(".chat");
|
const scrollContainer = channelContainer.find(".chat");
|
||||||
const container = channelContainer.find(".messages");
|
const container = channelContainer.find(".messages");
|
||||||
const activeChannelId = chat.find(".chan.active").data("id");
|
|
||||||
|
|
||||||
if (data.msg.type === "channel_list" || data.msg.type === "ban_list" || data.msg.type === "ignore_list") {
|
if (data.msg.type === "channel_list" || data.msg.type === "ban_list" || data.msg.type === "ignore_list") {
|
||||||
$(container).empty();
|
$(container).empty();
|
||||||
@ -62,10 +64,6 @@ function processReceivedMessage(data) {
|
|||||||
|
|
||||||
channel.channel.messages.push(data.msg);
|
channel.channel.messages.push(data.msg);
|
||||||
|
|
||||||
if (activeChannelId === targetId) {
|
|
||||||
scrollContainer.trigger("keepToBottom");
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyMessage(targetId, channelContainer, data);
|
notifyMessage(targetId, channelContainer, data);
|
||||||
|
|
||||||
let shouldMoveMarker = data.msg.self;
|
let shouldMoveMarker = data.msg.self;
|
||||||
@ -93,20 +91,6 @@ function processReceivedMessage(data) {
|
|||||||
.appendTo(container);
|
.appendTo(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
let messageLimit = 0;
|
|
||||||
|
|
||||||
if (activeChannelId !== targetId) {
|
|
||||||
// If message arrives in non active channel, keep only 100 messages
|
|
||||||
messageLimit = 100;
|
|
||||||
} else if (scrollContainer.isScrollBottom()) {
|
|
||||||
// If message arrives in active channel, keep 500 messages if scroll is currently at the bottom
|
|
||||||
messageLimit = 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messageLimit > 0) {
|
|
||||||
render.trimMessageInChannel(channelContainer, messageLimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((data.msg.type === "message" || data.msg.type === "action") && channel.channel.type === "channel") {
|
if ((data.msg.type === "message" || data.msg.type === "action") && channel.channel.type === "channel") {
|
||||||
const user = channel.channel.users.find((u) => u.nick === data.msg.from.nick);
|
const user = channel.channel.users.find((u) => u.nick === data.msg.from.nick);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user