Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CLNP-2719): inputDisabled prop opened as public #170

Merged
merged 3 commits into from
Apr 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ChannelInput from '../../../components/ChannelInput';
import { GroupChannelContexts } from '../module/moduleContext';
import type { GroupChannelProps } from '../types';

const GroupChannelInput = (props: GroupChannelProps['Input']) => {
const GroupChannelInput = ({ inputDisabled, ...props }: GroupChannelProps['Input']) => {
const {
channel,
keyboardAvoidOffset = 0,
Expand All @@ -25,10 +25,10 @@ const GroupChannelInput = (props: GroupChannelProps['Input']) => {
setMessageToEdit={setMessageToEdit}
messageToReply={messageToReply}
setMessageToReply={setMessageToReply}
keyboardAvoidOffset={keyboardAvoidOffset}
inputMuted={chatAvailableState.muted}
inputFrozen={chatAvailableState.frozen}
inputDisabled={chatAvailableState.disabled}
keyboardAvoidOffset={keyboardAvoidOffset}
inputDisabled={inputDisabled ?? chatAvailableState.disabled}
{...props}
/>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/uikit-react-native/src/domain/groupChannel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { MessageCollectionParams, MessageFilterParams } from '@sendbird/cha
import type { UseGroupChannelMessagesOptions } from '@sendbird/uikit-chat-hooks';
import type {
OnBeforeHandler,
PickPartial,
SendbirdFileMessage,
SendbirdFileMessageCreateParams,
SendbirdFileMessageUpdateParams,
Expand Down Expand Up @@ -91,15 +92,16 @@ export interface GroupChannelProps {
// Changing the search item will trigger the focus animation on messages.
onUpdateSearchItem: (searchItem?: GroupChannelProps['MessageList']['searchItem']) => void;
};
Input: Pick<
Input: PickPartial<
ChannelInputProps,
| 'shouldRenderInput'
| 'onPressSendUserMessage'
| 'onPressSendFileMessage'
| 'onPressUpdateUserMessage'
| 'onPressUpdateFileMessage'
| 'SuggestedMentionList'
| 'AttachmentsButton'
| 'AttachmentsButton',
'inputDisabled'
>;

SuggestedMentionList: SuggestedMentionListProps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useSendbirdChat } from '../../../hooks/useContext';
import { OpenChannelContexts } from '../module/moduleContext';
import type { OpenChannelProps } from '../types';

const OpenChannelInput = (props: OpenChannelProps['Input']) => {
const OpenChannelInput = ({ inputDisabled, ...props }: OpenChannelProps['Input']) => {
const { sdk, currentUser } = useSendbirdChat();

const {
Expand Down Expand Up @@ -64,10 +64,10 @@ const OpenChannelInput = (props: OpenChannelProps['Input']) => {
channel={channel}
messageToEdit={messageToEdit}
setMessageToEdit={setMessageToEdit}
keyboardAvoidOffset={keyboardAvoidOffset}
inputMuted={chatAvailableState.muted}
inputFrozen={channel.isFrozen}
inputDisabled={chatAvailableState.disabled}
keyboardAvoidOffset={keyboardAvoidOffset}
inputDisabled={inputDisabled ?? chatAvailableState.disabled}
{...props}
/>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/uikit-react-native/src/domain/openChannel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { UseOpenChannelMessagesOptions } from '@sendbird/uikit-chat-hooks';
import type { Icon } from '@sendbird/uikit-react-native-foundation';
import type {
OnBeforeHandler,
PickPartial,
SendbirdFileMessage,
SendbirdFileMessageCreateParams,
SendbirdFileMessageUpdateParams,
Expand Down Expand Up @@ -70,14 +71,15 @@ export type OpenChannelProps = {
| 'flatListProps'
| 'hasNext'
>;
Input: Pick<
Input: PickPartial<
ChannelInputProps,
| 'shouldRenderInput'
| 'onPressSendUserMessage'
| 'onPressSendFileMessage'
| 'onPressUpdateUserMessage'
| 'onPressUpdateFileMessage'
| 'AttachmentsButton'
| 'AttachmentsButton',
'inputDisabled'
>;

Provider: {
Expand Down
4 changes: 4 additions & 0 deletions packages/uikit-testing-tools/src/mocks/createMockChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class MockChannel implements GetMockProps<Params, SendbirdBaseChannel & Sendbird
pinnedMessageIds = [];
unreadMentionCount = 0;
unreadMessageCount = 0;
totalUnreadReplyCount = 0;

serialize(): object {
throw new Error('Method not implemented.');
Expand Down Expand Up @@ -637,6 +638,9 @@ class MockChannel implements GetMockProps<Params, SendbirdBaseChannel & Sendbird
throw new Error('Method not implemented.');
}

createThreadedParentMessageListQuery(): PreviousMessageListQuery {
throw new Error('Method not implemented.');
}
createPinnedMessageListQuery(_params?: PinnedMessageListQueryParams | undefined): PinnedMessageListQuery {
throw new Error('Method not implemented.');
}
Expand Down
6 changes: 6 additions & 0 deletions packages/uikit-testing-tools/src/mocks/createMockMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ class MockMessage implements GetMockProps<Params, SendbirdBaseMessage> {
updateFeedback(_: Feedback): Promise<void> {
return Promise.resolve(undefined);
}
markThreadAsRead(): Promise<void> {
return Promise.resolve();
}
setPushNotificationEnabled(_: boolean): Promise<void> {
return Promise.resolve();
}

asFileMessage(): SendbirdFileMessage {
return this as unknown as SendbirdFileMessage;
Expand Down
2 changes: 2 additions & 0 deletions packages/uikit-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export type PartialNullable<T> = {
[P in keyof T]?: T[P] | null;
};

export type PickPartial<T, PK extends keyof T, PPK extends keyof T> = Pick<T, PK> & Partial<Pick<T, PPK>>;

export type Optional<T> = T | undefined;

export type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
Expand Down
Loading