Skip to content

Commit

Permalink
Fix pinning; first-in-position channel
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Nov 20, 2024
1 parent d7a0d12 commit 224e052
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/ChannelList/hooks/useMemberUpdatedListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export const useMemberUpdatedListener = <SCG extends ExtendableGenerics>({
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) {
Expand Down

0 comments on commit 224e052

Please sign in to comment.