Page MenuHomePhabricator

D7343.id24783.diff
No OneTemporary

D7343.id24783.diff

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,21 @@
[],
);
+ const { item } = route.params;
+ const { messageInfo } = item;
+
+ const onPressEdit = () => {
+ invariant(
+ inputState,
+ 'inputState should be set in TextMessageTooltipModal.onPressEdit',
+ );
+ inputState.setEditedMessageID(messageInfo.id);
+ };
+ const renderEditIcon = React.useCallback(
+ style => <SWMansionIcon name="edit-1" style={style} size={16} />,
+ [],
+ );
+
const onPressCopy = React.useCallback(() => {
Clipboard.setString(text);
setTimeout(confirmCopy);
@@ -85,6 +100,13 @@
renderIcon={renderSidebarIcon}
key="sidebar"
/>
+ <TooltipItem
+ id="edit"
+ text="Edit"
+ onPress={onPressEdit}
+ renderIcon={renderEditIcon}
+ key="edit"
+ />
<TooltipItem
id="copy"
text="Copy"
diff --git a/native/chat/text-message.react.js b/native/chat/text-message.react.js
--- a/native/chat/text-message.react.js
+++ b/native/chat/text-message.react.js
@@ -4,6 +4,7 @@
import * as React from 'react';
import { View } from 'react-native';
+import { useCanEditMessage } from 'lib/shared/edit-messages-utils.js';
import { messageKey } from 'lib/shared/message-utils.js';
import {
threadHasPermission,
@@ -31,6 +32,7 @@
import { fixedTooltipHeight } from '../tooltip/tooltip.react.js';
import type { ChatTextMessageInfoItemWithHeight } from '../types/chat-types.js';
import type { VerticalBounds } from '../types/layout-types.js';
+import { useShouldRenderEditButton } from '../utils/edit-messages-utils.js';
type BaseProps = {
...React.ElementConfig<typeof View>,
@@ -51,6 +53,8 @@
+chatContext: ?ChatContextType,
// MarkdownContext
+isLinkModalActive: boolean,
+ +canEditMessage: boolean,
+ +shouldRenderEditButton: boolean,
};
class TextMessage extends React.PureComponent<Props> {
message: ?React.ElementRef<typeof View>;
@@ -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 };

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 10:00 AM (21 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2451360
Default Alt Text
D7343.id24783.diff (3 KB)

Event Timeline