From 8df05367b1361f09998897cba511092199e31b8a Mon Sep 17 00:00:00 2001 From: Ayushya Amitabh Date: Sat, 25 Jul 2020 23:04:36 -0400 Subject: [PATCH] v1.5.2/auto leave --- app/src/Create.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/Create.js b/app/src/Create.js index c2dbdda..4cdbaf5 100644 --- a/app/src/Create.js +++ b/app/src/Create.js @@ -24,6 +24,7 @@ import { PLAYER_STATUS, getPlayerSource, LocalData, + LeaveRoomApi, updateLocalData, getUserUid, } from './Api'; @@ -57,10 +58,19 @@ export default class Create extends Component { } componentDidMount() { const { lastActive, userName, partyName, partyPin } = LocalData(); - if (Math.abs(new Date(parseInt(lastActive)) - new Date().getTime()) <= 60000) { - if (userName && partyName && partyPin) { + if (userName && partyName && partyPin) { + if (Math.abs(new Date(parseInt(lastActive)) - new Date().getTime()) <= 60000) { this.props.updateLoading(true); this.joinCall(userName, partyName, partyPin); + } else { + this.props.updateLoading(true); + const data = { + partyName: LocalData().partyName, + userUid: LocalData().userUid, + }; + LeaveRoomApi(data).then((res) => { + this.props.updateLoading(false); + }); } } }