Skip to content

Commit

Permalink
fix(android) fix joining meetings in quick succession
Browse files Browse the repository at this point in the history
If the readyToClose event was fired there is no need to "leave" the
meeting, it just circles back to the app unnecessarily, potentially
creating another readyToClose event.
  • Loading branch information
saghul authored and Calinteodor committed Aug 21, 2024
1 parent d6fa066 commit 73c836f
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class JitsiMeetActivity extends AppCompatActivity
private static final String ACTION_JITSI_MEET_CONFERENCE = "org.jitsi.meet.CONFERENCE";
private static final String JITSI_MEET_CONFERENCE_OPTIONS = "JitsiMeetConferenceOptions";

private boolean isReadyToClose;

private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Expand Down Expand Up @@ -124,14 +126,19 @@ public void onStop() {

@Override
public void onDestroy() {
JitsiMeetLogger.i("onDestroy()");

// Here we are trying to handle the following corner case: an application using the SDK
// is using this Activity for displaying meetings, but there is another "main" Activity
// with other content. If this Activity is "swiped out" from the recent list we will get
// Activity#onDestroy() called without warning. At this point we can try to leave the
// current meeting, but when our view is detached from React the JS <-> Native bridge won't
// be operational so the external API won't be able to notify the native side that the
// conference terminated. Thus, try our best to clean up.
leave();
if (!isReadyToClose) {
JitsiMeetLogger.i("onDestroy(): leaving...");
leave();
}

this.jitsiView = null;

Expand All @@ -149,8 +156,12 @@ public void onDestroy() {

@Override
public void finish() {
leave();
if (!isReadyToClose) {
JitsiMeetLogger.i("finish(): leaving...");
leave();
}

JitsiMeetLogger.i("finish(): finishing...");
super.finish();
}

Expand Down Expand Up @@ -252,6 +263,7 @@ protected void onParticipantLeft(HashMap<String, Object> extraData) {

protected void onReadyToClose() {
JitsiMeetLogger.i("SDK is ready to close");
isReadyToClose = true;
finish();
}

Expand Down

0 comments on commit 73c836f

Please sign in to comment.