Skip to content

Commit

Permalink
fix(meeting): do not call leavemeeting if not joined
Browse files Browse the repository at this point in the history
  • Loading branch information
rajeshtezu authored and rarajes2 committed Sep 26, 2023
1 parent 9ddbaa2 commit 877a7d1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/hooks/useMeetingDestination.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useContext, useState} from 'react';
import {MeetingState} from '@webex/component-adapter-interfaces';

import {AdapterContext} from './contexts';
import {chainWith} from '../../util';
Expand Down Expand Up @@ -66,17 +67,17 @@ export default function useMeetingDestination(meetingDestination) {
chainWith(({ID}) => meetingsAdapter.getMeeting(ID)),
).subscribe(onMeeting, onError);

let beforePageUnload = () => {
if (lastMeeting?.ID) {
meetingsAdapter.leavemeeting(lastMeeting.ID);
let beforePageUnload = async () => {
if (lastMeeting?.ID && lastMeeting.state === MeetingState.JOINED) {
await meetingsAdapter.leavemeeting(lastMeeting.ID);
}
};

window.addEventListener('beforeunload', beforePageUnload);

cleanup = () => {
if (lastMeeting?.ID) {
meetingsAdapter.leaveMeeting(lastMeeting.ID);
cleanup = async () => {
if (lastMeeting?.ID && lastMeeting.state === MeetingState.JOINED) {
await meetingsAdapter.leaveMeeting(lastMeeting.ID);
}

if (beforePageUnload) {
Expand Down

0 comments on commit 877a7d1

Please sign in to comment.