diff --git a/native/chat/text-message-tooltip-modal.react.js b/native/chat/text-message-tooltip-modal.react.js
--- a/native/chat/text-message-tooltip-modal.react.js
+++ b/native/chat/text-message-tooltip-modal.react.js
@@ -54,6 +54,19 @@
[],
);
+ const { messageInfo } = route.params.item;
+ const onPressEdit = React.useCallback(() => {
+ invariant(
+ inputState,
+ 'inputState should be set in TextMessageTooltipModal.onPressEdit',
+ );
+ inputState.setEditedMessageID(messageInfo.id);
+ }, [inputState, messageInfo.id]);
+ const renderEditIcon = React.useCallback(
+ style => ,
+ [],
+ );
+
const onPressCopy = React.useCallback(() => {
Clipboard.setString(text);
setTimeout(confirmCopy);
@@ -85,6 +98,13 @@
renderIcon={renderSidebarIcon}
key="sidebar"
/>
+
,
@@ -51,6 +53,8 @@
+chatContext: ?ChatContextType,
// MarkdownContext
+isLinkModalActive: boolean,
+ +canEditMessage: boolean,
+ +shouldRenderEditButton: boolean,
};
class TextMessage extends React.PureComponent {
message: ?React.ElementRef;
@@ -75,6 +79,8 @@
chatContext,
isLinkModalActive,
canCreateSidebarFromMessage,
+ canEditMessage,
+ shouldRenderEditButton,
...viewProps
} = this.props;
@@ -137,6 +143,10 @@
result.push('reply');
}
+ if (this.props.canEditMessage && this.props.shouldRenderEditButton) {
+ result.push('edit');
+ }
+
if (
this.props.item.threadCreatedFromMessage ||
this.props.canCreateSidebarFromMessage
@@ -239,6 +249,13 @@
props.item.messageInfo,
);
+ const shouldRenderEditButton = useShouldRenderEditButton();
+
+ const canEditMessage = useCanEditMessage(
+ props.item.threadInfo,
+ props.item.messageInfo,
+ );
+
React.useEffect(() => clearMarkdownContextData, [clearMarkdownContextData]);
return (
@@ -248,6 +265,8 @@
overlayContext={overlayContext}
chatContext={chatContext}
isLinkModalActive={isLinkModalActive}
+ canEditMessage={canEditMessage}
+ shouldRenderEditButton={shouldRenderEditButton}
/>
);
});
diff --git a/native/utils/edit-messages-utils.js b/native/utils/edit-messages-utils.js
new file mode 100644
--- /dev/null
+++ b/native/utils/edit-messages-utils.js
@@ -0,0 +1,14 @@
+// @flow
+
+import * as React from 'react';
+
+import { FeatureFlagsContext } from '../components/feature-flags-provider.react.js';
+
+function useShouldRenderEditButton(): boolean {
+ const { configuration: featureFlagConfig } =
+ React.useContext(FeatureFlagsContext);
+
+ return !!featureFlagConfig['EDIT_BUTTON_DISPLAY'];
+}
+
+export { useShouldRenderEditButton };