Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mockState = {
},
isOnline: true,
},
};const mockActions = { connect: jest.fn(), disconnect: jest.fn() };
}; const mockActions = { connect: jest.fn(), disconnect: jest.fn() };

jest.mock('../../../../lib/Sendbird/context/hooks/useSendbird', () => ({
__esModule: true,
Expand Down
2 changes: 1 addition & 1 deletion src/modules/GroupChannel/context/GroupChannelProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ const GroupChannelManager :React.FC<React.PropsWithChildren<GroupChannelProvider
return children;
};

const GroupChannelProvider: React.FC<React.PropsWithChildren<GroupChannelProviderProps>> = (props) => {
const GroupChannelProvider: React.FC<GroupChannelProviderProps> = (props) => {
return (
<InternalGroupChannelProvider>
<GroupChannelManager {...props}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import React, { act } from 'react';
import { render, screen } from '@testing-library/react';
import type { GroupChannelProviderProps } from '../types'
import type { GroupChannelProviderProps } from '../types';
import { GroupChannelProvider, useGroupChannelContext } from '../GroupChannelProvider';
import { ThreadReplySelectType } from '../const';
import { match } from 'ts-pattern';
Expand Down Expand Up @@ -57,8 +57,7 @@ const mockProps: GroupChannelProviderProps = {
scrollBehavior: 'smooth',
forceLeftToRightMessageLayout: false,

startingPoint: 0,

startingPoint: undefined,
// Message Focusing
animatedMessageId: null,
onMessageAnimated: jest.fn(),
Expand Down Expand Up @@ -93,23 +92,23 @@ const mockProps: GroupChannelProviderProps = {
describe('GroupChannel Migration Compatibility Tests', () => {
// 1. Provider Props Interface test
describe('GroupChannelProvider Props Compatibility', () => {
it('should accept all legacy props without type errors', () => {
const { rerender } = render(
it('should accept all legacy props without type errors', async () => {
const { rerender } = await act(async () => render(
<GroupChannelProvider {...mockProps}>
{mockProps.children}
</GroupChannelProvider>,
);
));

// Props change scenario test
rerender(
await act(async () => rerender(
<GroupChannelProvider
{...mockProps}
isReactionEnabled={false}
onBackClick={() => {}}
>
{mockProps.children}
</GroupChannelProvider>,
);
));
});
});

Expand Down
10 changes: 8 additions & 2 deletions src/modules/GroupChannel/context/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ReplyType } from '../../../types';
import { useMessageActions } from './hooks/useMessageActions';
import { useGroupChannelMessages } from '@sendbird/uikit-tools';
import { ThreadReplySelectType } from './const';
import { PropsWithChildren } from 'react';

// Message data source types
type MessageDataSource = ReturnType<typeof useGroupChannelMessages>;
Expand Down Expand Up @@ -66,8 +67,13 @@ interface InternalGroupChannelState extends MessageDataSource {
scrollPubSub: PubSubTypes<ScrollTopics, ScrollTopicUnion>;
}

export interface GroupChannelProviderProps extends
Pick<UserProfileProviderProps, 'renderUserProfile' | 'disableUserProfile'> {
export interface GroupChannelProviderProps extends PropsWithChildren<
Pick<UserProfileProviderProps,
'renderUserProfile' |
'disableUserProfile' |
'onUserProfileMessage'|
'onStartDirectMessage'
>> {
// Required
channelUrl: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ describe('MessageSearch Migration Compatibility Tests', () => {
'children',
'requestString',
'retryCount',
'setRetryCount',
'selectedMessageId',
'setSelectedMessageId',
'messageSearchDispatcher',
'scrollRef',
'allMessages',
'loading',
'isInvalid',
'currentChannel',
'currentMessageSearchQuery',
'hasMoreResult',
Expand Down
4 changes: 2 additions & 2 deletions src/modules/MessageSearch/context/hooks/useMessageSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { MessageSearchQuery } from '@sendbird/chat/message';

import { useSyncExternalStore } from 'use-sync-external-store/shim';
import { ClientSentMessages } from '../../../../types';
import { MessageSearchContext } from '../MessageSearchProvider';
import { MessageSearchContext, type MessageSearchState } from '../MessageSearchProvider';

const useMessageSearch = () => {
const store = useContext(MessageSearchContext);
if (!store) throw new Error('useMessageSearch must be used within a MessageSearchProvider');

const state = useSyncExternalStore(store.subscribe, store.getState);
const state: MessageSearchState = useSyncExternalStore(store.subscribe, store.getState);
const actions = useMemo(() => ({
setCurrentChannel: (channel: GroupChannel) => store.setState(state => ({
...state,
Expand Down