Skip to content

Commit

Permalink
fix(handleMemberUpdated): consider both pinned and archived channels (#…
Browse files Browse the repository at this point in the history
…2638)

### 🎯 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.
  • Loading branch information
arnautov-anton authored Feb 11, 2025
1 parent ed0906c commit ae66de8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/ChannelList/hooks/useChannelListShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
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) => {
Expand All @@ -296,9 +301,6 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
const isTargetChannelArchived = isChannelArchived(targetChannel);
const isTargetChannelPinned = isChannelPinned(targetChannel);

// handle pinning
if (!considerPinnedChannels || lockChannelOrder) return currentChannels;

const newChannels = [...currentChannels];

if (targetChannelExistsWithinList) {
Expand Down

0 comments on commit ae66de8

Please sign in to comment.