-
-
+
+
-
+
diff --git a/client/components/ChatInput.vue b/client/components/ChatInput.vue
new file mode 100644
index 00000000..0cc2337e
--- /dev/null
+++ b/client/components/ChatInput.vue
@@ -0,0 +1,43 @@
+
+
+
+
+
diff --git a/client/js/libs/handlebars/diff.js b/client/js/libs/handlebars/diff.js
deleted file mode 100644
index fe463895..00000000
--- a/client/js/libs/handlebars/diff.js
+++ /dev/null
@@ -1,12 +0,0 @@
-"use strict";
-
-let diff;
-
-module.exports = function(a, opt) {
- if (a !== diff) {
- diff = a;
- return opt.fn(this);
- }
-
- return opt.inverse(this);
-};
diff --git a/client/js/lounge.js b/client/js/lounge.js
index 1a941ae5..4964336c 100644
--- a/client/js/lounge.js
+++ b/client/js/lounge.js
@@ -9,7 +9,6 @@ require("./libs/jquery/stickyscroll");
const slideoutMenu = require("./slideout");
const templates = require("../views");
const socket = require("./socket");
-const render = require("./render");
require("./socket-events");
const storage = require("./localStorage");
const utils = require("./utils");
@@ -232,7 +231,7 @@ $(function() {
const type = chan.data("type");
if (self.hasClass("chan")) {
- $("#chat-container").addClass("active");
+ vueApp.$nextTick(() => $("#chat-container").addClass("active"));
}
const chanChat = chan.find(".chat");
diff --git a/client/js/render.js b/client/js/render.js
index 51b75b9b..a67be131 100644
--- a/client/js/render.js
+++ b/client/js/render.js
@@ -8,23 +8,11 @@ const utils = require("./utils");
const constants = require("./constants");
const condensed = require("./condensed");
const JoinChannel = require("./join-channel");
-const helpers_parse = require("./libs/handlebars/parse");
-const Userlist = require("./userlist");
const storage = require("./localStorage");
const {vueApp} = require("./vue");
-
-const chat = $("#chat");
const sidebar = $("#sidebar");
-require("intersection-observer");
-
-const historyObserver = window.IntersectionObserver ?
- new window.IntersectionObserver(loadMoreHistory, {
- root: chat.get(0),
- }) : null;
-
module.exports = {
- renderChannel,
renderNetworks,
trimMessageInChannel,
};
@@ -124,24 +112,6 @@ function buildChatMessage(msg) {
return renderedMessage;
}
-function renderChannel(data) {
- renderChannelMessages(data);
-
- if (data.type === "channel") {
- //const users = renderChannelUsers(data);
-
- //Userlist.handleKeybinds(users.find(".search"));
- }
-
- if (historyObserver) {
- //historyObserver.observe(chat.find("#chan-" + data.id + " .show-more").get(0));
- }
-}
-
-function renderChannelMessages(data) {
- const channel = chat.find("#chan-" + data.id + " .messages");
-}
-
function renderNetworks(data, singleNetwork) {
const collapsed = new Set(JSON.parse(storage.get("thelounge.networks.collapsed")));
@@ -187,8 +157,6 @@ function renderNetworks(data, singleNetwork) {
if (newChannels.length > 0) {
newChannels.forEach((channel) => {
- renderChannel(channel);
-
if (channel.type === "channel") {
channel.usersOutdated = true;
}
@@ -227,22 +195,6 @@ function trimMessageInChannel(channel, messageLimit) {
});
}
-function loadMoreHistory(entries) {
- entries.forEach((entry) => {
- if (!entry.isIntersecting) {
- return;
- }
-
- const target = $(entry.target).find("button");
-
- if (target.prop("disabled")) {
- return;
- }
-
- target.trigger("click");
- });
-}
-
sidebar.on("click", "button.collapse-network", (e) => collapseNetwork($(e.target)));
function collapseNetwork(target) {
diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js
index b673f857..68fcde78 100644
--- a/client/js/socket-events/init.js
+++ b/client/js/socket-events/init.js
@@ -9,7 +9,7 @@ const slideoutMenu = require("../slideout");
const sidebar = $("#sidebar");
const storage = require("../localStorage");
const utils = require("../utils");
-const {Vue, vueApp} = require("../vue");
+const {vueApp} = require("../vue");
socket.on("init", function(data) {
$("#loading-page-message, #connection-error").text("Rendering…");
@@ -24,7 +24,7 @@ socket.on("init", function(data) {
vueApp.networks = data.networks;
if (data.networks.length > 0) {
- Vue.nextTick(() => render.renderNetworks(data));
+ vueApp.$nextTick(() => render.renderNetworks(data));
}
$("#connection-error").removeClass("shown");
@@ -66,7 +66,7 @@ socket.on("init", function(data) {
}
}
- Vue.nextTick(() => openCorrectChannel(previousActive, data.active));
+ vueApp.$nextTick(() => openCorrectChannel(previousActive, data.active));
});
function openCorrectChannel(clientActive, serverActive) {
diff --git a/client/js/socket-events/join.js b/client/js/socket-events/join.js
index bd595d7c..77b46283 100644
--- a/client/js/socket-events/join.js
+++ b/client/js/socket-events/join.js
@@ -2,23 +2,19 @@
const $ = require("jquery");
const socket = require("../socket");
-const render = require("../render");
-const templates = require("../../views");
const sidebar = $("#sidebar");
-const {Vue, vueApp} = require("../vue");
+const {vueApp} = require("../vue");
socket.on("join", function(data) {
vueApp.networks.find((n) => n.uuid === data.network)
.channels.splice(data.index || -1, 0, data.chan);
- Vue.nextTick(() => render.renderChannel(data.chan));
-
// Queries do not automatically focus, unless the user did a whois
if (data.chan.type === "query" && !data.shouldOpen) {
return;
}
- Vue.nextTick(() => {
+ vueApp.$nextTick(() => {
sidebar.find(".chan")
.sort(function(a, b) {
return $(a).data("id") - $(b).data("id");
diff --git a/client/js/socket-events/more.js b/client/js/socket-events/more.js
index e3ab8719..fe6564e0 100644
--- a/client/js/socket-events/more.js
+++ b/client/js/socket-events/more.js
@@ -2,13 +2,11 @@
const $ = require("jquery");
const socket = require("../socket");
-const render = require("../render");
const condensed = require("../condensed");
-const chat = $("#chat");
-const {Vue, vueApp, findChannel} = require("../vue");
+const {vueApp, findChannel} = require("../vue");
socket.on("more", function(data) {
- let chan = chat.find("#chan-" + data.chan);
+ let chan = $("#chat #chan-" + data.chan);
const type = chan.data("type");
chan = chan.find(".messages");
@@ -29,8 +27,9 @@ socket.on("more", function(data) {
}
channel.channel.messages.unshift(...data.messages);
+ channel.channel.historyLoading = false;
- Vue.nextTick(() => {
+ vueApp.$nextTick(() => {
// restore scroll position
const position = chan.height() - heightOld;
scrollable.finish().scrollTop(position);
@@ -40,11 +39,6 @@ socket.on("more", function(data) {
scrollable.find(".show-more").removeClass("show");
}
- // Swap button text back from its alternative label
- const showMoreBtn = scrollable.find(".show-more button");
- swapText(showMoreBtn);
- showMoreBtn.prop("disabled", false);
-
return;
// Join duplicate condensed messages together
@@ -62,28 +56,3 @@ socket.on("more", function(data) {
condensedDuplicate.remove();
}
});
-
-chat.on("click", ".show-more button", function() {
- const self = $(this);
- const lastMessage = self.closest(".chat").find(".msg:not(.condensed)").first();
- let lastMessageId = -1;
-
- if (lastMessage.length > 0) {
- lastMessageId = parseInt(lastMessage.prop("id").replace("msg-", ""), 10);
- }
-
- // Swap button text with its alternative label
- swapText(self);
- self.prop("disabled", true);
-
- socket.emit("more", {
- target: self.data("id"),
- lastId: lastMessageId,
- });
-});
-
-// Given a button, swap its text with the content of `data-alt-text`
-function swapText(btn) {
- const altText = btn.data("alt-text");
- btn.data("alt-text", btn.text()).text(altText);
-}
diff --git a/client/js/socket-events/network.js b/client/js/socket-events/network.js
index aaf0aca5..a0b322c6 100644
--- a/client/js/socket-events/network.js
+++ b/client/js/socket-events/network.js
@@ -6,12 +6,12 @@ const render = require("../render");
const templates = require("../../views");
const sidebar = $("#sidebar");
const utils = require("../utils");
-const {Vue, vueApp} = require("../vue");
+const {vueApp} = require("../vue");
socket.on("network", function(data) {
vueApp.networks.push(data.networks[0]);
- Vue.nextTick(() => {
+ vueApp.$nextTick(() => {
render.renderNetworks(data, true);
sidebar.find(".chan")
diff --git a/client/js/socket-events/quit.js b/client/js/socket-events/quit.js
index 2c6256c9..2ee34bdd 100644
--- a/client/js/socket-events/quit.js
+++ b/client/js/socket-events/quit.js
@@ -3,12 +3,12 @@
const $ = require("jquery");
const socket = require("../socket");
const sidebar = $("#sidebar");
-const {Vue, vueApp} = require("../vue");
+const {vueApp} = require("../vue");
socket.on("quit", function(data) {
vueApp.networks.splice(vueApp.networks.findIndex((n) => n.uuid === data.network), 1);
- Vue.nextTick(() => {
+ vueApp.$nextTick(() => {
const chan = sidebar.find(".chan");
if (chan.length === 0) {
diff --git a/client/js/socket.js b/client/js/socket.js
index 2956c6d5..614fc2fc 100644
--- a/client/js/socket.js
+++ b/client/js/socket.js
@@ -2,7 +2,6 @@
const $ = require("jquery");
const io = require("socket.io-client");
-const utils = require("./utils");
const socket = io({
transports: $(document.body).data("transports"),
@@ -51,6 +50,7 @@ function handleDisconnect(data) {
// If the server shuts down, socket.io skips reconnection
// and we have to manually call connect to start the process
if (socket.io.skipReconnect) {
+ const utils = require("./utils");
utils.requestIdleCallback(() => socket.connect(), 2000);
}
}
diff --git a/client/js/vue.js b/client/js/vue.js
index a6b7a3df..6ded26d2 100644
--- a/client/js/vue.js
+++ b/client/js/vue.js
@@ -45,7 +45,6 @@ function findChannel(id) {
}
module.exports = {
- Vue,
vueApp,
findChannel,
};
diff --git a/client/views/date_marker.tpl b/client/views/date_marker.tpl
deleted file mode 100644
index b1d20be7..00000000
--- a/client/views/date_marker.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-
+ ref="loadMoreButton"
+ :disabled="channel.historyLoading"
+ class="show-more show"
+ @click="onShowMoreClick"
+ >
+ v-if="channel.historyLoading"
+ class="btn">Loading…
+
-
-
+
@@ -95,34 +111,18 @@
+
-
-
-
-