Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/index_d_ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

export interface UserListQuery {
hasNext?: boolean;
next(callback: unknown): void;
next(): Promise<Array<User>>;
}

export interface RenderUserProfileProps {
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Logger = {

interface UserListQuery {
hasNext?: boolean;
next(): Promise<User[]>;
next(): Promise<Array<User>>;
}

interface RenderUserProfileProps {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/SendbirdState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CustomUseReducerDispatcher = ({

interface UserListQuery {
hasNext?: boolean;
next(callback: unknown): void;
next(): Promise<Array<User>>;
}

interface RenderUserProfileProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface CreateChannelUIProps {
const CreateChannel: React.FC<CreateChannelUIProps> = (props: CreateChannelUIProps) => {
const { onCancel, renderStepOne } = props;

const createChannelProps = useCreateChannelContext();
const {
step,
setStep,
} = createChannelProps;
userListQuery,
} = useCreateChannelContext();

return (
<>
Expand All @@ -33,6 +33,7 @@ const CreateChannel: React.FC<CreateChannelUIProps> = (props: CreateChannelUIPro
{
step === 1 && (
<InviteUsers
userListQuery={userListQuery}
onCancel={() => {
setStep(0);
onCancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,9 +24,13 @@ import {

export interface InviteUsersProps {
onCancel?: () => void;
userListQuery?(): UserListQuery;
}

const InviteUsers: React.FC<InviteUsersProps> = ({ onCancel }: InviteUsersProps) => {
const InviteUsers: React.FC<InviteUsersProps> = ({
onCancel,
userListQuery,
}: InviteUsersProps) => {
const {
onBeforeCreateChannel,
onCreateChannel,
Expand All @@ -40,12 +45,12 @@ const InviteUsers: React.FC<InviteUsersProps> = ({ onCancel }: InviteUsersProps)
const [users, setUsers] = useState([]);
const [selectedUsers, setSelectedUsers] = useState({});
const { stringSet } = useContext(LocalizationContext);
const [usersDataSource, setUsersDataSource] = useState<ApplicationUserListQuery>(null);
const [usersDataSource, setUsersDataSource] = useState<ApplicationUserListQuery | UserListQuery>(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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import { User } from '@sendbird/chat';
import type {
GroupChannel,
GroupChannelCreateParams,
Expand All @@ -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<Array<User>>;
}

export interface CreateChannelProviderProps {
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type ReplyType = "NONE" | "QUOTE_REPLY" | "THREAD";

export interface UserListQuery {
hasNext?: boolean;
next(callback: unknown): void;
next(): Promise<Array<User>>;
}

export interface RenderUserProfileProps {
Expand Down