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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Defined with message type if the user is editing some message within `MessageInput` component else its undefined.

| Type |
| ------- |
| Boolean |
| Type |
| ----------------------- |
| `Message`\| `undefined` |
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Message that is quoted to the original message

| Type |
| --------------------------- |
| `Boolean` \| `Message` type |
| Type |
| ----------------------- |
| `Message`\| `undefined` |
6 changes: 3 additions & 3 deletions package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ const ChannelWithContext = <
const [loadingMore, setLoadingMore] = useState(false);

const [loadingMoreRecent, setLoadingMoreRecent] = useState(false);
const [quotedMessage, setQuotedMessage] = useState<boolean | MessageType<StreamChatGenerics>>(
false,
const [quotedMessage, setQuotedMessage] = useState<MessageType<StreamChatGenerics> | undefined>(
undefined,
);
const [thread, setThread] = useState<ThreadContextValue<StreamChatGenerics>['thread']>(
threadProps || null,
Expand Down Expand Up @@ -1940,7 +1940,7 @@ const ChannelWithContext = <
() => setEditing(undefined);

const clearQuotedMessageState: InputMessageInputContextValue<StreamChatGenerics>['clearQuotedMessageState'] =
() => setQuotedMessage(false);
() => setQuotedMessage(undefined);

/**
* Removes the message from local state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ export const useCreateInputMessageInputContext = <
*/
channelId?: string;
}) => {
const editingDep = typeof editing === 'boolean' ? editing : editing?.id;
const quotedMessageId = quotedMessage
? typeof quotedMessage === 'boolean'
? ''
: quotedMessage.id
: '';
const editingDep = editing ? editing.id : '';
const quotedMessageId = quotedMessage ? quotedMessage.id : '';

const inputMessageInputContext: InputMessageInputContextValue<StreamChatGenerics> = useMemo(
() => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const MessageAvatar = <
const { alignment, lastGroupMessage, message, showAvatar } =
useMessageContext<StreamChatGenerics>();
const { ImageComponent } = useChatContext<StreamChatGenerics>();

return (
<MemoizedMessageAvatar
{...{
Expand Down
4 changes: 2 additions & 2 deletions package/src/components/Reply/Reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ const ReplyWithContext = <
},
} = useTheme();

const messageText = typeof quotedMessage === 'boolean' ? '' : quotedMessage.text || '';
const messageText = quotedMessage ? quotedMessage.text : '';

const emojiOnlyText = useMemo(() => {
if (!messageText) return false;
return hasOnlyEmojis(messageText);
}, [messageText]);

if (typeof quotedMessage === 'boolean') return null;
if (!quotedMessage) return null;

const lastAttachment = quotedMessage.attachments?.slice(-1)[0] as Attachment<StreamChatGenerics>;
const messageType = lastAttachment && getMessageType(lastAttachment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ export type InputMessageInputContextValue<
MoreOptionsButton: React.ComponentType<MoreOptionsButtonProps<StreamChatGenerics>>;
/** Limit on the number of lines in the text input before scrolling */
numberOfLines: number;
quotedMessage: boolean | MessageType<StreamChatGenerics>;
/**
* Custom UI component for send button.
*
Expand Down Expand Up @@ -455,6 +454,7 @@ export type InputMessageInputContextValue<
* Callback that is called when the text input's text changes. Changed text is passed as a single string argument to the callback handler.
*/
onChangeText?: (newText: string) => void;
quotedMessage?: MessageType<StreamChatGenerics>;
SendMessageDisallowedIndicator?: React.ComponentType;
/**
* ref for input setter function
Expand Down Expand Up @@ -915,8 +915,7 @@ export const MessageInputProvider = <
mentioned_users: uniq(mentionedUsers),
/** Parent message id - in case of thread */
parent_id: thread?.id,
quoted_message_id:
typeof value.quotedMessage === 'boolean' ? undefined : value.quotedMessage.id,
quoted_message_id: value.quotedMessage ? value.quotedMessage.id : undefined,
show_in_channel: sendThreadMessageInChannel || undefined,
text: prevText,
...customMessageData,
Expand Down Expand Up @@ -956,8 +955,7 @@ export const MessageInputProvider = <
attachments,
mentioned_users: [],
parent_id: thread?.id,
quoted_message_id:
typeof value.quotedMessage === 'boolean' ? undefined : value.quotedMessage.id,
quoted_message_id: value.quotedMessage ? value.quotedMessage.id : undefined,
show_in_channel: sendThreadMessageInChannel || undefined,
text: '',
} as unknown as Partial<StreamMessage<StreamChatGenerics>>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ export const useCreateMessageInputContext = <
const imageUploadsValue = imageUploads.map(({ state }) => state).join();
const asyncUploadsValue = Object.keys(asyncUploads).join();
const mentionedUsersLength = mentionedUsers.length;
const quotedMessageId = quotedMessage
? typeof quotedMessage === 'boolean'
? ''
: quotedMessage.id
: '';
const quotedMessageId = quotedMessage ? quotedMessage.id : '';
const threadId = thread?.id;
const asyncIdsLength = asyncIds.length;

Expand Down
2 changes: 1 addition & 1 deletion package/src/contexts/messagesContext/MessagesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export type MessagesContextValue<
ScrollToBottomButton: React.ComponentType<ScrollToBottomButtonProps>;
sendReaction: (type: string, messageId: string) => Promise<void>;
setEditingState: (message?: MessageType<StreamChatGenerics>) => void;
setQuotedMessageState: (message: MessageType<StreamChatGenerics> | boolean) => void;
setQuotedMessageState: (message?: MessageType<StreamChatGenerics>) => void;
supportedReactions: ReactionData[];
/**
* UI component for TypingIndicator
Expand Down