Fill inputhistory on channel load and more message load

This commit is contained in:
Nachtalb 2021-05-01 01:46:55 +02:00
parent bd4e821614
commit 11aa52687c
No known key found for this signature in database
GPG key ID: E48DF13C07055D92
2 changed files with 15 additions and 1 deletions

View file

@ -12,6 +12,13 @@ socket.on("more", function (data) {
return;
}
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)
);
channel.moreHistoryAvailable =
data.totalMessages > channel.messages.length + data.messages.length;
channel.messages.unshift(...data.messages);

View file

@ -160,7 +160,14 @@ const store = new Vuex.Store({
// TODO: This should be a mutation
channel.pendingMessage = "";
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.scrolledToBottom = true;
channel.editTopic = false;