Skip to content

Commit

Permalink
fix: handle leaving a 1:1 call over SFT [WPB-7151] (#17883)
Browse files Browse the repository at this point in the history
* fix: handle leaving a 1:1 call over SFT [WPB-7151]

* bump core to the new hotfix version

* compare participant with self participant id istead of relying on position in the array
  • Loading branch information
V-Gira authored Aug 12, 2024
1 parent 6608a4c commit ec71dc1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@lexical/react": "0.12.5",
"@wireapp/avs": "9.6.15",
"@wireapp/commons": "5.2.7",
"@wireapp/core": "46.0.17-hotfix-1.1",
"@wireapp/core": "46.0.17-hotfix-1.2",
"@wireapp/react-ui-kit": "9.16.4",
"@wireapp/store-engine-dexie": "2.1.8",
"@wireapp/webapp-events": "0.20.1",
Expand Down
53 changes: 52 additions & 1 deletion src/script/calling/CallingRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,14 @@ export class CallingRepository {
return this.conversationState.findConversation(conversationId);
}

private readonly leave1on1MLSConference = async (conversationId: QualifiedId) => {
await this.subconversationService.leave1on1ConferenceSubconversation(conversationId);

const conversationIdStr = this.serializeQualifiedId(conversationId);
this.wCall?.end(this.wUser, conversationIdStr);
callingSubscriptions.removeCall(conversationId);
};

private readonly leaveMLSConference = async (conversationId: QualifiedId) => {
await this.subconversationService.leaveConferenceSubconversation(conversationId);
callingSubscriptions.removeCall(conversationId);
Expand Down Expand Up @@ -1410,13 +1418,18 @@ export class CallingRepository {
Warnings.hideWarning(Warnings.TYPE.CALL_QUALITY_POOR);
const conversationId = this.parseQualifiedId(convId);
const call = this.findCall(conversationId);
const conversation = this.getConversationById(conversationId);
if (!call) {
return;
}

// There's nothing we need to do for non-mls calls
if (call.conversationType === CONV_TYPE.CONFERENCE_MLS) {
await this.leaveMLSConference(conversationId);
if (!conversation?.is1to1()) {
await this.leaveMLSConference(conversationId);
} else {
await this.leave1on1MLSConference(conversationId);
}
}

if (reason === REASON.NORMAL) {
Expand Down Expand Up @@ -1666,13 +1679,51 @@ export class CallingRepository {
userId: this.parseQualifiedId(member.userid),
}));

this.handleOneToOneMlsCallParticipantLeave(conversationId, members);
this.updateParticipantList(call, members);
this.updateParticipantMutedState(call, members);
this.updateParticipantVideoState(call, members);
this.updateParticipantAudioState(call, members);
this.handleCallParticipantChange(conversationId, members);
};

private readonly handleOneToOneMlsCallParticipantLeave = (
conversationId: QualifiedId,
members: QualifiedWcallMember[],
) => {
const conversation = this.getConversationById(conversationId);
const call = this.findCall(conversationId);

if (!conversation || !this.isMLSConference(conversation) || !conversation?.is1to1() || !call) {
return;
}

const selfParticipant = call.getSelfParticipant();

const nextOtherParticipant = members.find(
participant => !matchQualifiedIds(participant.userId, selfParticipant.user.qualifiedId),
);

if (!nextOtherParticipant) {
return;
}

const currentOtherParticipant = call
.participants()
.find(participant => matchQualifiedIds(nextOtherParticipant.userId, participant.user.qualifiedId));

if (!currentOtherParticipant) {
return;
}

const isCurrentlyEstablished = currentOtherParticipant.isAudioEstablished();
const {aestab: newEstablishedStatus} = nextOtherParticipant;

if (isCurrentlyEstablished && newEstablishedStatus === AUDIO_STATE.CONNECTING) {
void this.leave1on1MLSConference(conversationId);
}
};

private readonly requestClients = async (wUser: number, convId: SerializedConversationId, __: number) => {
const call = this.findCall(this.parseQualifiedId(convId));
if (!call) {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4775,9 +4775,9 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:46.0.17-hotfix-1.1":
version: 46.0.17-hotfix-1.1
resolution: "@wireapp/core@npm:46.0.17-hotfix-1.1"
"@wireapp/core@npm:46.0.17-hotfix-1.2":
version: 46.0.17-hotfix-1.2
resolution: "@wireapp/core@npm:46.0.17-hotfix-1.2"
dependencies:
"@wireapp/api-client": ^27.1.0-hotfix-1.0
"@wireapp/commons": ^5.2.8
Expand All @@ -4797,7 +4797,7 @@ __metadata:
long: ^5.2.0
uuid: 9.0.1
zod: 3.23.8
checksum: e345882a734ea8d37c800f360fa4777389a63249ac532c3c5f1eb5c51ca618155f5e9138c0c7cb1e582d5a8947c515073d24c8e1b2ec2df4de3f7e60c88e31be
checksum: 03a428e43bcc5e4accea630d643ee871023eed738a39c73c49c59cbd7c712bf14fd7747667a9392084032e7d599b356914f26fbfdb5e0eb2e7a58358318e4113
languageName: node
linkType: hard

Expand Down Expand Up @@ -17508,7 +17508,7 @@ __metadata:
"@wireapp/avs": 9.6.15
"@wireapp/commons": 5.2.7
"@wireapp/copy-config": 2.1.14
"@wireapp/core": 46.0.17-hotfix-1.1
"@wireapp/core": 46.0.17-hotfix-1.2
"@wireapp/eslint-config": 3.0.5
"@wireapp/prettier-config": 0.6.3
"@wireapp/react-ui-kit": 9.16.4
Expand Down

0 comments on commit ec71dc1

Please sign in to comment.