MCPcopy Create free account
hub / github.com/dailydotdev/apps / PostEngagements

Function PostEngagements

packages/shared/src/components/post/PostEngagements.tsx:54–185  ·  view source on GitHub ↗
({
  post,
  onCopyLinkClick,
  logOrigin,
  shouldOnboardAuthor,
}: PostEngagementsProps)

Source from the content-addressed store, hash-verified

52}
53
54function PostEngagements({
55 post,
56 onCopyLinkClick,
57 logOrigin,
58 shouldOnboardAuthor,
59}: PostEngagementsProps): ReactElement {
60 const { completeAction } = useActions();
61 const postQueryKey = ['post', post.id];
62 const { sortCommentsBy: sortBy, updateSortCommentsBy: setSortBy } =
63 useSettingsContext();
64 const { user, showLogin } = useAuthContext();
65 const { isPlus } = usePlusSubscription();
66 const commentRef = useRef<NewCommentRef>();
67 const [authorOnboarding, setAuthorOnboarding] = useState(false);
68 const [permissionNotificationCommentId, setPermissionNotificationCommentId] =
69 useState<string>();
70 const [joinNotificationCommentId, setJoinNotificationCommentId] =
71 useState<string>();
72 const [isComposerOpen, setIsComposerOpen] = useState(false);
73 const { onShowUpvoted } = useUpvoteQuery();
74 const { openShareComment } = useShareComment(logOrigin);
75 const [isJoinSquadBannerDismissed] = usePersistentContext(
76 SQUAD_COMMENT_JOIN_BANNER_KEY,
77 false,
78 );
79 const [linkClicked, setLinkClicked] = useState(false);
80
81 const handleLinkClick = () => {
82 setLinkClicked(true);
83 onCopyLinkClick?.(post);
84 };
85
86 const onCommented = (comment: Comment, isNew: boolean) => {
87 if (!isNew) {
88 return;
89 }
90
91 setPermissionNotificationCommentId(comment.id);
92
93 if (
94 isSourcePublicSquad(post.source) &&
95 !post.source?.currentMember &&
96 !isJoinSquadBannerDismissed
97 ) {
98 setJoinNotificationCommentId(comment.id);
99 }
100
101 if (post.source?.type === SourceType.Squad) {
102 completeAction(ActionType.SquadFirstComment);
103 }
104 };
105
106 useEffect(() => {
107 if (shouldOnboardAuthor) {
108 setAuthorOnboarding(true);
109 }
110 }, [shouldOnboardAuthor]);
111

Callers

nothing calls this directly

Calls 8

useActionsFunction · 0.90
useSettingsContextFunction · 0.90
useAuthContextFunction · 0.90
usePlusSubscriptionFunction · 0.90
useUpvoteQueryFunction · 0.90
useShareCommentFunction · 0.90
usePersistentContextFunction · 0.85
onShowUpvotedFunction · 0.85

Tested by

no test coverage detected