use topic.latestMsgVersion instead of iteration over versions

This commit is contained in:
or-else
2022-06-29 10:15:57 -07:00
parent 315631f67c
commit dcf9e1d47e
7 changed files with 49 additions and 32 deletions
+5 -6
View File
@@ -1814,11 +1814,10 @@ class TinodeWeb extends React.Component {
// Check if we have a later version of the message (which means the call
// has been either accepted or finished).
let isNewCall = true;
topic.messageVersions(data, (msg) => {
if (msg.head.webrtc && msg.head.webrtc != CALL_HEAD_STARTED) {
isNewCall = false;
}
});
const msg = topic.latestMsgVersion(data.seq) || data;
if (msg.head.webrtc && msg.head.webrtc != CALL_HEAD_STARTED) {
isNewCall = false;
}
if (isNewCall) {
// This is a legit new call.
if (data.from != this.state.myUserId) {
@@ -1837,7 +1836,7 @@ class TinodeWeb extends React.Component {
}
}
} else {
console.log('Could not find topic', data.topic);
console.warn("Received vc data message from unknown topic", data.topic);
}
}
}
+33 -15
View File
@@ -7712,6 +7712,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
this.handleHideForwardDialog = this.handleHideForwardDialog.bind(this);
this.handleStartVideoCall = this.handleStartVideoCall.bind(this);
this.handleInfoMessage = this.handleInfoMessage.bind(this);
this.handleDataMessage = this.handleDataMessage.bind(this);
this.handleCallClose = this.handleCallClose.bind(this);
this.handleCallInvite = this.handleCallInvite.bind(this);
this.handleCallRinging = this.handleCallRinging.bind(this);
@@ -7811,6 +7812,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
this.tinode.onDisconnect = this.handleDisconnect;
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
this.tinode.onInfoMessage = this.handleInfoMessage;
this.tinode.onDataMessage = this.handleDataMessage;
}).then(() => {
if (this.state.desktopAlertsEnabled) {
this.initFCMessaging().then(() => {
@@ -9392,21 +9394,6 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
}
switch (info.event) {
case 'invite':
if (info.from != this.state.myUserId) {
if (this.state.callState == _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_STATE_NONE) {
this.setState({
callTopic: info.src,
callState: _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_STATE_INCOMING_RECEIVED,
callSeq: info.seq
});
} else {
this.handleCallHangup(info.src, info.seq);
}
}
break;
case 'accept':
if (tinode_sdk__WEBPACK_IMPORTED_MODULE_4__.Tinode.isMeTopicName(info.topic) && this.tinode.isMe(info.from)) {
this.setState({
@@ -9431,6 +9418,37 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
}
}
handleDataMessage(data) {
if (data.head && data.head.webrtc && data.head.webrtc == _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_HEAD_STARTED) {
const topic = this.tinode.getTopic(data.topic);
if (topic) {
let isNewCall = true;
const msg = topic.latestMsgVersion(data.seq) || data;
if (msg.head.webrtc && msg.head.webrtc != _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_HEAD_STARTED) {
isNewCall = false;
}
if (isNewCall) {
if (data.from != this.state.myUserId) {
if (this.state.callState == _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_STATE_NONE) {
this.setState({
callTopic: data.topic,
callState: _constants_js__WEBPACK_IMPORTED_MODULE_13__.CALL_STATE_INCOMING_RECEIVED,
callSeq: data.seq
});
} else {
this.handleCallHangup(data.topic, data.seq);
}
}
}
} else {
console.warn("Received vc data message from unknown topic", data.topic);
}
}
}
render() {
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
id: "app-container",
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7 -7
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long