diff --git a/web/chat/chat-tabs.react.js b/web/chat/chat-tabs.react.js --- a/web/chat/chat-tabs.react.js +++ b/web/chat/chat-tabs.react.js @@ -11,10 +11,7 @@ import ChatThreadTab from './chat-thread-tab.react'; import { ThreadListContext } from './thread-list-provider'; -type Props = { - +setModal: (modal: ?React.Node) => void, -}; -function ChatTabs(props: Props): React.Node { +function ChatTabs(): React.Node { let backgroundTitle = 'Background'; const unreadBackgroundCountVal = useSelector(unreadBackgroundCount); if (unreadBackgroundCountVal) { @@ -52,7 +49,7 @@ />
- +
); diff --git a/web/chat/chat-thread-list-item.react.js b/web/chat/chat-thread-list-item.react.js --- a/web/chat/chat-thread-list-item.react.js +++ b/web/chat/chat-thread-list-item.react.js @@ -21,10 +21,9 @@ type Props = { +item: ChatThreadItem, - +setModal: (modal: ?React.Node) => void, }; function ChatThreadListItem(props: Props): React.Node { - const { item, setModal } = props; + const { item } = props; const { threadInfo, lastUpdatedTimeIncludingSidebars, @@ -105,7 +104,6 @@ threadInfo={item.threadInfo} unread={sidebarItem.unread} showingSidebarsInline={sidebarItem.showingSidebarsInline} - setModal={setModal} key="seeMore" /> ); diff --git a/web/chat/chat-thread-list-see-more-sidebars.react.js b/web/chat/chat-thread-list-see-more-sidebars.react.js --- a/web/chat/chat-thread-list-see-more-sidebars.react.js +++ b/web/chat/chat-thread-list-see-more-sidebars.react.js @@ -1,24 +1,28 @@ // @flow import classNames from 'classnames'; +import invariant from 'invariant'; import * as React from 'react'; import type { ThreadInfo } from 'lib/types/thread-types'; import SidebarListModal from '../modals/chat/sidebar-list-modal.react'; +import { ModalContext } from '../modals/modal-provider.react'; import css from './chat-thread-list.css'; type Props = { +threadInfo: ThreadInfo, +unread: boolean, +showingSidebarsInline: boolean, - +setModal: (modal: ?React.Node) => void, }; function ChatThreadListSeeMoreSidebars(props: Props): React.Node { - const { unread, showingSidebarsInline, setModal, threadInfo } = props; + const { unread, showingSidebarsInline, threadInfo } = props; + const modalContext = React.useContext(ModalContext); + invariant(modalContext, 'modal context should be set'); + const onClick = React.useCallback( - () => setModal(), - [setModal, threadInfo], + () => modalContext.setModal(), + [modalContext, threadInfo], ); const buttonText = showingSidebarsInline ? 'See more...' : 'See sidebars...'; return ( diff --git a/web/chat/chat-thread-list.react.js b/web/chat/chat-thread-list.react.js --- a/web/chat/chat-thread-list.react.js +++ b/web/chat/chat-thread-list.react.js @@ -10,12 +10,7 @@ import { ThreadListContext } from './thread-list-provider'; import ThreadListSearch from './thread-list-search.react'; -type Props = { - +setModal: (modal: ?React.Node) => void, -}; - -function ChatThreadList(props: Props): React.Node { - const { setModal } = props; +function ChatThreadList(): React.Node { const threadListContext = React.useContext(ThreadListContext); invariant( threadListContext, @@ -31,17 +26,13 @@ const threadComponents: React.Node[] = React.useMemo(() => { const threads = threadList.map(item => ( - + )); if (threads.length === 0 && isBackground) { threads.push(); } return threads; - }, [threadList, isBackground, setModal]); + }, [threadList, isBackground]); return (
diff --git a/web/chat/chat.react.js b/web/chat/chat.react.js --- a/web/chat/chat.react.js +++ b/web/chat/chat.react.js @@ -13,7 +13,7 @@ return ( <> - +