Fix joining deleted call links leaving call active

This commit is contained in:
ayumi-signal 2024-10-07 15:17:02 -07:00 committed by GitHub
parent a3b972f6e7
commit 25d206e4f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 68 additions and 24 deletions

View file

@ -2252,6 +2252,7 @@ const _startCallLinkLobby = async ({
return;
}
let success = false;
try {
dispatch({
type: WAITING_FOR_CALL_LINK_LOBBY,
@ -2342,22 +2343,25 @@ const _startCallLinkLobby = async ({
isConversationTooBigToRing: false,
},
});
success = true;
} catch (error) {
log.error(`${logId}: Failed to start lobby`, Errors.toLogFormat(error));
} finally {
if (!success) {
try {
calling.stopCallingLobby(roomId);
} catch (innerError) {
log.error(
`${logId}: Failed to stop calling lobby`,
Errors.toLogFormat(innerError)
);
}
try {
calling.stopCallingLobby(roomId);
} catch (innerError) {
log.error(
`${logId}: Failed to stop calling lobby`,
Errors.toLogFormat(innerError)
);
dispatch({
type: CALL_LOBBY_FAILED,
payload: { conversationId: roomId },
});
}
dispatch({
type: CALL_LOBBY_FAILED,
payload: { conversationId: roomId },
});
}
};
@ -2437,6 +2441,7 @@ function startCallingLobby({
return;
}
let success = false;
try {
dispatch({
type: WAITING_FOR_CALLING_LOBBY,
@ -2473,22 +2478,25 @@ function startCallingLobby({
isConversationTooBigToRing: isConversationTooBigToRing(conversation),
},
});
success = true;
} catch (error) {
log.error(`${logId}: Failed to start lobby`, Errors.toLogFormat(error));
} finally {
if (!success) {
try {
calling.stopCallingLobby(conversationId);
} catch (innerError) {
log.error(
`${logId}: Failed to stop calling lobby`,
Errors.toLogFormat(innerError)
);
}
try {
calling.stopCallingLobby(conversationId);
} catch (innerError) {
log.error(
`${logId}: Failed to stop calling lobby`,
Errors.toLogFormat(innerError)
);
dispatch({
type: CALL_LOBBY_FAILED,
payload: { conversationId },
});
}
dispatch({
type: CALL_LOBBY_FAILED,
payload: { conversationId },
});
}
};
}