diff --git a/lib/hooks/inline-sidebar-text.react.js b/lib/hooks/inline-sidebar-text.react.js --- a/lib/hooks/inline-sidebar-text.react.js +++ b/lib/hooks/inline-sidebar-text.react.js @@ -1,45 +1,13 @@ // @flow -import * as React from 'react'; - -import { relativeMemberInfoSelectorForMembersOfThread } from '../selectors/user-selectors'; -import { stringForUser } from '../shared/user-utils'; import type { ThreadInfo } from '../types/thread-types'; -import { useSelector } from '../utils/redux-utils'; -import { pluralizeAndTrim } from '../utils/text-utils'; - -function useInlineSidebarText( - threadInfo: ?ThreadInfo, -): { - sendersText: string, - repliesText: string, -} { - const threadMembers = useSelector( - relativeMemberInfoSelectorForMembersOfThread(threadInfo?.id), - ); - const sendersText = React.useMemo(() => { - const senders = threadMembers - .filter(member => member.isSender) - .map(stringForUser); - return senders.length > 0 ? `${pluralizeAndTrim(senders, 25)} sent ` : ''; - }, [threadMembers]); - - const noThreadInfo = !threadInfo; - - return React.useMemo(() => { - if (noThreadInfo) { - return { sendersText: '', repliesText: '' }; - } - const repliesCount = threadInfo?.repliesCount || 1; - const repliesText = `${repliesCount} ${ - repliesCount > 1 ? 'replies' : 'reply' - }`; - return { - sendersText, - repliesText, - }; - }, [noThreadInfo, sendersText, threadInfo?.repliesCount]); +function useInlineSidebarText(threadInfo: ?ThreadInfo): string { + if (!threadInfo) { + return ''; + } + const repliesCount = threadInfo.repliesCount || 1; + return `${repliesCount} ${repliesCount > 1 ? 'replies' : 'reply'}`; } export default useInlineSidebarText; diff --git a/native/chat/inline-sidebar.react.js b/native/chat/inline-sidebar.react.js --- a/native/chat/inline-sidebar.react.js +++ b/native/chat/inline-sidebar.react.js @@ -31,7 +31,7 @@ }; function InlineSidebar(props: Props): React.Node { const { disabled = false, reactions, threadInfo } = props; - const { repliesText } = useInlineSidebarText(threadInfo); + const repliesText = useInlineSidebarText(threadInfo); const navigateToThread = useNavigateToThread(); const onPress = React.useCallback(() => { diff --git a/web/chat/inline-sidebar.react.js b/web/chat/inline-sidebar.react.js --- a/web/chat/inline-sidebar.react.js +++ b/web/chat/inline-sidebar.react.js @@ -19,7 +19,7 @@ }; function InlineSidebar(props: Props): React.Node { const { threadInfo, positioning, reactions } = props; - const inlineSidebarText = useInlineSidebarText(threadInfo); + const repliesText = useInlineSidebarText(threadInfo); const containerClasses = classNames([ css.inlineSidebarContainer, @@ -45,17 +45,17 @@ const threadInfoExists = !!threadInfo; const sidebarItem = React.useMemo(() => { - if (!threadInfoExists || !inlineSidebarText) { + if (!threadInfoExists || !repliesText) { return null; } return (