mirror of
https://github.com/thelounge/thelounge
synced 2024-11-14 00:07:17 +00:00
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
3 changed files with 21 additions and 7 deletions
|
@ -2,7 +2,7 @@
|
|||
root: true
|
||||
|
||||
parserOptions:
|
||||
ecmaVersion: 2018
|
||||
ecmaVersion: 2020
|
||||
|
||||
env:
|
||||
es6: true
|
||||
|
|
|
@ -6,17 +6,24 @@ import socket from "../socket";
|
|||
import store from "../store";
|
||||
|
||||
socket.on("more", function (data) {
|
||||
const channel = store.getters.findChannel(data.chan);
|
||||
const channel = store.getters.findChannel(data.chan)?.channel;
|
||||
|
||||
if (!channel) {
|
||||
return;
|
||||
}
|
||||
|
||||
channel.channel.moreHistoryAvailable =
|
||||
data.totalMessages > channel.channel.messages.length + data.messages.length;
|
||||
channel.channel.messages.unshift(...data.messages);
|
||||
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);
|
||||
|
||||
Vue.nextTick(() => {
|
||||
channel.channel.historyLoading = false;
|
||||
channel.historyLoading = false;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -190,7 +190,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;
|
||||
|
|
Loading…
Reference in a new issue