Page MenuHomePhabricator

D7606.diff
No OneTemporary

D7606.diff

diff --git a/native/chat/chat-item-height-measurer.react.js b/native/chat/chat-item-height-measurer.react.js
--- a/native/chat/chat-item-height-measurer.react.js
+++ b/native/chat/chat-item-height-measurer.react.js
@@ -107,6 +107,7 @@
pendingUploads,
reactions: item.reactions,
hasBeenEdited: item.hasBeenEdited,
+ isPinned: item.isPinned,
...sizes,
};
}
@@ -133,6 +134,7 @@
contentHeight: height,
reactions: item.reactions,
hasBeenEdited: item.hasBeenEdited,
+ isPinned: item.isPinned,
};
}
invariant(
diff --git a/native/chat/multimedia-message-tooltip-modal.react.js b/native/chat/multimedia-message-tooltip-modal.react.js
--- a/native/chat/multimedia-message-tooltip-modal.react.js
+++ b/native/chat/multimedia-message-tooltip-modal.react.js
@@ -5,6 +5,7 @@
import { useOnPressReport } from './message-report-utils.js';
import MultimediaMessageTooltipButton from './multimedia-message-tooltip-button.react.js';
import { useAnimatedNavigateToSidebar } from './sidebar-navigation.js';
+import CommIcon from '../components/comm-icon.react.js';
import SWMansionIcon from '../components/swmansion-icon.react.js';
import {
createTooltip,
@@ -25,6 +26,16 @@
): React.Node {
const { route, tooltipItem: TooltipItem } = props;
+ const onPressTogglePin = React.useCallback(() => {}, []);
+ const renderPinIcon = React.useCallback(
+ style => <CommIcon name="pin-outline" style={style} size={16} />,
+ [],
+ );
+ const renderUnpinIcon = React.useCallback(
+ style => <CommIcon name="unpin-outline" style={style} size={16} />,
+ [],
+ );
+
const onPressSidebar = useAnimatedNavigateToSidebar(route.params.item);
const renderSidebarIcon = React.useCallback(
style => (
@@ -41,6 +52,20 @@
return (
<>
+ <TooltipItem
+ id="pin"
+ text="Pin"
+ onPress={onPressTogglePin}
+ renderIcon={renderPinIcon}
+ key="pin"
+ />
+ <TooltipItem
+ id="unpin"
+ text="Unpin"
+ onPress={onPressTogglePin}
+ renderIcon={renderUnpinIcon}
+ key="unpin"
+ />
<TooltipItem
id="sidebar"
text="Thread"
diff --git a/native/chat/multimedia-message.react.js b/native/chat/multimedia-message.react.js
--- a/native/chat/multimedia-message.react.js
+++ b/native/chat/multimedia-message.react.js
@@ -10,8 +10,12 @@
import { StyleSheet, View } from 'react-native';
import { messageKey } from 'lib/shared/message-utils.js';
-import { useCanCreateSidebarFromMessage } from 'lib/shared/thread-utils.js';
+import {
+ threadHasPermission,
+ useCanCreateSidebarFromMessage,
+} from 'lib/shared/thread-utils.js';
import type { MediaInfo } from 'lib/types/media-types.js';
+import { threadPermissions } from 'lib/types/thread-types.js';
import ComposedMessage from './composed-message.react.js';
import { InnerMultimediaMessage } from './inner-multimedia-message.react.js';
@@ -49,6 +53,7 @@
+overlayContext: ?OverlayContextType,
+chatContext: ?ChatContextType,
+canCreateSidebarFromMessage: boolean,
+ +canTogglePins: boolean,
};
type State = {
+clickable: boolean,
@@ -87,6 +92,10 @@
visibleEntryIDs() {
const result = [];
+ if (this.props.canTogglePins) {
+ this.props.item.isPinned ? result.push('unpin') : result.push('pin');
+ }
+
if (
this.props.item.threadCreatedFromMessage ||
this.props.canCreateSidebarFromMessage
@@ -194,6 +203,7 @@
overlayContext,
chatContext,
canCreateSidebarFromMessage,
+ canTogglePins,
...viewProps
} = this.props;
return (
@@ -235,6 +245,10 @@
props.item.threadInfo,
props.item.messageInfo,
);
+ const canTogglePins = threadHasPermission(
+ props.item.threadInfo,
+ threadPermissions.MANAGE_PINS,
+ );
return (
<MultimediaMessage
@@ -244,6 +258,7 @@
overlayContext={overlayContext}
chatContext={chatContext}
canCreateSidebarFromMessage={canCreateSidebarFromMessage}
+ canTogglePins={canTogglePins}
/>
);
});
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
@@ -84,6 +84,16 @@
[],
);
+ const onPressTogglePin = React.useCallback(() => {}, []);
+ const renderPinIcon = React.useCallback(
+ style => <CommIcon name="pin-outline" style={style} size={16} />,
+ [],
+ );
+ const renderUnpinIcon = React.useCallback(
+ style => <CommIcon name="unpin-outline" style={style} size={16} />,
+ [],
+ );
+
const onPressCopy = React.useCallback(() => {
Clipboard.setString(text);
setTimeout(confirmCopy);
@@ -122,6 +132,20 @@
renderIcon={renderEditIcon}
key="edit"
/>
+ <TooltipItem
+ id="pin"
+ text="Pin"
+ onPress={onPressTogglePin}
+ renderIcon={renderPinIcon}
+ key="pin"
+ />
+ <TooltipItem
+ id="unpin"
+ text="Unpin"
+ onPress={onPressTogglePin}
+ renderIcon={renderUnpinIcon}
+ key="unpin"
+ />
<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
@@ -55,6 +55,7 @@
+isLinkModalActive: boolean,
+canEditMessage: boolean,
+shouldRenderEditButton: boolean,
+ +canTogglePins: boolean,
};
class TextMessage extends React.PureComponent<Props> {
message: ?React.ElementRef<typeof View>;
@@ -81,6 +82,7 @@
canCreateSidebarFromMessage,
canEditMessage,
shouldRenderEditButton,
+ canTogglePins,
...viewProps
} = this.props;
@@ -147,6 +149,10 @@
result.push('edit');
}
+ if (this.props.canTogglePins) {
+ this.props.item.isPinned ? result.push('unpin') : result.push('pin');
+ }
+
if (
this.props.item.threadCreatedFromMessage ||
this.props.canCreateSidebarFromMessage
@@ -256,6 +262,11 @@
props.item.messageInfo,
);
+ const canTogglePins = threadHasPermission(
+ props.item.threadInfo,
+ threadPermissions.MANAGE_PINS,
+ );
+
React.useEffect(() => clearMarkdownContextData, [clearMarkdownContextData]);
return (
@@ -267,6 +278,7 @@
isLinkModalActive={isLinkModalActive}
canEditMessage={canEditMessage}
shouldRenderEditButton={shouldRenderEditButton}
+ canTogglePins={canTogglePins}
/>
);
});
diff --git a/native/types/chat-types.js b/native/types/chat-types.js
--- a/native/types/chat-types.js
+++ b/native/types/chat-types.js
@@ -39,6 +39,7 @@
+threadCreatedFromMessage: ?ThreadInfo,
+reactions: ReactionInfo,
+hasBeenEdited: ?boolean,
+ +isPinned: ?boolean,
};
export type MultimediaContentSizes = {
@@ -60,6 +61,7 @@
+pendingUploads: ?MessagePendingUploads,
+reactions: ReactionInfo,
+hasBeenEdited: ?boolean,
+ +isPinned: ?boolean,
};
export type ChatMessageInfoItemWithHeight =

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 7:55 AM (21 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578976
Default Alt Text
D7606.diff (7 KB)

Event Timeline