From 877a7d1e9a0f93507d58e46b415d8a6a8b45ee3e Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Mon, 25 Sep 2023 15:33:00 +0530 Subject: [PATCH] fix(meeting): do not call leavemeeting if not joined --- src/components/hooks/useMeetingDestination.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/hooks/useMeetingDestination.js b/src/components/hooks/useMeetingDestination.js index 241eee440..c1a66271a 100644 --- a/src/components/hooks/useMeetingDestination.js +++ b/src/components/hooks/useMeetingDestination.js @@ -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'; @@ -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) {