@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
22
33import { ReactionResponse , ReactionSort } from 'stream-chat' ;
44
5+ import { MessageType } from '../../../components/MessageList/hooks/useMessageList' ;
56import { useChatContext } from '../../../contexts/chatContext/ChatContext' ;
67import { getReactionsForFilterSort } from '../../../store/apis/getReactionsforFilterSort' ;
78import { DefaultStreamChatGenerics } from '../../../types/types' ;
@@ -10,7 +11,7 @@ export type UseFetchReactionParams<
1011 StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
1112> = {
1213 limit ?: number ;
13- messageId ?: string ;
14+ message ?: MessageType < StreamChatGenerics > ;
1415 reactionType ?: string ;
1516 sort ?: ReactionSort < StreamChatGenerics > ;
1617} ;
@@ -19,13 +20,14 @@ export const useFetchReactions = <
1920 StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
2021> ( {
2122 limit = 25 ,
22- messageId ,
23+ message ,
2324 reactionType,
2425 sort,
2526} : UseFetchReactionParams ) => {
2627 const [ reactions , setReactions ] = useState < ReactionResponse < StreamChatGenerics > [ ] > ( [ ] ) ;
2728 const [ loading , setLoading ] = useState ( true ) ;
2829 const [ next , setNext ] = useState < string | undefined > ( undefined ) ;
30+ const messageId = message ?. id ;
2931
3032 const { client, enableOfflineSupport } = useChatContext ( ) ;
3133
@@ -61,8 +63,9 @@ export const useFetchReactions = <
6163 } ;
6264
6365 try {
64- if ( enableOfflineSupport ) {
65- loadOfflineReactions ( ) ;
66+ // TODO: Threads are not supported for the offline use case as we don't store the thread messages currently, and this will change in the future.
67+ if ( enableOfflineSupport && ! message ?. parent_id ) {
68+ await loadOfflineReactions ( ) ;
6669 } else {
6770 await loadOnlineReactions ( ) ;
6871 }
0 commit comments