Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3183859
D7343.id24783.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7343.id24783.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7343: [native] Added edit button to the Tooltip
Attached
Detach File
Event Timeline
Log In to Comment