From ae66de8d3c5ed78fbe5aa5388ebf8a1b8e90a9e9 Mon Sep 17 00:00:00 2001 From: Anton Arnautov <43254280+arnautov-anton@users.noreply.github.com> Date: Tue, 11 Feb 2025 08:46:59 +0100 Subject: [PATCH] fix(handleMemberUpdated): consider both pinned and archived channels (#2638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 🎯 Goal This PR solves an issue where if `pinned_at` is missing from the `sort`, the archived channels are not being handled properly during application runtime. --- src/components/ChannelList/hooks/useChannelListShape.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ChannelList/hooks/useChannelListShape.ts b/src/components/ChannelList/hooks/useChannelListShape.ts index bcb2b43ad..b9208f6a5 100644 --- a/src/components/ChannelList/hooks/useChannelListShape.ts +++ b/src/components/ChannelList/hooks/useChannelListShape.ts @@ -285,6 +285,11 @@ export const useChannelListShapeDefaults = () => const considerPinnedChannels = shouldConsiderPinnedChannels(sort); const considerArchivedChannels = shouldConsiderArchivedChannels(filters); + // `pinned_at` nor `archived` properties are set or channel list order is locked, return early + if ((!considerPinnedChannels && !considerArchivedChannels) || lockChannelOrder) { + return; + } + const pinnedAtSort = extractSortValue({ atIndex: 0, sort, targetKey: 'pinned_at' }); setChannels((currentChannels) => { @@ -296,9 +301,6 @@ export const useChannelListShapeDefaults = () => const isTargetChannelArchived = isChannelArchived(targetChannel); const isTargetChannelPinned = isChannelPinned(targetChannel); - // handle pinning - if (!considerPinnedChannels || lockChannelOrder) return currentChannels; - const newChannels = [...currentChannels]; if (targetChannelExistsWithinList) {