Skip to content

Commit a0f8463

Browse files
authored
Merge pull request #599 from GetStream/message-overlay-theme-fix
CRNS-306 - fix theme on outer overlay for my message
2 parents e8c93d3 + 7bbb812 commit a0f8463

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

src/components/Message/MessageSimple/MessageTextContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type MessageTextContainerPropsWithContext<
6464
'markdownRules' | 'MessageText'
6565
> & {
6666
markdownStyles?: MarkdownStyle;
67+
messageOverlay?: boolean;
6768
styles?: Partial<{
6869
textContainer: StyleProp<ViewStyle>;
6970
}>;
@@ -86,6 +87,7 @@ const MessageTextContainerWithContext = <
8687
markdownRules,
8788
markdownStyles: markdownStylesProp = {},
8889
message,
90+
messageOverlay,
8991
MessageText,
9092
onLongPress,
9193
onlyEmojis,
@@ -125,6 +127,7 @@ const MessageTextContainerWithContext = <
125127
...(onlyEmojis ? onlyEmojiMarkdown : {}),
126128
},
127129
message,
130+
messageOverlay,
128131
onLongPress,
129132
onlyEmojis,
130133
onPress,

src/components/Message/MessageSimple/utils/renderText.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export type RenderTextParams<
7979
message: MessageType<At, Ch, Co, Ev, Me, Re, Us>;
8080
markdownRules?: MarkdownRules;
8181
markdownStyles?: MarkdownStyle;
82+
messageOverlay?: boolean;
8283
onLink?: (url: string) => Promise<void>;
8384
onlyEmojis?: boolean;
8485
};
@@ -99,6 +100,7 @@ export const renderText = <
99100
markdownRules,
100101
markdownStyles,
101102
message,
103+
messageOverlay,
102104
onLink: onLinkParams,
103105
onLongPress: propOnLongPress,
104106
onlyEmojis,
@@ -252,7 +254,9 @@ export const renderText = <
252254

253255
return (
254256
<Markdown
255-
key={`${JSON.stringify(mentioned_users)}-${onlyEmojis}`}
257+
key={`${JSON.stringify(mentioned_users)}-${onlyEmojis}-${
258+
messageOverlay ? JSON.stringify(markdownStyles) : undefined
259+
}`}
256260
onLink={onLink}
257261
rules={{
258262
...customRules,

src/components/MessageOverlay/MessageOverlay.tsx

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -150,24 +150,9 @@ const MessageOverlayWithContext = <
150150

151151
const { theme } = useTheme();
152152

153-
const {
154-
colors: {
155-
blue_alice,
156-
grey_gainsboro,
157-
grey_whisper,
158-
transparent,
159-
white_smoke,
160-
},
161-
messageSimple: {
162-
content: {
163-
container: { borderRadiusL, borderRadiusS },
164-
containerInner,
165-
replyContainer,
166-
},
167-
},
168-
} = theme;
169-
170153
const myMessageTheme = messagesContext?.myMessageTheme;
154+
const wrapMessageInTheme = clientId === message?.user?.id && !!myMessageTheme;
155+
171156
const [myMessageThemeString, setMyMessageThemeString] = useState(
172157
JSON.stringify(myMessageTheme),
173158
);
@@ -183,6 +168,23 @@ const MessageOverlayWithContext = <
183168
[myMessageThemeString, theme],
184169
);
185170

171+
const {
172+
colors: {
173+
blue_alice,
174+
grey_gainsboro,
175+
grey_whisper,
176+
transparent,
177+
white_smoke,
178+
},
179+
messageSimple: {
180+
content: {
181+
container: { borderRadiusL, borderRadiusS },
182+
containerInner,
183+
replyContainer,
184+
},
185+
},
186+
} = wrapMessageInTheme ? modifiedTheme : theme;
187+
186188
const scrollViewRef = useRef<ScrollView>(null);
187189

188190
const messageHeight = useSharedValue(0);
@@ -334,8 +336,6 @@ const MessageOverlayWithContext = <
334336
const { Attachment, FileAttachmentGroup, Gallery, MessageAvatar, Reply } =
335337
messagesContext || {};
336338

337-
const wrapMessageInTheme = clientId === message?.user?.id && !!myMessageTheme;
338-
339339
return (
340340
<MessagesProvider<At, Ch, Co, Ev, Me, Re, Us> value={messagesContext}>
341341
<ThemeProvider mergedStyle={wrapMessageInTheme ? modifiedTheme : theme}>
@@ -544,6 +544,7 @@ const MessageOverlayWithContext = <
544544
>
545545
key={`message_text_container_${messageContentOrderIndex}`}
546546
message={message}
547+
messageOverlay
547548
onlyEmojis={onlyEmojis}
548549
/>
549550
);

0 commit comments

Comments
 (0)