Move message history limit handling to ChatBox

This commit is contained in:
James Lyne 2021-01-06 16:10:56 +00:00
parent 9c0213016b
commit 1615c3d902
2 changed files with 8 additions and 5 deletions

View File

@ -34,7 +34,14 @@
},
setup() {
const store = useStore(),
messages = computed(() => store.state.chat.messages);
componentSettings = computed(() => store.state.components.chatBox),
messages = computed(() => {
if(componentSettings.value!.messageHistory) {
return store.state.chat.messages.slice(componentSettings.value!.messageHistory);
} else {
return store.state.chat.messages;
}
});
return {
messages,

View File

@ -242,10 +242,6 @@ export const mutations: MutationTree<State> & Mutations = {
//Adds chat messages from an update fetch to the chat history
[MutationTypes.ADD_CHAT](state: State, chat: Array<DynmapChat>) {
state.chat.messages.unshift(...chat);
if(state.components.chatBox && isFinite(state.components.chatBox.messageHistory)) {
state.chat.messages.splice(state.components.chatBox.messageHistory);
}
},
//Pops the specified number of marker updates from the pending updates list