2017-05-18 21:08:54 +01:00
|
|
|
"use strict";
|
|
|
|
|
2019-11-11 23:39:09 +02:00
|
|
|
import Vue from "vue";
|
|
|
|
|
2017-05-18 21:08:54 +01:00
|
|
|
const socket = require("../socket");
|
2019-11-03 16:59:43 +02:00
|
|
|
const store = require("../store").default;
|
2017-05-18 21:08:54 +01:00
|
|
|
|
|
|
|
socket.on("more", function(data) {
|
2019-11-03 16:59:43 +02:00
|
|
|
const channel = store.getters.findChannel(data.chan);
|
2018-02-20 09:28:04 +02:00
|
|
|
|
2018-07-08 15:18:17 +03:00
|
|
|
if (!channel) {
|
|
|
|
return;
|
2017-05-18 21:08:54 +01:00
|
|
|
}
|
|
|
|
|
2019-10-17 13:27:15 +03:00
|
|
|
channel.channel.moreHistoryAvailable =
|
|
|
|
data.totalMessages > channel.channel.messages.length + data.messages.length;
|
2018-07-08 15:18:17 +03:00
|
|
|
channel.channel.messages.unshift(...data.messages);
|
2018-07-12 19:25:41 +03:00
|
|
|
|
2019-11-11 23:39:09 +02:00
|
|
|
Vue.nextTick(() => {
|
2018-07-12 19:25:41 +03:00
|
|
|
channel.channel.historyLoading = false;
|
|
|
|
});
|
2017-05-18 21:08:54 +01:00
|
|
|
});
|