use topic.latestMsgVersion instead of iteration over versions
This commit is contained in:
@@ -1814,11 +1814,10 @@ class TinodeWeb extends React.Component {
|
|||||||
// Check if we have a later version of the message (which means the call
|
// Check if we have a later version of the message (which means the call
|
||||||
// has been either accepted or finished).
|
// has been either accepted or finished).
|
||||||
let isNewCall = true;
|
let isNewCall = true;
|
||||||
topic.messageVersions(data, (msg) => {
|
const msg = topic.latestMsgVersion(data.seq) || data;
|
||||||
if (msg.head.webrtc && msg.head.webrtc != CALL_HEAD_STARTED) {
|
if (msg.head.webrtc && msg.head.webrtc != CALL_HEAD_STARTED) {
|
||||||
isNewCall = false;
|
isNewCall = false;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (isNewCall) {
|
if (isNewCall) {
|
||||||
// This is a legit new call.
|
// This is a legit new call.
|
||||||
if (data.from != this.state.myUserId) {
|
if (data.from != this.state.myUserId) {
|
||||||
@@ -1837,7 +1836,7 @@ class TinodeWeb extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('Could not find topic', data.topic);
|
console.warn("Received vc data message from unknown topic", data.topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-15
@@ -7712,6 +7712,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
this.handleHideForwardDialog = this.handleHideForwardDialog.bind(this);
|
this.handleHideForwardDialog = this.handleHideForwardDialog.bind(this);
|
||||||
this.handleStartVideoCall = this.handleStartVideoCall.bind(this);
|
this.handleStartVideoCall = this.handleStartVideoCall.bind(this);
|
||||||
this.handleInfoMessage = this.handleInfoMessage.bind(this);
|
this.handleInfoMessage = this.handleInfoMessage.bind(this);
|
||||||
|
this.handleDataMessage = this.handleDataMessage.bind(this);
|
||||||
this.handleCallClose = this.handleCallClose.bind(this);
|
this.handleCallClose = this.handleCallClose.bind(this);
|
||||||
this.handleCallInvite = this.handleCallInvite.bind(this);
|
this.handleCallInvite = this.handleCallInvite.bind(this);
|
||||||
this.handleCallRinging = this.handleCallRinging.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.onDisconnect = this.handleDisconnect;
|
||||||
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
|
this.tinode.onAutoreconnectIteration = this.handleAutoreconnectIteration;
|
||||||
this.tinode.onInfoMessage = this.handleInfoMessage;
|
this.tinode.onInfoMessage = this.handleInfoMessage;
|
||||||
|
this.tinode.onDataMessage = this.handleDataMessage;
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (this.state.desktopAlertsEnabled) {
|
if (this.state.desktopAlertsEnabled) {
|
||||||
this.initFCMessaging().then(() => {
|
this.initFCMessaging().then(() => {
|
||||||
@@ -9392,21 +9394,6 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (info.event) {
|
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':
|
case 'accept':
|
||||||
if (tinode_sdk__WEBPACK_IMPORTED_MODULE_4__.Tinode.isMeTopicName(info.topic) && this.tinode.isMe(info.from)) {
|
if (tinode_sdk__WEBPACK_IMPORTED_MODULE_4__.Tinode.isMeTopicName(info.topic) && this.tinode.isMe(info.from)) {
|
||||||
this.setState({
|
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() {
|
render() {
|
||||||
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
||||||
id: "app-container",
|
id: "app-container",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7
-7
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user