hardlounge/client/js/socket-events/more.js

30 lines
669 B
JavaScript
Raw Normal View History

2017-05-18 20:08:54 +00:00
"use strict";
import Vue from "vue";
2019-11-16 17:24:03 +00:00
import socket from "../socket";
import store from "../store";
2017-05-18 20:08:54 +00:00
socket.on("more", function (data) {
const channel = store.getters.findChannel(data.chan)?.channel;
if (!channel) {
return;
2017-05-18 20:08:54 +00:00
}
channel.inputHistory = channel.inputHistory.concat(
data.messages
.filter((m) => m.self && m.text && m.type === "message")
.map((m) => m.text)
.reverse()
.slice(null, 100 - channel.inputHistory.length)
);
2021-04-30 23:36:44 +00:00
channel.moreHistoryAvailable =
data.totalMessages > channel.messages.length + data.messages.length;
channel.messages.unshift(...data.messages);
2018-07-12 16:25:41 +00:00
Vue.nextTick(() => {
2021-04-30 23:36:44 +00:00
channel.historyLoading = false;
2018-07-12 16:25:41 +00:00
});
2017-05-18 20:08:54 +00:00
});