From 224e052351335c93642f3db57c75b65af311a145 Mon Sep 17 00:00:00 2001 From: Anton Arnautov Date: Wed, 20 Nov 2024 17:16:24 +0100 Subject: [PATCH] Fix pinning; first-in-position channel --- src/components/ChannelList/hooks/useMemberUpdatedListener.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/ChannelList/hooks/useMemberUpdatedListener.ts b/src/components/ChannelList/hooks/useMemberUpdatedListener.ts index 83a4a1f0d..bac41d30b 100644 --- a/src/components/ChannelList/hooks/useMemberUpdatedListener.ts +++ b/src/components/ChannelList/hooks/useMemberUpdatedListener.ts @@ -38,8 +38,9 @@ export const useMemberUpdatedListener = ({ newChannels.splice(targetChannelIndex, 1); } - const lastPinnedChannelIndex = findLastPinnedChannelIndex({ channels: newChannels }) ?? 0; - const newTargetChannelIndex = lastPinnedChannelIndex + 1; + const lastPinnedChannelIndex = findLastPinnedChannelIndex({ channels: newChannels }); + const newTargetChannelIndex = + typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0; // skip re-render if the position of the channel does not change if (currentChannels[newTargetChannelIndex] === targetChannel) {