Skip to content

Commit 01f82da

Browse files
committed
feat(uikit): added queryCreator prop to OpenChannelParticipantsFragment
1 parent d7746f5 commit 01f82da

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/uikit-react-native/src/domain/openChannelUserList/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import type { UseUserListOptions } from '@sendbird/uikit-chat-hooks';
2-
import type { SendbirdOpenChannel, SendbirdParticipant, UserStruct } from '@sendbird/uikit-utils';
2+
import type { SendbirdOpenChannel, SendbirdParticipant, SendbirdUser, UserStruct } from '@sendbird/uikit-utils';
33

44
import type { CommonComponent } from '../../types';
55
import type { UserListProps } from '../userList/types';
66

7-
export interface OpenChannelParticipantsProps<User extends UserStruct> {
7+
export interface OpenChannelParticipantsProps {
88
Fragment: {
99
channel: SendbirdOpenChannel;
1010
onPressHeaderLeft: () => void;
11-
sortComparator?: UseUserListOptions<User>['sortComparator'];
12-
renderUser?: UserListProps<User>['List']['renderUser'];
11+
renderUser?: UserListProps<SendbirdParticipant>['List']['renderUser'];
12+
// NOTE: SDK does not migrate the response type of query to Participant from User yet due to backward compat.
13+
queryCreator?: UseUserListOptions<SendbirdUser | SendbirdParticipant>['queryCreator'];
14+
sortComparator?: UseUserListOptions<SendbirdUser | SendbirdParticipant>['sortComparator'];
1315
};
1416
}
15-
export type OpenChannelParticipantsFragment<User extends UserStruct> = CommonComponent<
16-
OpenChannelParticipantsProps<User>['Fragment']
17-
>;
17+
export type OpenChannelParticipantsFragment = CommonComponent<OpenChannelParticipantsProps['Fragment']>;
1818

1919
export interface OpenChannelRegisterOperatorProps<User extends UserStruct = SendbirdParticipant> {
2020
Fragment: {

packages/uikit-react-native/src/fragments/createOpenChannelParticipantsFragment.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import { useLocalization, useSendbirdChat, useUserProfile } from '../hooks/useCo
1717
const RETURN_EMPTY_STRING = () => '';
1818
const createOpenChannelParticipantsFragment = (
1919
initModule?: Partial<UserListModule<SendbirdParticipant>>,
20-
): OpenChannelParticipantsFragment<SendbirdParticipant> => {
20+
): OpenChannelParticipantsFragment => {
2121
const UserListModule = createUserListModule<SendbirdParticipant>(initModule);
2222

23-
return ({ channel, onPressHeaderLeft, renderUser }) => {
23+
return ({ channel, onPressHeaderLeft, renderUser, queryCreator, sortComparator }) => {
2424
const handlerId = useUniqHandlerId('OpenChannelParticipantsFragment');
2525

2626
const refreshSchedule = useRef<NodeJS.Timeout>();
@@ -30,7 +30,8 @@ const createOpenChannelParticipantsFragment = (
3030
const { show } = useUserProfile();
3131

3232
const { users, refresh, loading, next, error, upsertUser, deleteUser } = useUserList(sdk, {
33-
queryCreator: () => channel.createParticipantListQuery({ limit: 20 }),
33+
queryCreator: queryCreator ?? (() => channel.createParticipantListQuery({ limit: 20 })),
34+
sortComparator,
3435
});
3536

3637
useChannelHandler(

0 commit comments

Comments
 (0)