diff --git a/native/chat/chat-thread-list.react.js b/native/chat/chat-thread-list.react.js --- a/native/chat/chat-thread-list.react.js +++ b/native/chat/chat-thread-list.react.js @@ -21,7 +21,6 @@ } from 'lib/selectors/chat-selectors.js'; import { useGlobalThreadSearchIndex } from 'lib/selectors/nav-selectors.js'; import { usersWithPersonalThreadSelector } from 'lib/selectors/user-selectors.js'; -import SearchIndex from 'lib/shared/search-index.js'; import { createPendingThread, getThreadListSearchResults, @@ -42,10 +41,7 @@ ChatTopTabsNavigationProp, ChatNavigationProp, } from './chat.react.js'; -import { - type MessageListParams, - useNavigateToThread, -} from './message-list-types.js'; +import { useNavigateToThread } from './message-list-types.js'; import Button from '../components/button.react.js'; import Search from '../components/search.react.js'; import { @@ -97,50 +93,24 @@ type Props = { ...BaseProps, // Redux state - +chatListData: $ReadOnlyArray, +loggedInUserInfo: ?LoggedInUserInfo, - +threadSearchIndex: SearchIndex, +styles: typeof unboundStyles, +indicatorStyle: IndicatorStyle, - +usersWithPersonalThread: $ReadOnlySet, - +navigateToThread: (params: MessageListParams) => void, +searchText: string, - +setSearchText: SetState, +searchStatus: SearchStatus, - +setSearchStatus: SetState, - +threadsSearchResults: Set, - +setThreadsSearchResults: SetState>, - +usersSearchResults: $ReadOnlyArray, - +setUsersSearchResults: SetState<$ReadOnlyArray>, +openedSwipeableID: string, - +setOpenedSwipeableID: SetState, - +numItemsToDisplay: number, +setNumItemsToDisplay: SetState, +searchCancelButtonOpen: Value, - +searchCancelButtonProgress: Node, - +searchCancelButtonOffset: Node, - +searchUsers: ( - usernamePrefix: string, - ) => Promise<$ReadOnlyArray>, - +onChangeSearchText: (searchText: string) => Promise, +scrollPos: { current: number }, +onScroll: (event: ScrollEvent) => void, - +onSwipeableWillOpen: (threadInfo: ThreadInfo) => void, - +composeThread: () => void, - +onSearchCancel: () => void, - +onSearchFocus: () => void, +renderSearch: ( additionalProps?: $Shape>, ) => React.Node, - +onPressItem: ( - threadInfo: ThreadInfo, - pendingPersonalThreadUserInfo?: UserInfo, - ) => void, - +onPressSeeMoreSidebars: (threadInfo: ThreadInfo) => void, +hardwareBack: () => boolean, +renderItem: (row: { item: Item, ... }) => React.Node, +partialListData: Item[], +onEndReached: () => void, + +floatingAction: React.Node, }; class ChatThreadList extends React.PureComponent { @@ -228,17 +198,6 @@ }; render() { - let floatingAction; - if (Platform.OS === 'android') { - floatingAction = ( - - ); - } let fixedSearch; const { searchStatus } = this.props; if (searchStatus === 'active') { @@ -269,7 +228,7 @@ onEndReachedThreshold={1} ref={this.flatListRef} /> - {floatingAction} + {this.props.floatingAction} ); } @@ -279,47 +238,6 @@ }; } -const unboundStyles = { - icon: { - fontSize: 28, - }, - container: { - flex: 1, - }, - searchContainer: { - backgroundColor: 'listBackground', - display: 'flex', - justifyContent: 'center', - flexDirection: 'row', - }, - searchBox: { - flex: 1, - }, - search: { - marginBottom: 8, - marginHorizontal: 18, - marginTop: 16, - }, - cancelSearchButton: { - position: 'absolute', - right: 0, - top: 0, - bottom: 0, - display: 'flex', - justifyContent: 'center', - }, - cancelSearchButtonText: { - color: 'link', - fontSize: 16, - paddingHorizontal: 16, - paddingTop: 8, - }, - flatList: { - flex: 1, - backgroundColor: 'listBackground', - }, -}; - function ConnectedChatThreadList(props: BaseProps): React.Node { const boundChatListData = useFlattenedChatListData(); const loggedInUserInfo = useLoggedInUserInfo(); @@ -628,51 +546,86 @@ setNumItemsToDisplay(prevNumItems => prevNumItems + 25); }, [listData.length, partialListData.length]); + const floatingAction = React.useMemo(() => { + let node; + if (Platform.OS === 'android') { + node = ( + + ); + } + return node; + }, [composeThread]); + return ( ); } +const unboundStyles = { + icon: { + fontSize: 28, + }, + container: { + flex: 1, + }, + searchContainer: { + backgroundColor: 'listBackground', + display: 'flex', + justifyContent: 'center', + flexDirection: 'row', + }, + searchBox: { + flex: 1, + }, + search: { + marginBottom: 8, + marginHorizontal: 18, + marginTop: 16, + }, + cancelSearchButton: { + position: 'absolute', + right: 0, + top: 0, + bottom: 0, + display: 'flex', + justifyContent: 'center', + }, + cancelSearchButtonText: { + color: 'link', + fontSize: 16, + paddingHorizontal: 16, + paddingTop: 8, + }, + flatList: { + flex: 1, + backgroundColor: 'listBackground', + }, +}; + export default ConnectedChatThreadList;