From 6eb4ad0d35447183a697c2c8c5064a003c1e6f9a Mon Sep 17 00:00:00 2001 From: bang9 Date: Mon, 1 Apr 2024 10:42:28 +0900 Subject: [PATCH 1/3] feat: inputDisabled prop opened as public --- .../src/domain/groupChannel/component/GroupChannelInput.tsx | 6 +++--- .../uikit-react-native/src/domain/groupChannel/types.ts | 1 + .../src/domain/openChannel/component/OpenChannelInput.tsx | 6 +++--- packages/uikit-react-native/src/domain/openChannel/types.ts | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput.tsx b/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput.tsx index a6ce135e0..451eaefe7 100644 --- a/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput.tsx +++ b/packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput.tsx @@ -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, @@ -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} /> ); diff --git a/packages/uikit-react-native/src/domain/groupChannel/types.ts b/packages/uikit-react-native/src/domain/groupChannel/types.ts index 8b2464fcf..25ea4d399 100644 --- a/packages/uikit-react-native/src/domain/groupChannel/types.ts +++ b/packages/uikit-react-native/src/domain/groupChannel/types.ts @@ -93,6 +93,7 @@ export interface GroupChannelProps { }; Input: Pick< ChannelInputProps, + | 'inputDisabled' | 'shouldRenderInput' | 'onPressSendUserMessage' | 'onPressSendFileMessage' diff --git a/packages/uikit-react-native/src/domain/openChannel/component/OpenChannelInput.tsx b/packages/uikit-react-native/src/domain/openChannel/component/OpenChannelInput.tsx index a5a814d35..4bb1cca7b 100644 --- a/packages/uikit-react-native/src/domain/openChannel/component/OpenChannelInput.tsx +++ b/packages/uikit-react-native/src/domain/openChannel/component/OpenChannelInput.tsx @@ -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 { @@ -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} /> ); diff --git a/packages/uikit-react-native/src/domain/openChannel/types.ts b/packages/uikit-react-native/src/domain/openChannel/types.ts index 8294794b4..564f37d18 100644 --- a/packages/uikit-react-native/src/domain/openChannel/types.ts +++ b/packages/uikit-react-native/src/domain/openChannel/types.ts @@ -72,6 +72,7 @@ export type OpenChannelProps = { >; Input: Pick< ChannelInputProps, + | 'inputDisabled' | 'shouldRenderInput' | 'onPressSendUserMessage' | 'onPressSendFileMessage' From 754e029245694b6392bdb9e10596635ad10dfd64 Mon Sep 17 00:00:00 2001 From: bang9 Date: Mon, 1 Apr 2024 10:59:58 +0900 Subject: [PATCH 2/3] chore: mark as optional --- .../uikit-react-native/src/domain/groupChannel/types.ts | 7 ++++--- .../uikit-react-native/src/domain/openChannel/types.ts | 7 ++++--- packages/uikit-utils/src/types.ts | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/uikit-react-native/src/domain/groupChannel/types.ts b/packages/uikit-react-native/src/domain/groupChannel/types.ts index 25ea4d399..2bdcbabf4 100644 --- a/packages/uikit-react-native/src/domain/groupChannel/types.ts +++ b/packages/uikit-react-native/src/domain/groupChannel/types.ts @@ -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, @@ -91,16 +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, - | 'inputDisabled' | 'shouldRenderInput' | 'onPressSendUserMessage' | 'onPressSendFileMessage' | 'onPressUpdateUserMessage' | 'onPressUpdateFileMessage' | 'SuggestedMentionList' - | 'AttachmentsButton' + | 'AttachmentsButton', + 'inputDisabled' >; SuggestedMentionList: SuggestedMentionListProps; diff --git a/packages/uikit-react-native/src/domain/openChannel/types.ts b/packages/uikit-react-native/src/domain/openChannel/types.ts index 564f37d18..1a160aa41 100644 --- a/packages/uikit-react-native/src/domain/openChannel/types.ts +++ b/packages/uikit-react-native/src/domain/openChannel/types.ts @@ -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, @@ -70,15 +71,15 @@ export type OpenChannelProps = { | 'flatListProps' | 'hasNext' >; - Input: Pick< + Input: PickPartial< ChannelInputProps, - | 'inputDisabled' | 'shouldRenderInput' | 'onPressSendUserMessage' | 'onPressSendFileMessage' | 'onPressUpdateUserMessage' | 'onPressUpdateFileMessage' - | 'AttachmentsButton' + | 'AttachmentsButton', + 'inputDisabled' >; Provider: { diff --git a/packages/uikit-utils/src/types.ts b/packages/uikit-utils/src/types.ts index 5f60d4658..de34a70ee 100644 --- a/packages/uikit-utils/src/types.ts +++ b/packages/uikit-utils/src/types.ts @@ -70,6 +70,8 @@ export type PartialNullable = { [P in keyof T]?: T[P] | null; }; +export type PickPartial = Pick & Partial>; + export type Optional = T | undefined; export type ContextValue> = T extends React.Context ? V : never; From 2e3e41571d85f83bdcdf053001d0b9d9a0a88800 Mon Sep 17 00:00:00 2001 From: bang9 Date: Mon, 8 Apr 2024 13:17:29 +0900 Subject: [PATCH 3/3] chore: update mock files --- packages/uikit-testing-tools/src/mocks/createMockChannel.ts | 4 ++++ packages/uikit-testing-tools/src/mocks/createMockMessage.ts | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/uikit-testing-tools/src/mocks/createMockChannel.ts b/packages/uikit-testing-tools/src/mocks/createMockChannel.ts index 35cdb4e49..f874c144a 100644 --- a/packages/uikit-testing-tools/src/mocks/createMockChannel.ts +++ b/packages/uikit-testing-tools/src/mocks/createMockChannel.ts @@ -121,6 +121,7 @@ class MockChannel implements GetMockProps { updateFeedback(_: Feedback): Promise { return Promise.resolve(undefined); } + markThreadAsRead(): Promise { + return Promise.resolve(); + } + setPushNotificationEnabled(_: boolean): Promise { + return Promise.resolve(); + } asFileMessage(): SendbirdFileMessage { return this as unknown as SendbirdFileMessage;