Page MenuHomePhabricator

D7163.id24252.diff
No OneTemporary

D7163.id24252.diff

diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js
--- a/lib/selectors/chat-selectors.js
+++ b/lib/selectors/chat-selectors.js
@@ -545,7 +545,7 @@
) => (state: BaseAppState<*>) => MessageListData =
memoize2(baseMessageListData);
-type UseMessageListDataArgs = {
+export type UseMessageListDataArgs = {
+searching: boolean,
+userInfoInputArray: $ReadOnlyArray<AccountUserInfo>,
+threadInfo: ?ThreadInfo,
diff --git a/native/chat/chat-context-provider.react.js b/native/chat/chat-context-provider.react.js
--- a/native/chat/chat-context-provider.react.js
+++ b/native/chat/chat-context-provider.react.js
@@ -2,12 +2,12 @@
import * as React from 'react';
-import type { ChatMessageItem } from 'lib/selectors/chat-selectors.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';
import { ChatContext } from './chat-context.js';
import type { SidebarAnimationType } from './chat-context.js';
import ChatItemHeightMeasurer from './chat-item-height-measurer.react.js';
+import type { NativeChatMessageItem } from './message-data.react.js';
import type { ChatMessageItemWithHeight } from '../types/chat-types.js';
type Props = {
@@ -15,7 +15,7 @@
};
export type MeasurementTask = {
- +messages: $ReadOnlyArray<ChatMessageItem>,
+ +messages: $ReadOnlyArray<NativeChatMessageItem>,
+threadInfo: ThreadInfo,
+onMessagesMeasured: (
messagesWithHeight: $ReadOnlyArray<ChatMessageItemWithHeight>,
@@ -36,7 +36,7 @@
const measureMessages = React.useCallback(
(
- messages: ?$ReadOnlyArray<ChatMessageItem>,
+ messages: ?$ReadOnlyArray<NativeChatMessageItem>,
threadInfo: ?ThreadInfo,
onMessagesMeasured: ($ReadOnlyArray<ChatMessageItemWithHeight>) => mixed,
measurerID: number,
@@ -92,7 +92,7 @@
const measurerID = nextMeasurerID.current++;
return {
measure: (
- messages: ?$ReadOnlyArray<ChatMessageItem>,
+ messages: ?$ReadOnlyArray<NativeChatMessageItem>,
threadInfo: ?ThreadInfo,
onMessagesMeasured: (
$ReadOnlyArray<ChatMessageItemWithHeight>,
diff --git a/native/chat/chat-context.js b/native/chat/chat-context.js
--- a/native/chat/chat-context.js
+++ b/native/chat/chat-context.js
@@ -3,14 +3,14 @@
import invariant from 'invariant';
import * as React from 'react';
-import type { ChatMessageItem } from 'lib/selectors/chat-selectors.js';
import type { SetState } from 'lib/types/hook-types.js';
import type { ThreadInfo } from 'lib/types/thread-types.js';
+import type { NativeChatMessageItem } from './message-data.react.js';
import type { ChatMessageItemWithHeight } from '../types/chat-types.js';
export type MessagesMeasurer = (
- ?$ReadOnlyArray<ChatMessageItem>,
+ ?$ReadOnlyArray<NativeChatMessageItem>,
?ThreadInfo,
($ReadOnlyArray<ChatMessageItemWithHeight>) => mixed,
) => void;
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
@@ -3,7 +3,6 @@
import invariant from 'invariant';
import * as React from 'react';
-import type { ChatMessageItem } from 'lib/selectors/chat-selectors.js';
import { messageID } from 'lib/shared/message-utils.js';
import { messageTypes, type MessageType } from 'lib/types/message-types.js';
import { entityTextToRawString } from 'lib/utils/entity-text.js';
@@ -12,6 +11,7 @@
import { useComposedMessageMaxWidth } from './composed-message-width.js';
import { dummyNodeForRobotextMessageHeightMeasurement } from './inner-robotext-message.react.js';
import { dummyNodeForTextMessageHeightMeasurement } from './inner-text-message.react.js';
+import type { NativeChatMessageItem } from './message-data.react.js';
import { MessageListContextProvider } from './message-list-types.js';
import { multimediaMessageContentSizes } from './multimedia-message-utils.js';
import { chatMessageItemKey } from './utils.js';
@@ -22,7 +22,7 @@
+measurement: MeasurementTask,
};
-const heightMeasurerKey = (item: ChatMessageItem) => {
+const heightMeasurerKey = (item: NativeChatMessageItem) => {
if (item.itemType !== 'message') {
return null;
}
@@ -38,7 +38,7 @@
return null;
};
-const heightMeasurerDummy = (item: ChatMessageItem) => {
+const heightMeasurerDummy = (item: NativeChatMessageItem) => {
invariant(
item.itemType === 'message',
'NodeHeightMeasurer asked for dummy for non-message item',
@@ -63,7 +63,7 @@
const { measurement } = props;
const { threadInfo } = measurement;
const heightMeasurerMergeItem = React.useCallback(
- (item: ChatMessageItem, height: ?number) => {
+ (item: NativeChatMessageItem, height: ?number) => {
if (item.itemType !== 'message') {
return item;
}
diff --git a/native/chat/message-data.react.js b/native/chat/message-data.react.js
new file mode 100644
--- /dev/null
+++ b/native/chat/message-data.react.js
@@ -0,0 +1,19 @@
+// @flow
+
+import {
+ type ChatMessageItem,
+ type UseMessageListDataArgs,
+ useMessageListData,
+} from 'lib/selectors/chat-selectors.js';
+
+export type NativeChatMessageItem = ChatMessageItem;
+
+type MessageListData = ?(NativeChatMessageItem[]);
+
+function useNativeMessageListData(
+ args: UseMessageListDataArgs,
+): MessageListData {
+ return useMessageListData(args);
+}
+
+export { useNativeMessageListData };
diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js
--- a/native/chat/message-list-container.react.js
+++ b/native/chat/message-list-container.react.js
@@ -6,10 +6,6 @@
import { View } from 'react-native';
import genesis from 'lib/facts/genesis.js';
-import {
- type ChatMessageItem,
- useMessageListData,
-} from 'lib/selectors/chat-selectors.js';
import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
import {
userInfoSelectorForPotentialMembers,
@@ -26,6 +22,10 @@
import { type MessagesMeasurer, useHeightMeasurer } from './chat-context.js';
import { ChatInputBar } from './chat-input-bar.react.js';
import type { ChatNavigationProp } from './chat.react.js';
+import {
+ type NativeChatMessageItem,
+ useNativeMessageListData,
+} from './message-data.react.js';
import MessageListThreadSearch from './message-list-thread-search.react.js';
import { MessageListContextProvider } from './message-list-types.js';
import MessageList from './message-list.react.js';
@@ -58,7 +58,7 @@
+userSearchResults: $ReadOnlyArray<UserListItem>,
+threadInfo: ThreadInfo,
+genesisThreadInfo: ?ThreadInfo,
- +messageListData: ?$ReadOnlyArray<ChatMessageItem>,
+ +messageListData: ?$ReadOnlyArray<NativeChatMessageItem>,
+colors: Colors,
+styles: typeof unboundStyles,
// withOverlayContext
@@ -335,7 +335,7 @@
[setParams, existingThreadInfoFinder, addReply],
);
- const messageListData = useMessageListData({
+ const messageListData = useNativeMessageListData({
searching: isSearching,
userInfoInputArray,
threadInfo,
diff --git a/native/chat/utils.js b/native/chat/utils.js
--- a/native/chat/utils.js
+++ b/native/chat/utils.js
@@ -5,8 +5,6 @@
import Animated from 'react-native-reanimated';
import { useLoggedInUserInfo } from 'lib/hooks/account-hooks.js';
-import { useMessageListData } from 'lib/selectors/chat-selectors.js';
-import type { ChatMessageItem } from 'lib/selectors/chat-selectors.js';
import { colorIsDark } from 'lib/shared/color-utils.js';
import { messageKey } from 'lib/shared/message-utils.js';
import { viewerIsMember } from 'lib/shared/thread-utils.js';
@@ -15,6 +13,10 @@
import { clusterEndHeight, inlineEngagementStyle } from './chat-constants.js';
import { ChatContext, useHeightMeasurer } from './chat-context.js';
import { failedSendHeight } from './failed-send.react.js';
+import {
+ useNativeMessageListData,
+ type NativeChatMessageItem,
+} from './message-data.react.js';
import { authorNameHeight } from './message-header.react.js';
import { multimediaMessageItemHeight } from './multimedia-message-utils.js';
import { getUnresolvedSidebarThreadInfo } from './sidebar-navigation.js';
@@ -119,7 +121,7 @@
+position: number,
+color: string,
} {
- const messageListData = useMessageListData({
+ const messageListData = useNativeMessageListData({
searching: false,
userInfoInputArray: [],
threadInfo: sidebarThreadInfo,
@@ -390,7 +392,7 @@
}
function chatMessageItemKey(
- item: ChatMessageItemWithHeight | ChatMessageItem,
+ item: ChatMessageItemWithHeight | NativeChatMessageItem,
): string {
if (item.itemType === 'loader') {
return 'loader';

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 8:03 AM (13 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690278
Default Alt Text
D7163.id24252.diff (8 KB)

Event Timeline