Skip to content

Commit 3693856

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

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
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,5 +1,5 @@
11
import type { UseUserListOptions } from '@sendbird/uikit-chat-hooks';
2-
import type { SendbirdOpenChannel, SendbirdParticipant, SendbirdUser, UserStruct } from '@sendbird/uikit-utils';
2+
import type { SendbirdOpenChannel, SendbirdParticipant, SendbirdUser } from '@sendbird/uikit-utils';
33

44
import type { CommonComponent } from '../../types';
55
import type { UserListProps } from '../userList/types';
@@ -16,15 +16,15 @@ export interface OpenChannelParticipantsProps {
1616
}
1717
export type OpenChannelParticipantsFragment = CommonComponent<OpenChannelParticipantsProps['Fragment']>;
1818

19-
export interface OpenChannelRegisterOperatorProps<User extends UserStruct = SendbirdParticipant> {
19+
export interface OpenChannelRegisterOperatorProps {
2020
Fragment: {
2121
channel: SendbirdOpenChannel;
2222
onPressHeaderLeft: () => void;
2323
onPressHeaderRight: (channel: SendbirdOpenChannel) => void;
24-
sortComparator?: UseUserListOptions<User>['sortComparator'];
25-
renderUser?: UserListProps<User>['List']['renderUser'];
24+
renderUser?: UserListProps<SendbirdParticipant>['List']['renderUser'];
25+
// NOTE: SDK does not migrate the response type of query to Participant from User yet due to backward compat.
26+
queryCreator?: UseUserListOptions<SendbirdUser | SendbirdParticipant>['queryCreator'];
27+
sortComparator?: UseUserListOptions<SendbirdUser | SendbirdParticipant>['sortComparator'];
2628
};
2729
}
28-
export type OpenChannelRegisterOperatorFragment<User extends UserStruct> = CommonComponent<
29-
OpenChannelRegisterOperatorProps<User>['Fragment']
30-
>;
30+
export type OpenChannelRegisterOperatorFragment = CommonComponent<OpenChannelRegisterOperatorProps['Fragment']>;

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback } from 'react';
22
import { TouchableOpacity } from 'react-native';
33

4-
import { CustomQueryInterface, useUserList } from '@sendbird/uikit-chat-hooks';
4+
import { useUserList } from '@sendbird/uikit-chat-hooks';
55
import type { SendbirdParticipant } from '@sendbird/uikit-utils';
66

77
import StatusComposition from '../components/StatusComposition';
@@ -13,18 +13,14 @@ import { useLocalization, useSendbirdChat } from '../hooks/useContext';
1313

1414
const createOpenChannelRegisterOperatorFragment = (
1515
initModule?: Partial<UserListModule<SendbirdParticipant>>,
16-
): OpenChannelRegisterOperatorFragment<SendbirdParticipant> => {
16+
): OpenChannelRegisterOperatorFragment => {
1717
const UserListModule = createUserListModule<SendbirdParticipant>(initModule);
1818

19-
return ({ channel, onPressHeaderLeft, sortComparator, renderUser, onPressHeaderRight }) => {
19+
return ({ channel, onPressHeaderLeft, sortComparator, renderUser, onPressHeaderRight, queryCreator }) => {
2020
const { sdk, currentUser } = useSendbirdChat();
2121
const { STRINGS } = useLocalization();
2222
const { users, refreshing, refresh, next, error, loading } = useUserList(sdk, {
23-
queryCreator: () => {
24-
return channel.createParticipantListQuery({
25-
limit: 20,
26-
}) as unknown as CustomQueryInterface<SendbirdParticipant>;
27-
},
23+
queryCreator: queryCreator ?? (() => channel.createParticipantListQuery({ limit: 20 })),
2824
sortComparator,
2925
});
3026

@@ -84,7 +80,7 @@ const createOpenChannelRegisterOperatorFragment = (
8480
>
8581
<UserListModule.List
8682
onLoadNext={next}
87-
users={users}
83+
users={users as SendbirdParticipant[]}
8884
renderUser={_renderUser}
8985
onRefresh={refresh}
9086
refreshing={refreshing}

0 commit comments

Comments
 (0)