Skip to content

Commit

Permalink
fix: ChannelAvatar crash when used outside of ChannelList (#2708)
Browse files Browse the repository at this point in the history
  • Loading branch information
isekovanic authored Oct 15, 2024
1 parent 50d6467 commit 85f4ab2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export const ChannelPreviewMessenger = <
props: ChannelPreviewMessengerProps<StreamChatGenerics>,
) => {
const {
forceUpdate,
maxUnreadCount,
onSelect,
PreviewAvatar,
Expand All @@ -224,6 +225,7 @@ export const ChannelPreviewMessenger = <
return (
<MemoizedChannelPreviewMessengerWithContext
{...{
forceUpdate,
maxUnreadCount,
onSelect,
PreviewAvatar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useState } from 'react';

import type { Channel, StreamChat } from 'stream-chat';

import { useChannelsContext } from '../../../contexts';
import { useChatContext } from '../../../contexts/chatContext/ChatContext';

import type { DefaultStreamChatGenerics } from '../../../types/types';
Expand Down Expand Up @@ -38,7 +37,6 @@ export const useChannelPreviewDisplayPresence = <
channel: Channel<StreamChatGenerics>,
) => {
const { client } = useChatContext<StreamChatGenerics>();
const { forceUpdate } = useChannelsContext<StreamChatGenerics>();

const currentUserId = client.userID;
const members = Object.values(channel.state.members).filter(
Expand All @@ -50,7 +48,7 @@ export const useChannelPreviewDisplayPresence = <

useEffect(() => {
setDisplayPresence(getChannelPreviewDisplayPresence(channel, client));
}, [channel, channelMemberOnline, client, forceUpdate]);
}, [channel, channelMemberOnline, client]);

return displayPresence;
};

0 comments on commit 85f4ab2

Please sign in to comment.