Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3100487
D13683.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D13683.id.diff
View Options
diff --git a/lib/shared/chat-message-item-utils.js b/lib/shared/chat-message-item-utils.js
--- a/lib/shared/chat-message-item-utils.js
+++ b/lib/shared/chat-message-item-utils.js
@@ -8,6 +8,7 @@
ComposableMessageInfo,
} from '../types/message-types.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
+import { longAbsoluteDate } from '../utils/date-utils.js';
type ChatMessageItemMessageInfo = ComposableMessageInfo | RobotextMessageInfo;
@@ -35,6 +36,10 @@
return messageKey(item.messageInfo);
}
+function chatMessageInfoItemTimestamp(item: BaseChatMessageInfoItem): string {
+ return longAbsoluteDate(item.messageInfo.time);
+}
+
type BaseChatMessageItemForEngagementCheck = {
+threadCreatedFromMessage: ?ThreadInfo,
+reactions: ReactionInfo,
@@ -53,4 +58,8 @@
);
}
-export { chatMessageItemKey, chatMessageItemHasEngagement };
+export {
+ chatMessageItemKey,
+ chatMessageInfoItemTimestamp,
+ chatMessageItemHasEngagement,
+};
diff --git a/native/chat/message-header.react.js b/native/chat/message-header.react.js
--- a/native/chat/message-header.react.js
+++ b/native/chat/message-header.react.js
@@ -23,7 +23,7 @@
function MessageHeader(props: Props): React.Node {
const styles = useStyles(unboundStyles);
const { item, focused, display } = props;
- const { creator, time } = item.messageInfo;
+ const { creator } = item.messageInfo;
const { isViewer } = creator;
const route = useRoute();
@@ -84,14 +84,8 @@
return null;
}
- return <Timestamp time={time} display={display} />;
- }, [
- display,
- item.startsConversation,
- messageInMessageList,
- modalDisplay,
- time,
- ]);
+ return <Timestamp item={item} display={display} />;
+ }, [display, item, messageInMessageList, modalDisplay]);
const containerStyle = React.useMemo(() => {
if (!focused || modalDisplay) {
diff --git a/native/chat/message-result.react.js b/native/chat/message-result.react.js
--- a/native/chat/message-result.react.js
+++ b/native/chat/message-result.react.js
@@ -4,8 +4,8 @@
import { Text, View } from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';
+import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import { longAbsoluteDate } from 'lib/utils/date-utils.js';
import { type ChatNavigationProp } from './chat.react.js';
import { MessageListContextProvider } from './message-list-types.js';
@@ -64,7 +64,7 @@
shouldDisplayPinIndicator={false}
/>
<Text style={styles.messageDate}>
- {longAbsoluteDate(props.item.messageInfo.time)}
+ {chatMessageInfoItemTimestamp(props.item)}
</Text>
</View>
</MessageListContextProvider>
diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js
--- a/native/chat/robotext-message-tooltip-button.react.js
+++ b/native/chat/robotext-message-tooltip-button.react.js
@@ -123,7 +123,7 @@
onInputBarMeasured={onInputBarMeasured}
/>
<Animated.View style={headerStyle}>
- <Timestamp time={item.messageInfo.time} display="modal" />
+ <Timestamp item={item} display="modal" />
</Animated.View>
{reactionSelectionPopover}
<InnerRobotextMessage item={item} onPress={navigation.goBackOnce} />
diff --git a/native/chat/robotext-message.react.js b/native/chat/robotext-message.react.js
--- a/native/chat/robotext-message.react.js
+++ b/native/chat/robotext-message.react.js
@@ -58,9 +58,7 @@
let timestamp = null;
if (focused || item.startsConversation) {
- timestamp = (
- <Timestamp time={item.messageInfo.time} display="lowContrast" />
- );
+ timestamp = <Timestamp item={item} display="lowContrast" />;
}
const styles = useStyles(unboundStyles);
diff --git a/native/chat/timestamp.react.js b/native/chat/timestamp.react.js
--- a/native/chat/timestamp.react.js
+++ b/native/chat/timestamp.react.js
@@ -2,15 +2,16 @@
import * as React from 'react';
-import { longAbsoluteDate } from 'lib/utils/date-utils.js';
+import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
import SingleLine from '../components/single-line.react.js';
import { useStyles } from '../themes/colors.js';
+import type { ChatMessageInfoItemWithHeight } from '../types/chat-types.js';
export type DisplayType = 'lowContrast' | 'modal';
type Props = {
- +time: number,
+ +item: ChatMessageInfoItemWithHeight,
+display: DisplayType,
};
function Timestamp(props: Props): React.Node {
@@ -24,8 +25,8 @@
);
const absoluteDate = React.useMemo(
- () => longAbsoluteDate(props.time),
- [props.time],
+ () => chatMessageInfoItemTimestamp(props.item),
+ [props.item],
);
const timestamp = React.useMemo(
diff --git a/web/chat/message.react.js b/web/chat/message.react.js
--- a/web/chat/message.react.js
+++ b/web/chat/message.react.js
@@ -4,9 +4,9 @@
import * as React from 'react';
import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
+import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
import { messageTypes } from 'lib/types/message-types-enum.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import { longAbsoluteDate } from 'lib/utils/date-utils.js';
import css from './chat-message-list.css';
import { useEditModalContext } from './edit-message-provider.js';
@@ -27,7 +27,7 @@
if (item.startsConversation) {
conversationHeader = (
<div className={css.conversationHeader}>
- {longAbsoluteDate(item.messageInfo.time)}
+ {chatMessageInfoItemTimestamp(item)}
</div>
);
}
diff --git a/web/components/message-result.react.js b/web/components/message-result.react.js
--- a/web/components/message-result.react.js
+++ b/web/components/message-result.react.js
@@ -6,8 +6,8 @@
import { useThreadChatMentionCandidates } from 'lib/hooks/chat-mention-hooks.js';
import { useStringForUser } from 'lib/hooks/ens-cache.js';
import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
+import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import { longAbsoluteDate } from 'lib/utils/date-utils.js';
import css from './message-result.css';
import { MessageListContext } from '../chat/message-list-types.js';
@@ -59,7 +59,7 @@
</MessageListContext.Provider>
</div>
<div className={css.messageDate}>
- {longAbsoluteDate(item.messageInfo.time)}
+ {chatMessageInfoItemTimestamp(item)}
</div>
</div>
</div>
diff --git a/web/tooltips/tooltip-action-utils.js b/web/tooltips/tooltip-action-utils.js
--- a/web/tooltips/tooltip-action-utils.js
+++ b/web/tooltips/tooltip-action-utils.js
@@ -10,6 +10,7 @@
ChatMessageInfoItem,
ReactionInfo,
} from 'lib/selectors/chat-selectors.js';
+import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
import { useCanEditMessage } from 'lib/shared/edit-messages-utils.js';
import { createMessageReply } from 'lib/shared/message-utils.js';
import { useCanCreateReactionFromMessage } from 'lib/shared/reaction-utils.js';
@@ -18,7 +19,6 @@
import { messageTypes } from 'lib/types/message-types-enum.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
-import { longAbsoluteDate } from 'lib/utils/date-utils.js';
import { useCanToggleMessagePin } from 'lib/utils/message-pinning-utils.js';
import LabelTooltip from './label-toolitp.react.js';
@@ -407,10 +407,7 @@
}: UseMessageTooltipArgs): UseTooltipResult {
const tooltipActions = useMessageTooltipActions(item, threadInfo);
- const messageTimestamp = React.useMemo(() => {
- const time = item.messageInfo.time;
- return longAbsoluteDate(time);
- }, [item.messageInfo.time]);
+ const messageTimestamp = chatMessageInfoItemTimestamp(item);
const tooltipSize = React.useMemo(() => {
if (typeof document === 'undefined') {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 31, 3:00 AM (16 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2390421
Default Alt Text
D13683.id.diff (8 KB)
Attached To
Mode
D13683: [lib][native][web] Extract chatMessageInfoItemTimestamp
Attached
Detach File
Event Timeline
Log In to Comment