Skip to content

Commit

Permalink
fix(callbox): check if there are no participants in call
Browse files Browse the repository at this point in the history
- in that case call is already missed, and callbox shouldn't be shown

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Dec 5, 2024
1 parent e860e24 commit e94a922
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/callbox/renderer/callbox.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type CallGetParticipantsForCallResponse = {
}
}

const MISSED_CALL = 'missed_call'

/**
* Get participants of a call in a conversation
* @param token - Conversation token
Expand All @@ -49,6 +51,9 @@ async function hasCurrentUserJoinedCall(token: string) {
throw new Error('Cannot check whether current join the call - no current user found')
}
const participants = await getCallParticipants(token)
if (!participants.length) {
throw new Error('There are currently no participants in the call', { cause: MISSED_CALL })
}
return participants.some((participant) => user.uid === participant.actorId)
}

Expand Down Expand Up @@ -76,6 +81,10 @@ export function waitCurrentUserHasJoinedCall(token: string, limit?: number): Pro
return resolve(true)
}
} catch (e) {
if (e instanceof Error && e.cause === MISSED_CALL) {
console.debug(e)
resolve(false)
}
console.warn('Error while checking if the user has joined the call', e)
}

Expand Down

0 comments on commit e94a922

Please sign in to comment.