From 824f15aa292244c9cf96c114daa85dafeb4d16d7 Mon Sep 17 00:00:00 2001 From: aforge Date: Mon, 14 Mar 2022 00:55:29 -0700 Subject: [PATCH] Hangup upon topic change. --- src/views/messages-view.jsx | 18 +++++++----------- src/widgets/rtc-panel.jsx | 1 + 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/views/messages-view.jsx b/src/views/messages-view.jsx index 238682f5..def9cc88 100644 --- a/src/views/messages-view.jsx +++ b/src/views/messages-view.jsx @@ -165,6 +165,11 @@ class MessagesView extends React.Component { if (this.state.topic != prevState.topic) { if (prevState.topic && !Tinode.isNewGroupTopicName(prevState.topic)) { this.leave(prevState.topic); + if (prevState.rtcPanel) { + console.log('hangup: ', prevState.topic); + this.props.onTeleHangup(prevState.topic, prevProps.callSeq); + this.handleRtcClose(); + } } if (topic) { @@ -176,17 +181,7 @@ class MessagesView extends React.Component { topic.onPres = this.handleSubsUpdated; } } - /* - if (this.props.callTopic == this.props.topic && !this.state.rtcPanel) { - this.handleRtcClick(); - } - */ - /* - if (this.state.rtcPanel == null && topic && topic.name == this.props.callTopic && (this.props.callState == 1 || this.props.callState == 3)) { - console.log('--> setting rtc panel, call state = ', this.props.callState); - this.setState({rtcPanel: { topic: this.props.callTopic }}); - } - */ + if (!this.props.applicationVisible) { // If application is not visible, flush all unsent 'read' notifications. this.clearNotificationQueue(); @@ -418,6 +413,7 @@ class MessagesView extends React.Component { if (!oldTopicName || !this.props.tinode.isTopicCached(oldTopicName)) { return; } + const oldTopic = this.props.tinode.getTopic(oldTopicName); if (oldTopic && oldTopic.isSubscribed()) { oldTopic.leave(false) diff --git a/src/widgets/rtc-panel.jsx b/src/widgets/rtc-panel.jsx index d99a6f51..da49f0a5 100644 --- a/src/widgets/rtc-panel.jsx +++ b/src/widgets/rtc-panel.jsx @@ -121,6 +121,7 @@ export default class RtcPanel extends React.PureComponent { componentWillUnmount() { this.props.topic.onInfo = this.previousOnInfo; + this.stop(); } launchStream() {