Page MenuHomePhorge

D5755.1765257424.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D5755.1765257424.diff

diff --git a/native/chat/text-message-markdown-context.js b/native/chat/text-message-markdown-context.js
--- a/native/chat/text-message-markdown-context.js
+++ b/native/chat/text-message-markdown-context.js
@@ -3,7 +3,7 @@
import * as React from 'react';
import * as SimpleMarkdown from 'simple-markdown';
-import type { SingleASTNode } from 'lib/shared/markdown';
+import type { ASTNode, SingleASTNode } from 'lib/shared/markdown';
import { messageKey } from 'lib/shared/message-utils';
import type { TextMessageInfo } from 'lib/types/messages/text';
@@ -12,11 +12,27 @@
export type TextMessageMarkdownContextType = {
+messageKey: string,
+markdownAST: $ReadOnlyArray<SingleASTNode>,
+ +markdownHasPressable: boolean,
};
const TextMessageMarkdownContext: React.Context<?TextMessageMarkdownContextType> = React.createContext<?TextMessageMarkdownContextType>(
null,
);
+const pressableMarkdownTypes = new Set(['link']);
+const markdownASTHasPressable = (node: ASTNode): boolean => {
+ if (Array.isArray(node)) {
+ return node.some(markdownASTHasPressable);
+ }
+ const { type, content, items } = node;
+ if (pressableMarkdownTypes.has(type)) {
+ return true;
+ } else if (items) {
+ return markdownASTHasPressable(items);
+ } else if (content) {
+ return markdownASTHasPressable(content);
+ }
+ return false;
+};
function useTextMessageMarkdown(
messageInfo: TextMessageInfo,
@@ -37,6 +53,7 @@
() => ({
messageKey: key,
markdownAST: ast,
+ markdownHasPressable: markdownASTHasPressable(ast),
}),
[key, ast],
);

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 9, 5:17 AM (15 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5852740
Default Alt Text
D5755.1765257424.diff (1 KB)

Event Timeline