Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32193677
D4823.1765099099.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D4823.1765099099.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,20 @@
return senders.length > 0 ? `${pluralizeAndTrim(senders, 25)} sent ` : '';
}, [threadMembers]);
- return React.useMemo(
- () => ({
+ return React.useMemo(() => {
+ if (!threadInfo) {
+ return { sendersText: '', repliesText: '' };
+ }
+ const repliesCount = threadInfo?.repliesCount || 1;
+ const repliesText = `${repliesCount} ${
+ repliesCount > 1 ? 'replies' : 'reply'
+ }`;
+
+ return {
sendersText,
repliesText,
- }),
- [sendersText, repliesText],
- );
+ };
+ }, [threadInfo, sendersText]);
}
export default useInlineSidebarText;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 9:18 AM (14 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5843251
Default Alt Text
D4823.1765099099.diff (1 KB)
Attached To
Mode
D4823: [lib] Make `useInlineSidebarText` hook parameter optional
Attached
Detach File
Event Timeline
Log In to Comment