diff --git a/client/js/socket-events/more.js b/client/js/socket-events/more.js index 78970430..ee864895 100644 --- a/client/js/socket-events/more.js +++ b/client/js/socket-events/more.js @@ -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); diff --git a/client/js/store.js b/client/js/store.js index 3d336d06..d3669bdd 100644 --- a/client/js/store.js +++ b/client/js/store.js @@ -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;