Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32187553
D9389.1765087366.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D9389.1765087366.diff
View Options
diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js
--- a/lib/utils/entity-text.js
+++ b/lib/utils/entity-text.js
@@ -365,6 +365,7 @@
type RenderFunctions = {
+renderText: ({ +text: string }) => React.Node,
+renderThread: ({ +id: string, +name: string }) => React.Node,
+ +renderUser: ({ +userID: string, usernameText: string }) => React.Node,
+renderColor: ({ +hex: string }) => React.Node,
};
function entityTextToReact(
@@ -372,7 +373,7 @@
threadID: string,
renderFuncs: RenderFunctions,
): React.Node {
- const { renderText, renderThread, renderColor } = renderFuncs;
+ const { renderText, renderThread, renderUser, renderColor } = renderFuncs;
// ESLint doesn't recognize that invariant always throws
// eslint-disable-next-line consistent-return
return entityText.map((entity, i) => {
@@ -402,7 +403,14 @@
</React.Fragment>
);
} else if (entity.type === 'user') {
- return getNameForUserEntity(entity);
+ const userID = entity.id;
+ const usernameText = getNameForUserEntity(entity);
+
+ return (
+ <React.Fragment key={key}>
+ {renderUser({ userID, usernameText })}
+ </React.Fragment>
+ );
} else {
invariant(
false,
diff --git a/native/chat/inner-robotext-message.react.js b/native/chat/inner-robotext-message.react.js
--- a/native/chat/inner-robotext-message.react.js
+++ b/native/chat/inner-robotext-message.react.js
@@ -21,6 +21,7 @@
import { useSelector } from '../redux/redux-utils.js';
import { useOverlayStyles } from '../themes/colors.js';
import type { ChatRobotextMessageInfoItemWithHeight } from '../types/chat-types.js';
+import { useNavigateToUserProfileBottomSheet } from '../user-profile/user-profile-utils.js';
function dummyNodeForRobotextMessageHeightMeasurement(
robotext: EntityText,
@@ -75,6 +76,10 @@
// eslint-disable-next-line react/display-name
renderThread: ({ id, name }) => <ThreadEntity id={id} name={name} />,
// eslint-disable-next-line react/display-name
+ renderUser: ({ userID, usernameText }) => (
+ <UserEntity userID={userID} usernameText={usernameText} />
+ ),
+ // eslint-disable-next-line react/display-name
renderColor: ({ hex }) => <ColorEntity color={hex} />,
});
}, [robotextWithENSNames, activeTheme, threadID, styles.robotext]);
@@ -114,6 +119,30 @@
);
}
+type UserEntityProps = {
+ userID: string,
+ usernameText: string,
+};
+function UserEntity(props: UserEntityProps) {
+ const { userID, usernameText } = props;
+
+ const styles = useOverlayStyles(unboundStyles);
+
+ const navigateToUserProfileBottomSheet =
+ useNavigateToUserProfileBottomSheet();
+
+ const onPressUser = React.useCallback(
+ () => navigateToUserProfileBottomSheet(userID),
+ [navigateToUserProfileBottomSheet, userID],
+ );
+
+ return (
+ <Text style={styles.link} onPress={onPressUser}>
+ {usernameText}
+ </Text>
+ );
+}
+
function ColorEntity(props: { +color: string }) {
const colorStyle = { color: props.color };
return <Text style={colorStyle}>{props.color}</Text>;
diff --git a/web/chat/robotext-message.react.js b/web/chat/robotext-message.react.js
--- a/web/chat/robotext-message.react.js
+++ b/web/chat/robotext-message.react.js
@@ -69,6 +69,10 @@
// eslint-disable-next-line react/display-name
renderThread: ({ id, name }) => <ThreadEntity id={id} name={name} />,
// eslint-disable-next-line react/display-name
+ renderUser: ({ userID, usernameText }) => (
+ <UserEntity userID={userID} usernameText={usernameText} />
+ ),
+ // eslint-disable-next-line react/display-name
renderColor: ({ hex }) => <ColorEntity color={hex} />,
});
}, [robotextWithENSNames, threadID]);
@@ -134,6 +138,19 @@
},
);
+type UserEntityProps = {
+ userID: string,
+ usernameText: string,
+};
+// Since entityTextToReact lives in lib I created this dummy UserEntity
+// component for web that will be used temporarily to appease flow
+// https://phab.comm.dev/D9389
+function UserEntity(props: UserEntityProps) {
+ const { usernameText } = props;
+
+ return usernameText;
+}
+
function ColorEntity(props: { color: string }) {
const colorStyle = { color: props.color };
return <span style={colorStyle}>{props.color}</span>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 6:02 AM (19 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842685
Default Alt Text
D9389.1765087366.diff (4 KB)
Attached To
Mode
D9389: [lib/native/web] make user profile accessible from a user entity in a robotext
Attached
Detach File
Event Timeline
Log In to Comment