Page MenuHomePhabricator

D5541.id18152.diff
No OneTemporary

D5541.id18152.diff

diff --git a/native/chat/inner-text-message.react.js b/native/chat/inner-text-message.react.js
--- a/native/chat/inner-text-message.react.js
+++ b/native/chat/inner-text-message.react.js
@@ -13,6 +13,7 @@
import { useColors, colors } from '../themes/colors';
import type { ChatTextMessageInfoItemWithHeight } from '../types/chat-types';
import { useComposedMessageMaxWidth } from './composed-message-width';
+import { MessageContext } from './message-context.react';
import { MessageListContext } from './message-list-types';
import {
allCorners,
@@ -101,6 +102,11 @@
return [styles.text, textStyle];
}, [darkColor]);
+ const contextValue = {
+ messageID: item.messageInfo.id ?? '',
+ messageText: item.messageInfo.text,
+ };
+
const message = (
<TouchableWithoutFeedback>
<View>
@@ -111,9 +117,11 @@
style={[styles.message, cornerStyle]}
animatedStyle={messageStyle}
>
- <Markdown style={markdownStyles} rules={rules}>
- {text}
- </Markdown>
+ <MessageContext.Provider value={contextValue}>
+ <Markdown style={markdownStyles} rules={rules}>
+ {text}
+ </Markdown>
+ </MessageContext.Provider>
</GestureTouchableOpacity>
</View>
</TouchableWithoutFeedback>
diff --git a/native/markdown/markdown-context.js b/native/markdown/markdown-context.js
--- a/native/markdown/markdown-context.js
+++ b/native/markdown/markdown-context.js
@@ -9,6 +9,7 @@
+linkModalActive: { [key: string]: boolean },
+setLinkPressActive: SetState<{ [key: string]: boolean }>,
+linkPressActive: { [key: string]: boolean },
+
+setSpoilerRevealed: SetState<{ [key: string]: { [key: number]: boolean } }>,
+spoilerRevealed: { [key: string]: { [key: number]: boolean } },
+setSpoilerPressActive: SetState<boolean>,
diff --git a/native/markdown/markdown-spoiler.react.js b/native/markdown/markdown-spoiler.react.js
--- a/native/markdown/markdown-spoiler.react.js
+++ b/native/markdown/markdown-spoiler.react.js
@@ -19,10 +19,6 @@
const messageContext = React.useContext(MessageContext);
const styles = useStyles(unboundStyles);
- const [styleBasedOnState, setStyleBasedOnState] = React.useState(
- styles.spoilerHidden,
- );
-
const { messageID, messageText } = messageContext;
const text = props.text;
@@ -32,6 +28,12 @@
const spoilerIndex = messageText?.indexOf(text.toString());
+ const [styleBasedOnState, setStyleBasedOnState] = React.useState(
+ spoilerIndex && spoilerRevealed?.[messageID]?.[spoilerIndex]
+ ? null
+ : styles.spoilerHidden,
+ );
+
const onSpoilerClick = React.useCallback(() => {
if (styleBasedOnState === null) {
setSpoilerPressActive && setSpoilerPressActive(false);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 1, 5:02 PM (18 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2399411
Default Alt Text
D5541.id18152.diff (2 KB)

Event Timeline