Skip to content

Commit c2e8698

Browse files
authored
Merge pull request #170 from sendbird/feat/public-input-disabled-prop
feat(CLNP-2719): inputDisabled prop opened as public
2 parents 5cc9300 + 2e3e415 commit c2e8698

File tree

7 files changed

+26
-10
lines changed

7 files changed

+26
-10
lines changed

packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ChannelInput from '../../../components/ChannelInput';
66
import { GroupChannelContexts } from '../module/moduleContext';
77
import type { GroupChannelProps } from '../types';
88

9-
const GroupChannelInput = (props: GroupChannelProps['Input']) => {
9+
const GroupChannelInput = ({ inputDisabled, ...props }: GroupChannelProps['Input']) => {
1010
const {
1111
channel,
1212
keyboardAvoidOffset = 0,
@@ -25,10 +25,10 @@ const GroupChannelInput = (props: GroupChannelProps['Input']) => {
2525
setMessageToEdit={setMessageToEdit}
2626
messageToReply={messageToReply}
2727
setMessageToReply={setMessageToReply}
28+
keyboardAvoidOffset={keyboardAvoidOffset}
2829
inputMuted={chatAvailableState.muted}
2930
inputFrozen={chatAvailableState.frozen}
30-
inputDisabled={chatAvailableState.disabled}
31-
keyboardAvoidOffset={keyboardAvoidOffset}
31+
inputDisabled={inputDisabled ?? chatAvailableState.disabled}
3232
{...props}
3333
/>
3434
);

packages/uikit-react-native/src/domain/groupChannel/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { MessageCollectionParams, MessageFilterParams } from '@sendbird/cha
55
import type { UseGroupChannelMessagesOptions } from '@sendbird/uikit-chat-hooks';
66
import type {
77
OnBeforeHandler,
8+
PickPartial,
89
SendbirdFileMessage,
910
SendbirdFileMessageCreateParams,
1011
SendbirdFileMessageUpdateParams,
@@ -91,15 +92,16 @@ export interface GroupChannelProps {
9192
// Changing the search item will trigger the focus animation on messages.
9293
onUpdateSearchItem: (searchItem?: GroupChannelProps['MessageList']['searchItem']) => void;
9394
};
94-
Input: Pick<
95+
Input: PickPartial<
9596
ChannelInputProps,
9697
| 'shouldRenderInput'
9798
| 'onPressSendUserMessage'
9899
| 'onPressSendFileMessage'
99100
| 'onPressUpdateUserMessage'
100101
| 'onPressUpdateFileMessage'
101102
| 'SuggestedMentionList'
102-
| 'AttachmentsButton'
103+
| 'AttachmentsButton',
104+
'inputDisabled'
103105
>;
104106

105107
SuggestedMentionList: SuggestedMentionListProps;

packages/uikit-react-native/src/domain/openChannel/component/OpenChannelInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { useSendbirdChat } from '../../../hooks/useContext';
99
import { OpenChannelContexts } from '../module/moduleContext';
1010
import type { OpenChannelProps } from '../types';
1111

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

1515
const {
@@ -64,10 +64,10 @@ const OpenChannelInput = (props: OpenChannelProps['Input']) => {
6464
channel={channel}
6565
messageToEdit={messageToEdit}
6666
setMessageToEdit={setMessageToEdit}
67+
keyboardAvoidOffset={keyboardAvoidOffset}
6768
inputMuted={chatAvailableState.muted}
6869
inputFrozen={channel.isFrozen}
69-
inputDisabled={chatAvailableState.disabled}
70-
keyboardAvoidOffset={keyboardAvoidOffset}
70+
inputDisabled={inputDisabled ?? chatAvailableState.disabled}
7171
{...props}
7272
/>
7373
);

packages/uikit-react-native/src/domain/openChannel/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { UseOpenChannelMessagesOptions } from '@sendbird/uikit-chat-hooks';
44
import type { Icon } from '@sendbird/uikit-react-native-foundation';
55
import type {
66
OnBeforeHandler,
7+
PickPartial,
78
SendbirdFileMessage,
89
SendbirdFileMessageCreateParams,
910
SendbirdFileMessageUpdateParams,
@@ -70,14 +71,15 @@ export type OpenChannelProps = {
7071
| 'flatListProps'
7172
| 'hasNext'
7273
>;
73-
Input: Pick<
74+
Input: PickPartial<
7475
ChannelInputProps,
7576
| 'shouldRenderInput'
7677
| 'onPressSendUserMessage'
7778
| 'onPressSendFileMessage'
7879
| 'onPressUpdateUserMessage'
7980
| 'onPressUpdateFileMessage'
80-
| 'AttachmentsButton'
81+
| 'AttachmentsButton',
82+
'inputDisabled'
8183
>;
8284

8385
Provider: {

packages/uikit-testing-tools/src/mocks/createMockChannel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class MockChannel implements GetMockProps<Params, SendbirdBaseChannel & Sendbird
121121
pinnedMessageIds = [];
122122
unreadMentionCount = 0;
123123
unreadMessageCount = 0;
124+
totalUnreadReplyCount = 0;
124125

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

641+
createThreadedParentMessageListQuery(): PreviousMessageListQuery {
642+
throw new Error('Method not implemented.');
643+
}
640644
createPinnedMessageListQuery(_params?: PinnedMessageListQueryParams | undefined): PinnedMessageListQuery {
641645
throw new Error('Method not implemented.');
642646
}

packages/uikit-testing-tools/src/mocks/createMockMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ class MockMessage implements GetMockProps<Params, SendbirdBaseMessage> {
134134
updateFeedback(_: Feedback): Promise<void> {
135135
return Promise.resolve(undefined);
136136
}
137+
markThreadAsRead(): Promise<void> {
138+
return Promise.resolve();
139+
}
140+
setPushNotificationEnabled(_: boolean): Promise<void> {
141+
return Promise.resolve();
142+
}
137143

138144
asFileMessage(): SendbirdFileMessage {
139145
return this as unknown as SendbirdFileMessage;

packages/uikit-utils/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export type PartialNullable<T> = {
7070
[P in keyof T]?: T[P] | null;
7171
};
7272

73+
export type PickPartial<T, PK extends keyof T, PPK extends keyof T> = Pick<T, PK> & Partial<Pick<T, PPK>>;
74+
7375
export type Optional<T> = T | undefined;
7476

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

0 commit comments

Comments
 (0)