From a2b05ad68c528776da5928445daafd69a0a5c7f6 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Thu, 31 Jul 2025 03:31:40 +0200 Subject: [PATCH 1/6] feat: use array replacement instead of for loop to add older messages to array --- components/MessageArea.vue | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/components/MessageArea.vue b/components/MessageArea.vue index 17b4a3e..08b89a5 100644 --- a/components/MessageArea.vue +++ b/components/MessageArea.vue @@ -268,17 +268,11 @@ onMounted(async () => { console.log("scroll height is at 10% or less"); //console.log("current oldest:", currentOldestMessage); const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset }); - if (olderMessages) { + if (olderMessages?.length) { olderMessages.reverse(); - console.log("older messages:", olderMessages); - if (olderMessages.length == 0) return; - olderMessages.reverse(); - for (const [i, oldMessage] of olderMessages.entries()) { - console.log("old message:", oldMessage); - messages.value.unshift(oldMessage); - for (const message of messages.value) { - groupMessage(message); - } + messages.value = [...olderMessages.map(msg => reactive(msg)), ...messages.value]; + for (const message of messages.value) { + groupMessage(message); } offset += offset; } From 446578c29ba2928f8c092bd708d4e4451f3c2315 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Thu, 31 Jul 2025 03:33:17 +0200 Subject: [PATCH 2/6] fix: amount of older messages requested doubling every time infinite scrolling is triggered --- components/MessageArea.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/MessageArea.vue b/components/MessageArea.vue index 08b89a5..d77c741 100644 --- a/components/MessageArea.vue +++ b/components/MessageArea.vue @@ -274,7 +274,7 @@ onMounted(async () => { for (const message of messages.value) { groupMessage(message); } - offset += offset; + offset += amount; } } else { fetched = false; From 4e60139ac275901a16f65bca5ca1d7f09fc54978 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Thu, 31 Jul 2025 03:34:30 +0200 Subject: [PATCH 3/6] chore: comment out unnecessary console logs in MessageArea --- components/MessageArea.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/MessageArea.vue b/components/MessageArea.vue index d77c741..529609c 100644 --- a/components/MessageArea.vue +++ b/components/MessageArea.vue @@ -237,12 +237,8 @@ function sendMessage(e: Event) { } function getReplyMessage(id: string) { - console.log("[REPLYMSG] id:", id); const messagesValues = Object.values(messages.value); - console.log("[REPLYMSG] messages values:", messagesValues); for (const message of messagesValues) { - console.log("[REPLYMSG] message:", message); - console.log("[REPLYMSG] IDs match?", message.uuid == id); if (message.uuid == id) return message; } } @@ -266,7 +262,6 @@ onMounted(async () => { if (fetched) return; fetched = true; console.log("scroll height is at 10% or less"); - //console.log("current oldest:", currentOldestMessage); const olderMessages = await fetchMessages(route.params.channelId as string, { amount, offset }); if (olderMessages?.length) { olderMessages.reverse(); From c2338199245e156daae3d4a05bc5fe79503e6734 Mon Sep 17 00:00:00 2001 From: SauceyRed Date: Thu, 31 Jul 2025 03:37:25 +0200 Subject: [PATCH 4/6] fix: MessageArea rendering the last X amount of messages in the messages array rather than the newly-loaded messages --- components/MessageArea.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/MessageArea.vue b/components/MessageArea.vue index 529609c..caf4079 100644 --- a/components/MessageArea.vue +++ b/components/MessageArea.vue @@ -1,7 +1,7 @@