Changeset View
Changeset View
Standalone View
Standalone View
web/modals/chat/sidebar-list-modal.react.js
// @flow | // @flow | ||||
import classNames from 'classnames'; | |||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { useSearchSidebars } from 'lib/hooks/search-sidebars'; | import { useSearchSidebars } from 'lib/hooks/search-sidebars'; | ||||
import type { ThreadInfo } from 'lib/types/thread-types'; | import type { ThreadInfo } from 'lib/types/thread-types'; | ||||
import chatThreadListCSS from '../../chat/chat-thread-list.css'; | |||||
import SidebarItem from '../../chat/sidebar-item.react'; | import SidebarItem from '../../chat/sidebar-item.react'; | ||||
import { useModalContext } from '../modal-provider.react'; | import { useModalContext } from '../modal-provider.react'; | ||||
import SearchModal from '../search-modal.react'; | import SearchModal from '../search-modal.react'; | ||||
type Props = { | type Props = { | ||||
+threadInfo: ThreadInfo, | +threadInfo: ThreadInfo, | ||||
}; | }; | ||||
type SidebarModalContentProps = { | type SidebarModalContentProps = { | ||||
+threadInfo: ThreadInfo, | +threadInfo: ThreadInfo, | ||||
+onClose: () => void, | +onClose: () => void, | ||||
+searchText: string, | +searchText: string, | ||||
}; | }; | ||||
function SidebarModalContent(props: SidebarModalContentProps): React.Node { | function SidebarModalContent(props: SidebarModalContentProps): React.Node { | ||||
const { threadInfo, searchText } = props; | const { threadInfo, searchText } = props; | ||||
const { popModal } = useModalContext(); | const { popModal } = useModalContext(); | ||||
const { listData } = useSearchSidebars(threadInfo, searchText); | const { listData } = useSearchSidebars(threadInfo, searchText); | ||||
return listData.map(item => ( | return ( | ||||
<div | <ul> | ||||
className={classNames( | {listData.map(item => ( | ||||
chatThreadListCSS.thread, | <li key={item.threadInfo.id} onClick={popModal}> | ||||
chatThreadListCSS.sidebar, | |||||
)} | |||||
key={item.threadInfo.id} | |||||
onClick={popModal} | |||||
> | |||||
<SidebarItem sidebarInfo={item} /> | <SidebarItem sidebarInfo={item} /> | ||||
</div> | </li> | ||||
)); | ))} | ||||
</ul> | |||||
); | |||||
} | } | ||||
function SidebarListModal(props: Props): React.Node { | function SidebarListModal(props: Props): React.Node { | ||||
const { popModal } = useModalContext(); | const { popModal } = useModalContext(); | ||||
const { threadInfo } = props; | const { threadInfo } = props; | ||||
const searchSidebarModalContent = React.useCallback( | const searchSidebarModalContent = React.useCallback( | ||||
(searchSidebarText: string) => ( | (searchSidebarText: string) => ( | ||||
Show All 22 Lines |