diff --git a/src/components/TwitchChat.vue b/src/components/TwitchChat.vue index 15e354f..5c312f4 100644 --- a/src/components/TwitchChat.vue +++ b/src/components/TwitchChat.vue @@ -15,7 +15,7 @@ export default { }, setup(props) { let messages: Ref< - { username: string; channel: string; message: string; messageType: string }[] + { username: string; channel: string; message: string; messageType: string, tags: Record }[] > = ref([]) let ws = new WebSocket('ws://localhost:7000') @@ -34,6 +34,7 @@ export default { chatStatusMessage.textContent = `Connected to ${this.channelName}` } else { this.messages.push(JSON.parse(message.data)) + this.clearMessages() this.scrollToBottom(chatList) } } @@ -49,13 +50,18 @@ export default { }, scrollToBottom(el: Element) { el.scrollTop = el.scrollHeight + }, + clearMessages() { + if (this.messages.length > 50) { + this.messages.shift + } } } }