({ thread }: Props)
| 11 | } |
| 12 | |
| 13 | export 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 | } |
no test coverage detected