Merge pull request #4206 from Nachtalb/na/fill-inputhistory-onload
Fill inputhistory on channel load and more message load
This commit is contained in:
commit
ad8a315cf9
@ -2,7 +2,7 @@
|
|||||||
root: true
|
root: true
|
||||||
|
|
||||||
parserOptions:
|
parserOptions:
|
||||||
ecmaVersion: 2018
|
ecmaVersion: 2020
|
||||||
|
|
||||||
env:
|
env:
|
||||||
es6: true
|
es6: true
|
||||||
|
@ -6,17 +6,24 @@ import socket from "../socket";
|
|||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
socket.on("more", function (data) {
|
socket.on("more", function (data) {
|
||||||
const channel = store.getters.findChannel(data.chan);
|
const channel = store.getters.findChannel(data.chan)?.channel;
|
||||||
|
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.channel.moreHistoryAvailable =
|
channel.inputHistory = channel.inputHistory.concat(
|
||||||
data.totalMessages > channel.channel.messages.length + data.messages.length;
|
data.messages
|
||||||
channel.channel.messages.unshift(...data.messages);
|
.filter((m) => m.self && m.text && m.type === "message")
|
||||||
|
.map((m) => m.text)
|
||||||
|
.reverse()
|
||||||
|
.slice(null, 100 - channel.inputHistory.length)
|
||||||
|
);
|
||||||
|
channel.moreHistoryAvailable =
|
||||||
|
data.totalMessages > channel.messages.length + data.messages.length;
|
||||||
|
channel.messages.unshift(...data.messages);
|
||||||
|
|
||||||
Vue.nextTick(() => {
|
Vue.nextTick(() => {
|
||||||
channel.channel.historyLoading = false;
|
channel.historyLoading = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -190,7 +190,14 @@ const store = new Vuex.Store({
|
|||||||
// TODO: This should be a mutation
|
// TODO: This should be a mutation
|
||||||
channel.pendingMessage = "";
|
channel.pendingMessage = "";
|
||||||
channel.inputHistoryPosition = 0;
|
channel.inputHistoryPosition = 0;
|
||||||
channel.inputHistory = [""];
|
|
||||||
|
channel.inputHistory = [""].concat(
|
||||||
|
channel.messages
|
||||||
|
.filter((m) => m.self && m.text && m.type === "message")
|
||||||
|
.map((m) => m.text)
|
||||||
|
.reverse()
|
||||||
|
.slice(null, 99)
|
||||||
|
);
|
||||||
channel.historyLoading = false;
|
channel.historyLoading = false;
|
||||||
channel.scrolledToBottom = true;
|
channel.scrolledToBottom = true;
|
||||||
channel.editTopic = false;
|
channel.editTopic = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user