Skip to content

Commit 55cd5a1

Browse files
Fix pinning; first-in-position channel
1 parent bdf80b6 commit 55cd5a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/ChannelList/hooks/useMemberUpdatedListener.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ export const useMemberUpdatedListener = <SCG extends ExtendableGenerics>({
3838
newChannels.splice(targetChannelIndex, 1);
3939
}
4040

41-
const lastPinnedChannelIndex = findLastPinnedChannelIndex({ channels: newChannels }) ?? 0;
42-
const newTargetChannelIndex = lastPinnedChannelIndex + 1;
41+
const lastPinnedChannelIndex = findLastPinnedChannelIndex({ channels: newChannels });
42+
const newTargetChannelIndex =
43+
typeof lastPinnedChannelIndex === 'number' ? lastPinnedChannelIndex + 1 : 0;
4344

4445
// skip re-render if the position of the channel does not change
4546
if (currentChannels[newTargetChannelIndex] === targetChannel) {

0 commit comments

Comments
 (0)