Skip to content

Commit 66dc1ca

Browse files
committed
chore: resolve conflicts from base branch
2 parents 0edcacd + 86fe540 commit 66dc1ca

File tree

14 files changed

+141
-77
lines changed

14 files changed

+141
-77
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { ChannelContextValue, ChannelProvider } from '../../contexts/channelCont
5555
import type { UseChannelStateValue } from '../../contexts/channelsStateContext/useChannelState';
5656
import { useChannelState } from '../../contexts/channelsStateContext/useChannelState';
5757
import { ChatContextValue, useChatContext } from '../../contexts/chatContext/ChatContext';
58+
import { MessageComposerProvider } from '../../contexts/messageComposerContext/MessageComposerContext';
5859
import {
5960
InputMessageInputContextValue,
6061
MessageInputProvider,
@@ -1695,7 +1696,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
16951696
channel,
16961697
channelUnreadState,
16971698
disabled: !!channel?.data?.frozen,
1698-
editing,
16991699
EmptyStateIndicator,
17001700
enableMessageGroupingByUser,
17011701
enforceUniqueReaction,
@@ -1946,6 +1946,11 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19461946
typing: channelState.typing ?? {},
19471947
});
19481948

1949+
const messageComposerContext = useMemo(
1950+
() => ({ channel, editing, thread, threadInstance }),
1951+
[channel, editing, thread, threadInstance],
1952+
);
1953+
19491954
// TODO: replace the null view with appropriate message. Currently this is waiting a design decision.
19501955
if (deleted) {
19511956
return null;
@@ -1977,10 +1982,12 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19771982
<MessagesProvider value={messagesContext}>
19781983
<ThreadProvider value={threadContext}>
19791984
<AttachmentPickerProvider value={attachmentPickerContext}>
1980-
<MessageInputProvider value={inputMessageInputContext}>
1981-
<View style={{ height: '100%' }}>{children}</View>
1982-
<AttachmentPicker ref={bottomSheetRef} {...attachmentPickerProps} />
1983-
</MessageInputProvider>
1985+
<MessageComposerProvider value={messageComposerContext}>
1986+
<MessageInputProvider value={inputMessageInputContext}>
1987+
<View style={{ height: '100%' }}>{children}</View>
1988+
<AttachmentPicker ref={bottomSheetRef} {...attachmentPickerProps} />
1989+
</MessageInputProvider>
1990+
</MessageComposerProvider>
19841991
</AttachmentPickerProvider>
19851992
</ThreadProvider>
19861993
</MessagesProvider>

package/src/components/Channel/hooks/useCreateChannelContext.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const useCreateChannelContext = ({
66
channel,
77
channelUnreadState,
88
disabled,
9-
editing,
109
EmptyStateIndicator,
1110
enableMessageGroupingByUser,
1211
enforceUniqueReaction,
@@ -46,14 +45,12 @@ export const useCreateChannelContext = ({
4645
const readUsersLength = readUsers.length;
4746
const readUsersLastReads = readUsers.map(({ last_read }) => last_read.toISOString()).join();
4847
const stringifiedChannelUnreadState = JSON.stringify(channelUnreadState);
49-
const editingDep = editing ? editing.id : '';
5048

5149
const channelContext: ChannelContextValue = useMemo(
5250
() => ({
5351
channel,
5452
channelUnreadState,
5553
disabled,
56-
editing,
5754
EmptyStateIndicator,
5855
enableMessageGroupingByUser,
5956
enforceUniqueReaction,
@@ -89,7 +86,6 @@ export const useCreateChannelContext = ({
8986
[
9087
channelId,
9188
disabled,
92-
editingDep,
9389
error,
9490
isChannelActive,
9591
highlightedMessageId,

package/src/components/Message/Message.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useMessageActions } from './hooks/useMessageActions';
99
import { useProcessReactions } from './hooks/useProcessReactions';
1010
import { messageActions as defaultMessageActions } from './utils/messageActions';
1111

12+
import { useMessageComposer } from '../../contexts';
1213
import {
1314
ChannelContextValue,
1415
useChannelContext,
@@ -31,6 +32,7 @@ import {
3132
useTranslationContext,
3233
} from '../../contexts/translationContext/TranslationContext';
3334

35+
import { useStableCallback } from '../../hooks';
3436
import { isVideoPlayerAvailable, NativeHandlers } from '../../native';
3537
import { FileTypes } from '../../types/types';
3638
import {
@@ -140,7 +142,10 @@ export type MessagePropsWithContext = Pick<
140142
'groupStyles' | 'handleReaction' | 'message' | 'isMessageAIGenerated' | 'readBy'
141143
>
142144
> &
143-
Pick<MessageContextValue, 'groupStyles' | 'message' | 'isMessageAIGenerated' | 'readBy'> &
145+
Pick<
146+
MessageContextValue,
147+
'groupStyles' | 'message' | 'isMessageAIGenerated' | 'readBy' | 'setQuotedMessage'
148+
> &
144149
Pick<
145150
MessagesContextValue,
146151
| 'sendReaction'
@@ -264,6 +269,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
264269
threadList = false,
265270
updateMessage,
266271
readBy,
272+
setQuotedMessage,
267273
} = props;
268274
const isMessageAIGenerated = messagesContext.isMessageAIGenerated;
269275
const isAIGenerated = useMemo(
@@ -499,6 +505,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
499505
retrySendMessage,
500506
sendReaction,
501507
setEditingState,
508+
setQuotedMessage,
502509
supportedReactions,
503510
});
504511

@@ -543,6 +550,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
543550
selectReaction,
544551
sendReaction,
545552
setEditingState,
553+
setQuotedMessage,
546554
supportedReactions,
547555
t,
548556
updateMessage,
@@ -691,6 +699,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
691699
reactions,
692700
readBy,
693701
setIsEditedMessageOpen,
702+
setQuotedMessage,
694703
showAvatar,
695704
showMessageOverlay,
696705
showMessageStatus: typeof showMessageStatus === 'boolean' ? showMessageStatus : isMyMessage,
@@ -938,6 +947,10 @@ export const Message = (props: MessageProps) => {
938947
const { openThread } = useThreadContext();
939948
const { t } = useTranslationContext();
940949
const readBy = useMemo(() => getReadState(message, read), [message, read]);
950+
const messageComposer = useMessageComposer();
951+
const setQuotedMessage = useStableCallback((message: LocalMessage | null) =>
952+
messageComposer.setQuotedMessage(message),
953+
);
941954

942955
return (
943956
<MemoizedMessage
@@ -951,6 +964,7 @@ export const Message = (props: MessageProps) => {
951964
messagesContext,
952965
openThread,
953966
readBy,
967+
setQuotedMessage,
954968
t,
955969
}}
956970
{...props}

package/src/components/Message/MessageSimple/MessageSimple.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
MessageContextValue,
1919
useMessageContext,
2020
} from '../../../contexts/messageContext/MessageContext';
21-
import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer';
2221
import {
2322
MessagesContextValue,
2423
useMessagesContext,
@@ -70,6 +69,7 @@ export type MessageSimplePropsWithContext = Pick<
7069
| 'onlyEmojis'
7170
| 'otherAttachments'
7271
| 'showMessageStatus'
72+
| 'setQuotedMessage'
7373
> &
7474
Pick<
7575
MessagesContextValue,
@@ -130,6 +130,7 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
130130
ReactionListTop,
131131
showMessageStatus,
132132
shouldRenderSwipeableWrapper,
133+
setQuotedMessage,
133134
} = props;
134135

135136
const {
@@ -161,7 +162,6 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
161162
isVeryLastMessage,
162163
messageGroupedSingleOrBottom,
163164
} = useMessageData({});
164-
const messageComposer = useMessageComposer();
165165

166166
const lastMessageInMessageListStyles = [styles.lastMessageContainer, lastMessageContainer];
167167
const messageGroupedSingleOrBottomStyles = {
@@ -215,8 +215,8 @@ const MessageSimpleWithContext = (props: MessageSimplePropsWithContext) => {
215215
);
216216

217217
const onSwipeToReply = useCallback(() => {
218-
messageComposer.setQuotedMessage(message);
219-
}, [messageComposer, message]);
218+
setQuotedMessage(message);
219+
}, [setQuotedMessage, message]);
220220

221221
const THRESHOLD = 25;
222222

@@ -608,6 +608,7 @@ export const MessageSimple = (props: MessageSimpleProps) => {
608608
otherAttachments,
609609
showMessageStatus,
610610
isMessageAIGenerated,
611+
setQuotedMessage,
611612
} = useMessageContext();
612613
const {
613614
enableMessageGroupingByUser,
@@ -662,6 +663,7 @@ export const MessageSimple = (props: MessageSimpleProps) => {
662663
ReactionListBottom,
663664
reactionListPosition,
664665
ReactionListTop,
666+
setQuotedMessage,
665667
shouldRenderSwipeableWrapper,
666668
showMessageStatus,
667669
}}

package/src/components/Message/hooks/useCreateMessageContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const useCreateMessageContext = ({
4141
showMessageStatus,
4242
threadList,
4343
videos,
44+
setQuotedMessage,
4445
}: MessageContextValue) => {
4546
const groupStylesLength = groupStyles.length;
4647
const reactionsValue = reactions.map(({ count, own, type }) => `${own}${type}${count}`).join();
@@ -84,6 +85,7 @@ export const useCreateMessageContext = ({
8485
reactions,
8586
readBy,
8687
setIsEditedMessageOpen,
88+
setQuotedMessage,
8789
showAvatar,
8890
showMessageOverlay,
8991
showMessageStatus,

package/src/components/Message/hooks/useMessageActionHandlers.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Alert } from 'react-native';
33
import type { ChannelContextValue } from '../../../contexts/channelContext/ChannelContext';
44
import type { ChatContextValue } from '../../../contexts/chatContext/ChatContext';
55
import type { MessageContextValue } from '../../../contexts/messageContext/MessageContext';
6-
import { useMessageComposer } from '../../../contexts/messageInputContext/hooks/useMessageComposer';
76
import type { MessagesContextValue } from '../../../contexts/messagesContext/MessagesContext';
87

98
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
@@ -18,6 +17,7 @@ export const useMessageActionHandlers = ({
1817
retrySendMessage,
1918
sendReaction,
2019
setEditingState,
20+
setQuotedMessage,
2121
}: Pick<
2222
MessagesContextValue,
2323
| 'sendReaction'
@@ -29,13 +29,12 @@ export const useMessageActionHandlers = ({
2929
> &
3030
Pick<ChannelContextValue, 'channel' | 'enforceUniqueReaction'> &
3131
Pick<ChatContextValue, 'client'> &
32-
Pick<MessageContextValue, 'message'>) => {
32+
Pick<MessageContextValue, 'message' | 'setQuotedMessage'>) => {
3333
const { t } = useTranslationContext();
3434
const handleResendMessage = () => retrySendMessage(message);
35-
const messageComposer = useMessageComposer();
3635

3736
const handleQuotedReplyMessage = () => {
38-
messageComposer.setQuotedMessage(message);
37+
setQuotedMessage(message);
3938
};
4039

4140
const isMuted = (client.mutedUsers || []).some(

package/src/components/Message/hooks/useMessageActions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export type MessageActionsHookProps = Pick<
5858
Pick<ChannelContextValue, 'channel' | 'enforceUniqueReaction'> &
5959
Pick<ChatContextValue, 'client'> &
6060
Pick<ThreadContextValue, 'openThread'> &
61-
Pick<MessageContextValue, 'dismissOverlay' | 'message'> &
61+
Pick<MessageContextValue, 'dismissOverlay' | 'message' | 'setQuotedMessage'> &
6262
Pick<TranslationContextValue, 't'> & {
6363
onThreadSelect?: (message: LocalMessage) => void;
6464
};
@@ -91,6 +91,7 @@ export const useMessageActions = ({
9191
setEditingState,
9292
supportedReactions,
9393
t,
94+
setQuotedMessage,
9495
}: MessageActionsHookProps) => {
9596
const {
9697
theme: {
@@ -119,6 +120,7 @@ export const useMessageActions = ({
119120
retrySendMessage,
120121
sendReaction,
121122
setEditingState,
123+
setQuotedMessage,
122124
supportedReactions,
123125
});
124126

0 commit comments

Comments
 (0)