From ae9bdeb77fd635b8ad8a3f3cb2e3891c1514aa18 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Tue, 12 Sep 2023 12:40:29 -0400 Subject: [PATCH] fix bug with message list fetch more --- src/components/messaging/MessageList.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/messaging/MessageList.tsx b/src/components/messaging/MessageList.tsx index cfdb638..79e9988 100644 --- a/src/components/messaging/MessageList.tsx +++ b/src/components/messaging/MessageList.tsx @@ -61,6 +61,10 @@ function MessageList({ guild, channel }: Props) { } // get last group const lastGroup = messageGroups[messageGroups.length - 1]; + if (!lastGroup) { + logger.warn("No last group found, aborting fetchMore"); + return; + } // ignore queued messages if ("status" in lastGroup.messages[0]) return; // get first message in the group to use as before @@ -70,7 +74,7 @@ function MessageList({ guild, channel }: Props) { if (r !== 50) setHasMore(false); else setHasMore(true); }); - }, [channel, setHasMore]); + }, [channel, messageGroups, setHasMore]); const renderGroup = React.useCallback( (group: MessageGroupType) => ,