diff --git a/scripts/index_d_ts b/scripts/index_d_ts index 1566032c7..93b59e4bc 100644 --- a/scripts/index_d_ts +++ b/scripts/index_d_ts @@ -59,7 +59,7 @@ export interface UserListQuery { hasNext?: boolean; - next(callback: unknown): void; + next(): Promise>; } export interface RenderUserProfileProps { diff --git a/src/index.d.ts b/src/index.d.ts index 9bc8eeefc..dfe116deb 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -46,7 +46,7 @@ type Logger = { interface UserListQuery { hasNext?: boolean; - next(): Promise; + next(): Promise>; } interface RenderUserProfileProps { diff --git a/src/lib/SendbirdState.tsx b/src/lib/SendbirdState.tsx index c9fa478ed..2dd7921a3 100644 --- a/src/lib/SendbirdState.tsx +++ b/src/lib/SendbirdState.tsx @@ -10,7 +10,7 @@ export type CustomUseReducerDispatcher = ({ interface UserListQuery { hasNext?: boolean; - next(callback: unknown): void; + next(): Promise>; } interface RenderUserProfileProps { diff --git a/src/smart-components/ChannelSettings/components/ModerationPanel/InviteUsersModal.tsx b/src/smart-components/ChannelSettings/components/ModerationPanel/InviteUsersModal.tsx index 8335188c9..3474509d6 100644 --- a/src/smart-components/ChannelSettings/components/ModerationPanel/InviteUsersModal.tsx +++ b/src/smart-components/ChannelSettings/components/ModerationPanel/InviteUsersModal.tsx @@ -21,11 +21,12 @@ export default function InviteUsers({ const state = useSendbirdStateContext(); const sdk = state?.stores?.sdkStore?.sdk; + const globalUserListQuery = state?.config?.userListQuery; const { channel } = useChannelSettingsContext(); useEffect(() => { - const userListQuery = sdk?.createApplicationUserListQuery(); + const userListQuery = globalUserListQuery ? globalUserListQuery() : sdk?.createApplicationUserListQuery(); userListQuery.next().then((members) => { setMembers(members); }); diff --git a/src/smart-components/CreateChannel/components/CreateChannelUI/index.tsx b/src/smart-components/CreateChannel/components/CreateChannelUI/index.tsx index f9e30cd13..d7db0d7e6 100644 --- a/src/smart-components/CreateChannel/components/CreateChannelUI/index.tsx +++ b/src/smart-components/CreateChannel/components/CreateChannelUI/index.tsx @@ -13,11 +13,11 @@ export interface CreateChannelUIProps { const CreateChannel: React.FC = (props: CreateChannelUIProps) => { const { onCancel, renderStepOne } = props; - const createChannelProps = useCreateChannelContext(); const { step, setStep, - } = createChannelProps; + userListQuery, + } = useCreateChannelContext(); return ( <> @@ -33,6 +33,7 @@ const CreateChannel: React.FC = (props: CreateChannelUIPro { step === 1 && ( { setStep(0); onCancel(); diff --git a/src/smart-components/CreateChannel/components/InviteUsers/index.tsx b/src/smart-components/CreateChannel/components/InviteUsers/index.tsx index b0231824e..388b46856 100644 --- a/src/smart-components/CreateChannel/components/InviteUsers/index.tsx +++ b/src/smart-components/CreateChannel/components/InviteUsers/index.tsx @@ -14,6 +14,7 @@ import Label, { } from '../../../../ui/Label'; import { ButtonTypes } from '../../../../ui/Button'; import UserListItem from '../../../../ui/UserListItem'; +import { UserListQuery } from '../../context/CreateChannelProvider'; import { filterUser, @@ -23,9 +24,13 @@ import { export interface InviteUsersProps { onCancel?: () => void; + userListQuery?(): UserListQuery; } -const InviteUsers: React.FC = ({ onCancel }: InviteUsersProps) => { +const InviteUsers: React.FC = ({ + onCancel, + userListQuery, +}: InviteUsersProps) => { const { onBeforeCreateChannel, onCreateChannel, @@ -40,12 +45,12 @@ const InviteUsers: React.FC = ({ onCancel }: InviteUsersProps) const [users, setUsers] = useState([]); const [selectedUsers, setSelectedUsers] = useState({}); const { stringSet } = useContext(LocalizationContext); - const [usersDataSource, setUsersDataSource] = useState(null); + const [usersDataSource, setUsersDataSource] = useState(null); const selectedCount = Object.keys(selectedUsers).length; const titleText = stringSet.MODAL__CREATE_CHANNEL__TITLE; const submitText = stringSet.BUTTON__CREATE; - const userQueryCreator = createDefaultUserListQuery({ sdk }); + const userQueryCreator = userListQuery ? userListQuery() : createDefaultUserListQuery({ sdk }); useEffect(() => { const applicationUserListQuery = userQueryCreator; diff --git a/src/smart-components/CreateChannel/context/CreateChannelProvider.tsx b/src/smart-components/CreateChannel/context/CreateChannelProvider.tsx index b5c77f767..d7a718674 100644 --- a/src/smart-components/CreateChannel/context/CreateChannelProvider.tsx +++ b/src/smart-components/CreateChannel/context/CreateChannelProvider.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { User } from '@sendbird/chat'; import type { GroupChannel, GroupChannelCreateParams, @@ -11,9 +12,9 @@ import { CHANNEL_TYPE } from '../types'; const CreateChannelContext = React.createContext(undefined); -interface UserListQuery { +export interface UserListQuery { hasNext?: boolean; - next(callback: unknown): void; + next(): Promise>; } export interface CreateChannelProviderProps { diff --git a/src/types.d.ts b/src/types.d.ts index 876e2e6e7..598ccf742 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -10,7 +10,7 @@ export type ReplyType = "NONE" | "QUOTE_REPLY" | "THREAD"; export interface UserListQuery { hasNext?: boolean; - next(callback: unknown): void; + next(): Promise>; } export interface RenderUserProfileProps {