Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3350061
D4823.id15955.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4823.id15955.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D4823: [lib] Make `useInlineSidebarText` hook parameter optional
Attached
Detach File
Event Timeline
Log In to Comment