Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-18 21:54:07 +0300
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2020-05-26 13:28:43 +0300
commit035a751c57ed178cde1c2ea31e8674b8e1f0d0ec (patch)
treece5093e1a74816516f6611584dfe893523f91264 /src/utils/signaling.js
parent375360ec543c945bfab9157990017ee5292a5a49 (diff)
Fix "joinCall" of standalone signaling not returning a promise
"Signaling.Standalone.joinCall" should return a promise, like done for "Signaling.Base.joinCall". The standalone signaling object is able to defer joining a call if called before its room has been joined. However, it only takes into account the last room that a call was tried to be joined in. This is still the case now when the promise is returned; if "joinCall" is called on a different room while a previous was pending the previous one is just rejected (although if it is in the same room the previous promise is reused). Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'src/utils/signaling.js')
-rw-r--r--src/utils/signaling.js34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/utils/signaling.js b/src/utils/signaling.js
index c15ac82be..8ebd2ede7 100644
--- a/src/utils/signaling.js
+++ b/src/utils/signaling.js
@@ -930,21 +930,43 @@ Signaling.Standalone.prototype._joinRoomSuccess = function(token, nextcloudSessi
Signaling.Standalone.prototype.joinCall = function(token, flags) {
if (this.signalingRoomJoined !== token) {
console.debug('Not joined room yet, not joining call', token)
- this.pendingJoinCall = {
- token: token,
- flags: flags,
+
+ if (this.pendingJoinCall && this.pendingJoinCall.token === token) {
+ return this.pendingJoinCall.promise
+ } else if (this.pendingJoinCall && this.pendingJoinCall.token !== token) {
+ this.pendingJoinCall.reject(new Error('Pending join call canceled for ' + this.pendingJoinCall.token))
}
- return
+
+ const promise = new Promise((resolve, reject) => {
+ this.pendingJoinCall = {
+ token: token,
+ flags: flags,
+ resolve: resolve,
+ reject: reject,
+ }
+ })
+
+ this.pendingJoinCall.promise = promise
+
+ return this.pendingJoinCall.promise
}
- Signaling.Base.prototype.joinCall.apply(this, arguments)
+ return Signaling.Base.prototype.joinCall.apply(this, arguments)
}
Signaling.Standalone.prototype.joinResponseReceived = function(data, token) {
console.debug('Joined', data, token)
this.signalingRoomJoined = token
if (this.pendingJoinCall && token === this.pendingJoinCall.token) {
- this.joinCall(this.pendingJoinCall.token, this.pendingJoinCall.flags)
+ const pendingJoinCallResolve = this.pendingJoinCall.resolve
+ const pendingJoinCallReject = this.pendingJoinCall.reject
+
+ this.joinCall(this.pendingJoinCall.token, this.pendingJoinCall.flags).then(() => {
+ pendingJoinCallResolve()
+ }).catch(error => {
+ pendingJoinCallReject(error)
+ })
+
this.pendingJoinCall = null
}
if (this.roomCollection) {