From 1615c3d902b7831b9fa321ca88f9020167079370 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 6 Jan 2021 16:10:56 +0000 Subject: [PATCH] Move message history limit handling to ChatBox --- src/components/ChatBox.vue | 9 ++++++++- src/store/mutations.ts | 4 ---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/ChatBox.vue b/src/components/ChatBox.vue index 9ed092c..4c85315 100644 --- a/src/components/ChatBox.vue +++ b/src/components/ChatBox.vue @@ -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, diff --git a/src/store/mutations.ts b/src/store/mutations.ts index e293919..631bea5 100644 --- a/src/store/mutations.ts +++ b/src/store/mutations.ts @@ -242,10 +242,6 @@ export const mutations: MutationTree & Mutations = { //Adds chat messages from an update fetch to the chat history [MutationTypes.ADD_CHAT](state: State, chat: Array) { 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