Page MenuHomePhabricator

D4823.id15955.diff
No OneTemporary

D4823.id15955.diff

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
@@ -9,18 +9,13 @@
import { pluralizeAndTrim } from '../utils/text-utils';
function useInlineSidebarText(
- threadInfo: ThreadInfo,
+ threadInfo: ?ThreadInfo,
): {
sendersText: string,
repliesText: string,
} {
- const repliesCount = threadInfo.repliesCount || 1;
- const repliesText = `${repliesCount} ${
- repliesCount > 1 ? 'replies' : 'reply'
- }`;
-
const threadMembers = useSelector(
- relativeMemberInfoSelectorForMembersOfThread(threadInfo.id),
+ relativeMemberInfoSelectorForMembersOfThread(threadInfo?.id),
);
const sendersText = React.useMemo(() => {
const senders = threadMembers
@@ -29,13 +24,22 @@
return senders.length > 0 ? `${pluralizeAndTrim(senders, 25)} sent ` : '';
}, [threadMembers]);
- return React.useMemo(
- () => ({
+ 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,
- }),
- [sendersText, repliesText],
- );
+ };
+ }, [noThreadInfo, sendersText, threadInfo?.repliesCount]);
}
export default useInlineSidebarText;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 8:33 PM (17 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2572355
Default Alt Text
D4823.id15955.diff (1 KB)

Event Timeline