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

fix: Room mention in the message is not highlighted #49769

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
89 changes: 47 additions & 42 deletions src/components/SelectionList/ChatListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import React, {useMemo} from 'react';
import {View} from 'react-native';
import {AttachmentContext} from '@components/AttachmentContext';
import MentionReportContext from '@components/HTMLEngineProvider/HTMLRenderers/MentionReportRenderer/MentionReportContext';
import MultipleAvatars from '@components/MultipleAvatars';
import {ShowContextMenuContext} from '@components/ShowContextMenuContext';
import TextWithTooltip from '@components/TextWithTooltip';
Expand Down Expand Up @@ -54,6 +55,8 @@ function ChatListItem<TItem extends ListItem>({
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
const hoveredBackgroundColor = styles.sidebarLinkHover?.backgroundColor ? styles.sidebarLinkHover.backgroundColor : theme.sidebar;

const mentionReportContextValue = useMemo(() => ({currentReportID: item?.reportID ?? ''}), [item.reportID]);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fallback to -1 is better?

return (
<BaseListItem
item={item}
Expand All @@ -77,49 +80,51 @@ function ChatListItem<TItem extends ListItem>({
hoverStyle={item.isSelected && styles.activeComponentBG}
>
{(hovered) => (
<ShowContextMenuContext.Provider value={contextValue}>
<AttachmentContext.Provider value={attachmentContextValue}>
<MultipleAvatars
icons={icons}
shouldShowTooltip={showTooltip}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar),
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
<View style={[styles.flexShrink1, styles.mr1]}>
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={reportActionItem.formattedFrom}
style={[
styles.chatItemMessageHeaderSender,
isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText,
styles.sidebarLinkTextBold,
styles.pre,
]}
/>
<MentionReportContext.Provider value={mentionReportContextValue}>
<ShowContextMenuContext.Provider value={contextValue}>
<AttachmentContext.Provider value={attachmentContextValue}>
<MultipleAvatars
icons={icons}
shouldShowTooltip={showTooltip}
secondAvatarStyle={[
StyleUtils.getBackgroundAndBorderStyle(theme.sidebar),
isFocused ? StyleUtils.getBackgroundAndBorderStyle(focusedBackgroundColor) : undefined,
hovered && !isFocused ? StyleUtils.getBackgroundAndBorderStyle(hoveredBackgroundColor) : undefined,
]}
/>
<View style={[styles.chatItemRight]}>
<View style={[styles.chatItemMessageHeader]}>
<View style={[styles.flexShrink1, styles.mr1]}>
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={reportActionItem.formattedFrom}
style={[
styles.chatItemMessageHeaderSender,
isFocused ? styles.sidebarLinkActiveText : styles.sidebarLinkText,
styles.sidebarLinkTextBold,
styles.pre,
]}
/>
</View>
<ReportActionItemDate created={reportActionItem.created ?? ''} />
</View>
<View style={styles.chatItemMessage}>
{reportActionItem.message.map((fragment, index) => (
<ReportActionItemFragment
// eslint-disable-next-line react/no-array-index-key
key={`actionFragment-${reportActionItem.reportActionID}-${index}`}
fragment={fragment}
actionName={reportActionItem.actionName}
source=""
accountID={from.accountID}
isFragmentContainingDisplayName={index === 0}
/>
))}
</View>
<ReportActionItemDate created={reportActionItem.created ?? ''} />
</View>
<View style={styles.chatItemMessage}>
{reportActionItem.message.map((fragment, index) => (
<ReportActionItemFragment
// eslint-disable-next-line react/no-array-index-key
key={`actionFragment-${reportActionItem.reportActionID}-${index}`}
fragment={fragment}
actionName={reportActionItem.actionName}
source=""
accountID={from.accountID}
isFragmentContainingDisplayName={index === 0}
/>
))}
</View>
</View>
</AttachmentContext.Provider>
</ShowContextMenuContext.Provider>
</AttachmentContext.Provider>
</ShowContextMenuContext.Provider>
</MentionReportContext.Provider>
)}
</BaseListItem>
);
Expand Down
Loading
Loading