MCPcopy Create free account
hub / github.com/campsite/campsite / useJoinMessageThreadCall

Function useJoinMessageThreadCall

apps/web/hooks/useJoinMessageThreadCall.tsx:13–31  ·  view source on GitHub ↗
({ thread }: Props)

Source from the content-addressed store, hash-verified

11}
12
13export function useJoinMessageThreadCall({ thread }: Props) {
14 const { data: currentUser } = useGetCurrentUser()
15 const singleChatWithDeactivatedMember =
16 thread?.other_members.length === 1 && !!thread?.other_members.at(0)?.deactivated
17 const canJoin =
18 currentUser && !currentUser.on_call && !singleChatWithDeactivatedMember && !!thread?.remote_call_room_id
19 const isDesktopApp = useIsDesktopApp()
20
21 const join = useCallback(() => {
22 if (!thread?.call_room_url) return
23 if (isDesktopApp) {
24 desktopJoinCall(thread.call_room_url)
25 } else {
26 window.open(thread.call_room_url)
27 }
28 }, [isDesktopApp, thread?.call_room_url])
29
30 return { joinCall: join, canJoin, onCall: !!currentUser?.on_call }
31}

Callers 4

ProjectCallButtonFunction · 0.90
ActiveMessageCallFunction · 0.90
BreadcrumbCallButtonFunction · 0.90
ThreadHoverCardFunction · 0.90

Calls 3

useGetCurrentUserFunction · 0.90
useIsDesktopAppFunction · 0.90
desktopJoinCallFunction · 0.90

Tested by

no test coverage detected