Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for group calls using MSC3401 #2553

Merged
merged 364 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
364 commits
Select commit Hold shift + click to select a range
0148ad0
Group call improvements (#1985)
SimonBrandner Oct 19, 2021
e9b52e2
Rermove session id
robertlong Oct 19, 2021
431d7a0
Merge branch 'develop' into robertlong/group-call
robertlong Oct 19, 2021
8131b39
Use glare resolution to manage group call setup
robertlong Oct 19, 2021
159e825
Fix unnecessary param to placeCallWithCallFeeds
robertlong Oct 19, 2021
0555f9d
Only send to device messages to a single device
robertlong Oct 20, 2021
305de54
Fix screensharing and webrtc races
robertlong Oct 21, 2021
5110e0b
Merge branch 'develop' into robertlong/group-call
robertlong Oct 21, 2021
3b0d1b2
Add check for existing group call session
robertlong Oct 21, 2021
b4d8c0b
Fix updating member state with no existing calls
robertlong Oct 22, 2021
fc8a867
Start processing member state events only after we've set out own (#2…
SimonBrandner Oct 25, 2021
119ce2e
Fix inbound calls in Safari
robertlong Oct 26, 2021
9f3f999
untested first cut at factoring out a encryptAndSendToDevices method
ara4n Oct 18, 2021
aeeed6e
clarify the factoring
ara4n Oct 18, 2021
24406d2
make it build
ara4n Oct 18, 2021
56c0c9b
fix example in readme
ara4n Oct 19, 2021
5a83635
switch encryptAndSendToDevices to return a promise rather than use a cb
ara4n Oct 20, 2021
53397ee
lint
ara4n Oct 20, 2021
f46355e
don't choke on missing promise
ara4n Oct 20, 2021
2f09e96
chain promises correctly; log rejects
ara4n Oct 20, 2021
a48546f
fix the tests (thanks @turt2live!!!)
ara4n Oct 20, 2021
841e6e9
handle promises normally now tests are fixed
ara4n Oct 20, 2021
067ac62
lint
ara4n Oct 20, 2021
32aca09
Merge branch 'to-device-olm' into robertlong/group-call
robertlong Oct 26, 2021
13d62e7
Fix stopping all media streams
robertlong Oct 26, 2021
923e9c4
Ensure that member call state is set correctly
robertlong Oct 28, 2021
8c5f88c
Fix handling null call
robertlong Oct 28, 2021
4c9648a
Sanitize call member state
robertlong Oct 28, 2021
d99428f
Remove duplicate call answer
robertlong Nov 2, 2021
6f695c1
Ignore call call state in glare resolution
robertlong Nov 2, 2021
5a92597
Check if call ended before getting user media
robertlong Nov 2, 2021
bdc12a2
Revert changes to gotCallFeedsForAnswer
robertlong Nov 3, 2021
7998817
Send candidate queue again on finish to flush out queue
robertlong Nov 4, 2021
c1f56ba
Fix indentation
robertlong Nov 4, 2021
b253ad9
Preserve the disabled tracks when updating local usermedia stream
robertlong Nov 5, 2021
17f7dc5
Keep track of original stream id for sdp stream metadata
robertlong Nov 5, 2021
f76f708
Ad a longer wait to safari media stream hack
robertlong Nov 5, 2021
4b87907
Update local usermedia streams serially
robertlong Nov 8, 2021
74c5a20
Temporarily disable safari hack
robertlong Nov 8, 2021
a2e255c
Merge branch 'robertlong/group-call' of github.com:matrix-org/matrix-…
robertlong Nov 8, 2021
f28cb48
Re-enable safari hack
robertlong Nov 8, 2021
97e8fce
Clean up replacing calls for Safari
robertlong Nov 9, 2021
e880cec
Add restart ICE
robertlong Nov 9, 2021
28da62c
Add retry call loop
robertlong Nov 9, 2021
7d48a83
Don't immediately start retry call loop
robertlong Nov 15, 2021
3139112
Clean up logging
robertlong Nov 15, 2021
4e26f29
Add unknown device errors
robertlong Nov 15, 2021
c2fe2ab
Add additional logging for removing feeds/tracks
robertlong Nov 15, 2021
139904f
Update sync state to error when aborting
robertlong Nov 18, 2021
3291846
Merge branch 'robertlong/abort-sync-error' into robertlong/group-call
robertlong Nov 18, 2021
5f06df8
Properly stop screensharing feed
robertlong Nov 18, 2021
64c3ac5
Stop screenshare when screensharing track ended
robertlong Nov 19, 2021
0683133
Dont start retry loop until weve sent the member state event
robertlong Nov 20, 2021
96ef535
Make unknown device error more useful
robertlong Nov 20, 2021
d0e37ee
Hopefully resolve a race condition with missing device ids
robertlong Nov 20, 2021
ffbd10a
Make updateLocalUsermediaStreams stop tracks
robertlong Nov 22, 2021
d1a62ed
Set initial audio/video input ids
robertlong Nov 24, 2021
fcc4b71
Add LocalStreamsChanged event to MediaHandler
robertlong Nov 29, 2021
e336ace
Expose webrtc related types/props
robertlong Nov 30, 2021
06d9d62
Send device id along with to device signaling messages
robertlong Nov 30, 2021
549f9b7
Disable retries
robertlong Jan 6, 2022
bef5579
Emit sent voip events
robertlong Jan 6, 2022
7993dd7
Log opponentDeviceId
robertlong Jan 6, 2022
f3f9e41
Emit sent voip events
robertlong Jan 6, 2022
18bb5c3
Log opponentDeviceId
robertlong Jan 6, 2022
87bf115
Use session ids to resolve refresh during invite/answer
robertlong Jan 10, 2022
c91617a
Force hangup replaced calls
robertlong Jan 11, 2022
487bfc8
Merge branch 'robertlong/group-call-session-id' into robertlong/group…
robertlong Jan 11, 2022
3fac6d7
Replace outbound calls only
robertlong Jan 11, 2022
7529af4
Add NewSession CallErrorCode
robertlong Jan 12, 2022
ee995cb
Ensure call events are processed once and in order
robertlong Jan 12, 2022
eeacf8c
Dont filter unstable call events
robertlong Jan 12, 2022
d8285aa
Remove call from callEventHandler after hangup
robertlong Jan 12, 2022
28f3169
Use replace error code when replacing incoming calls
robertlong Jan 12, 2022
42fef0e
Add user id to all send voip events
robertlong Jan 13, 2022
015eb5d
Add sender/dest session ids
robertlong Jan 14, 2022
592fb0c
Re-enable retries
robertlong Jan 18, 2022
bbf7020
Remove log
robertlong Jan 18, 2022
1a78301
Fix restartIce on FF Android
robertlong Feb 4, 2022
4a4465b
Don't send candidates after the call has ended
robertlong Feb 7, 2022
d42e2fe
Ignore duplicate streams when adding local feeds
robertlong Feb 10, 2022
b4fe00a
Add answer/negotiate response promise chain
robertlong Feb 10, 2022
c801690
Don't reuse local call feeds that have been added to a RTCPeerConnection
robertlong Feb 12, 2022
d8e597c
Avoid glare
robertlong Feb 12, 2022
d12bccd
Remove safari hack
robertlong Feb 15, 2022
a2a127d
Remove unused isSafari check
robertlong Feb 15, 2022
3db056a
Enable max-bundle (#2182)
dbkr Feb 16, 2022
fa5eae7
Log complete sync errors
robertlong Feb 17, 2022
7f21f56
Process toDevice events in order
robertlong Feb 17, 2022
353d6ba
Fix and add a test for toDevice ordering
robertlong Feb 18, 2022
7a249e3
Switch media devices on disconnect
robertlong Feb 18, 2022
0ef6c2e
Add callId to all logs
robertlong Feb 19, 2022
e270f07
Fix call log
robertlong Feb 23, 2022
17f5ab4
Move device changes to the application. Add methods to set device ids
robertlong Feb 23, 2022
c819ac6
Fix updating local media streams
robertlong Feb 24, 2022
e68cabc
Add logging for all stream creation/cloning/muting
robertlong Feb 24, 2022
49994ac
Add checks for call/groupCall ended for updateLocalUsermediaStream
robertlong Feb 25, 2022
09fee4a
Allow calls to terminate properly when calling stopClient
robertlong Feb 25, 2022
94c5e37
Fix import
robertlong Feb 25, 2022
6e25b13
Send / add end-of-candidates messages
robertlong Mar 1, 2022
2a0dc39
Fix bug with ine-way audio after a transfer (#2193)
dbkr Feb 23, 2022
ee4cbd1
Don't remove streams that still have tracks (#2104)
dbkr Jan 14, 2022
96ba061
Fix shouldRequestAudio logging
robertlong Mar 2, 2022
8d9cd0f
Support for PTT group call mode (#2338)
dbkr May 3, 2022
d82c041
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr May 9, 2022
9702e8a
Remove test 'fix'
dbkr May 9, 2022
85a6a55
Make tests pass again
dbkr May 10, 2022
83f61c9
Merge remote-tracking branch 'origin/develop' into dbkr/group-call-merge
dbkr May 10, 2022
f475251
Merge remote-tracking branch 'origin/develop' into dbkr/group-call-merge
dbkr May 10, 2022
f4f0555
Merge branch 'develop' into dbkr/group-call-merge
t3chguy May 10, 2022
da615fd
More setTimeout typings
dbkr May 10, 2022
acef1d7
Merge branch 'dbkr/group-call-merge' of github.com:matrix-org/matrix-…
dbkr May 10, 2022
38e54ae
Remove PTT 'other user speaking' logic (#2362)
dbkr May 11, 2022
87791cd
Fix races when muting/unmuting (#2370)
dbkr May 13, 2022
942a28d
Add support for sending encrypted to-device events with OLM (#2322)
robertlong May 18, 2022
aa0d3bd
Handle other members having no e2e keys (#2383)
dbkr May 19, 2022
18e2052
Wait for mute event to send in PTT mode (#2401)
dbkr May 26, 2022
34ef7bc
Mute disconnected peers in PTT mode (#2421)
dbkr May 31, 2022
5e76697
Set PTT mode on call correctly (#2445)
dbkr Jun 8, 2022
b97b862
Emit unknown device errors for group call participants without e2e (#…
dbkr Jun 10, 2022
404f8e1
Only clone streams on Safari (#2450)
dbkr Jun 10, 2022
04d0d61
Change CODEOWNERS for element-call feature branch (#2457)
turt2live Jun 13, 2022
9192b87
Disable playback of audio for muted users (#2456)
dbkr Jun 13, 2022
70449ea
Expire call member state events after 1 hour (#2446)
robintown Jun 16, 2022
df9ffdc
Don't ignore call member events with a distant future expiration date…
robintown Jun 16, 2022
5b4263b
Don't block muting on determining whether the device exists (#2461)
robintown Jun 16, 2022
ebcb26f
Merge branch 'develop' into robertlong/group-call
robintown Jun 21, 2022
c89bbf4
Fix call.collectCallStats() (#2480)
dbkr Jun 29, 2022
f553854
Remove the feature to disable audio from muted members (#2479)
dbkr Jun 29, 2022
e7493fd
Enable DTX on audio tracks in calls (#2482)
robintown Jun 29, 2022
f9672cf
Fix some MatrixCall leaks and use a shared AudioContext (#2484)
robintown Jul 1, 2022
ca5ac79
Revert hack to only clone streams on safari (#2485)
dbkr Jul 1, 2022
6ea2885
Remove empty decryption listener (#2486)
dbkr Jul 1, 2022
e980c88
Don't mute the remote side immediately in PTT calls (#2487)
robintown Jul 2, 2022
9a15094
Add config option for e2e group call signalling (#2492)
dbkr Jul 5, 2022
bdb91b3
Set max average bitrate on PTT calls (#2499)
dbkr Jul 6, 2022
984dd26
Prevent double mute status changed events (#2502)
dbkr Jul 8, 2022
544b1c6
Merge develop into group call branch again (#2513)
dbkr Jul 12, 2022
e876482
Add local volume control (#2525)
SimonBrandner Jul 25, 2022
38a6949
add missing events from reemitter to GroupCall (#2527)
toger5 Jul 25, 2022
9e2e144
Make SDP munging media type specific (#2526)
dbkr Jul 28, 2022
8ba2d25
Add support for audio sharing (#2530)
SimonBrandner Jul 28, 2022
b711781
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Jul 29, 2022
22c5999
Delint group calls (#2554)
SimonBrandner Aug 1, 2022
2cc51e0
Merge changes from develop (#2563)
dbkr Aug 4, 2022
c0dacb5
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Aug 5, 2022
471f174
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Aug 5, 2022
88ce017
Fix return types of event sending functions (#2576)
dbkr Aug 9, 2022
0b8de25
Add basic creation / entering tests for group calls (#2575)
dbkr Aug 9, 2022
3334c01
Support nested Matrix clients via the widget API (#2473)
robintown Aug 9, 2022
5f5a9b1
Merge branch 'develop' into robertlong/group-call
dbkr Aug 10, 2022
0207431
Tidy up imports (#2584)
dbkr Aug 10, 2022
e8f682f
Test placing a call in a group call (#2593)
dbkr Aug 16, 2022
c698317
Add group call tests for muting (#2590)
SimonBrandner Aug 17, 2022
e4cf5b2
Add test for updateLocalUsermediaStream (#2596)
dbkr Aug 17, 2022
099cac0
Merge branch 'develop' into robertlong/group-call
dbkr Aug 17, 2022
2566c40
Add tests for incoming calls in group calls (#2597)
dbkr Aug 17, 2022
9589a97
Test muting in PTT mode (#2599)
dbkr Aug 17, 2022
448a5c9
Add screensharing tests (#2598)
SimonBrandner Aug 18, 2022
e95947d
Update lockfile (#2603)
robintown Aug 19, 2022
45e56f8
Add `disposed` to `CallFeed` (#2604)
SimonBrandner Aug 19, 2022
92cd84f
Add unit tests for hangup / reject (#2606)
dbkr Aug 22, 2022
e7a7ec0
Test call timeouts (#2611)
dbkr Aug 22, 2022
5f9369a
Merge branch 'develop' into robertlong/group-call
dbkr Aug 22, 2022
be94f5e
Fix imports
dbkr Aug 22, 2022
4a294c9
1:1 screenshare tests
dbkr Aug 23, 2022
c527f85
Revert 4a294c9dd36109233041ede34e780685c5d69801
dbkr Aug 23, 2022
9e1b126
1:1 screenshare tests (#2617)
dbkr Aug 24, 2022
965f4fb
Fix ICE end-of-candidates messages (#2622)
dbkr Aug 26, 2022
d5b82e3
Add types to the call unit test suites (#2627)
dbkr Aug 31, 2022
db32420
Add logging to diagnose connection issue (#2629)
dbkr Aug 31, 2022
0981652
Add GroupCallEventHandlerEvent.Room (#2631)
dbkr Sep 1, 2022
d656b84
Wait for client to start syncing before making group calls (#2632)
dbkr Sep 1, 2022
40ecfa7
Test disabling screenshare in group calls (#2634)
dbkr Sep 2, 2022
0d6a93b
Refactor the group call placing calls test (#2636)
dbkr Sep 2, 2022
c78631b
Test that calls in a group call are retried (#2637)
dbkr Sep 5, 2022
aca51fd
Test call mute status set on call state chnage (#2638)
dbkr Sep 5, 2022
98d119d
Add client.waitUntilRoomReadyForGroupCalls() (#2641)
dbkr Sep 6, 2022
fa6f70f
Log ID instead of object (#2643)
dbkr Sep 6, 2022
83c8480
MediaHandler Tests (#2646)
dbkr Sep 7, 2022
d950cda
Merge branch 'develop' into robertlong/group-call
dbkr Sep 8, 2022
60e175a
Merge branch 'develop' into robertlong/group-call
dbkr Sep 8, 2022
aebe26d
GroupCallEventhandler Tests (#2654)
dbkr Sep 8, 2022
36a6117
Misc fixes for group call widgets (#2657)
robintown Sep 9, 2022
02f6a09
Test active speaker events (#2658)
dbkr Sep 9, 2022
00629e6
Test fallback screensharing (#2659)
dbkr Sep 9, 2022
3711899
Add test for removing RTX codec (#2660)
dbkr Sep 12, 2022
276849f
Merge branch 'develop' into robertlong/group-call
dbkr Sep 12, 2022
3e1e99f
Fix import in failed merge
dbkr Sep 12, 2022
41cee6f
Fix race in creating calls (#2662)
dbkr Sep 13, 2022
c605310
Prevent exception when muting (#2667)
dbkr Sep 13, 2022
586a313
Add tests for call answering / candidate sending (#2666)
dbkr Sep 14, 2022
c05cb3a
Merge branch 'develop' into robertlong/group-call
dbkr Sep 14, 2022
f52c5eb
Unused imports from merge
dbkr Sep 14, 2022
6fc9827
Add tests for ice candidate sending (#2674)
dbkr Sep 16, 2022
de69445
Target widget actions at a specific room (#2670)
robintown Sep 16, 2022
f41b770
Upgrade matrix-widget-api (and fix the lockfile) (#2676)
robintown Sep 16, 2022
c400dd4
Add a few new `GroupCall` tests (#2678)
SimonBrandner Sep 20, 2022
72b89fd
Add test for call transfers (#2677)
SimonBrandner Sep 20, 2022
72a6ec0
Add a few group call event handler tests (#2679)
SimonBrandner Sep 22, 2022
2a0ffe1
Fix group call tests getting stuck (#2689)
SimonBrandner Sep 22, 2022
6f7a72d
Merge remote-tracking branch 'upstream/develop' into SimonBrandner/ta…
SimonBrandner Sep 23, 2022
4625ed7
Merge pull request #2695 from matrix-org/SimonBrandner/task/gc-merge
SimonBrandner Sep 23, 2022
a2981ef
Add `MatrixClient` group call tests (#2692)
SimonBrandner Sep 23, 2022
af6f9d4
Add `CallEventHandler` tests (#2696)
SimonBrandner Sep 26, 2022
ab39ee3
Add more `MatrixCall` tests (#2697)
SimonBrandner Sep 26, 2022
e48d919
Fix ICE restarts (#2702)
dbkr Sep 27, 2022
9355177
Merge branch 'develop' into robertlong/group-call
robintown Sep 28, 2022
ce3b72c
Merge pull request #2712 from robintown/merge
robintown Sep 29, 2022
c0a5299
Don't block muting/unmuting on network requests
robintown Oct 13, 2022
d521f97
Merge pull request #2754 from robintown/unblock-mute
robintown Oct 13, 2022
3c33c42
Merge branch 'develop' into robertlong/group-call
robintown Oct 14, 2022
dfe535b
More debugging for multiple group calls (#2766)
dbkr Oct 17, 2022
c57c897
Fix screenshare failing after several attempts (#2771)
dbkr Oct 19, 2022
5a07873
Fix connectivity regressions (#2780)
dbkr Oct 19, 2022
eddd0ca
Add throwOnFail to groupCall.setScreensharingEnabled (#2787)
dbkr Oct 24, 2022
8cd5aac
Add event and message capabilities to RoomWidgetClient
robintown Oct 24, 2022
193d8a4
Merge remote-tracking branch 'origin/develop' into dbkr/gcmerge_oct22_3
dbkr Oct 24, 2022
35f697a
Merge pull request #2797 from robintown/matryoshka-events
robintown Oct 24, 2022
b4ab7fc
Merge branch 'robertlong/group-call' into dbkr/gcmerge_oct22_3
dbkr Oct 24, 2022
450ff00
Merge pull request #2800 from matrix-org/dbkr/gcmerge_oct22_3
dbkr Oct 24, 2022
c374ba2
TS strict mode compliance in the call / groupcall code (#2805)
dbkr Oct 26, 2022
384116c
Merge remote-tracking branch 'origin/develop' into dbkr/gcmerge_26oct22
dbkr Oct 26, 2022
0d211df
Clean up group call tests (#2806)
dbkr Oct 26, 2022
0f10122
Fix types
dbkr Oct 26, 2022
4cd50e4
Merge pull request #2807 from matrix-org/dbkr/gcmerge_26oct22
dbkr Oct 26, 2022
5679c86
More TS strict mode fixes
dbkr Oct 26, 2022
87115d1
Don't commit the strict mode flag
dbkr Oct 26, 2022
13c751c
Merge pull request #2808 from matrix-org/dbkr/groupcall_more_strict
dbkr Oct 26, 2022
dbdaa15
Let leave requests outlive the window
robintown Oct 26, 2022
d979302
A few more strict mode fixes
dbkr Oct 27, 2022
77ef855
Merge pull request #2816 from matrix-org/dbkr/groupcall_more_strict
dbkr Oct 27, 2022
9ff6b35
Merge branch 'develop' into robertlong/group-call
dbkr Oct 27, 2022
4c6e1e5
Replace the keepAlive flag with request options
robintown Oct 27, 2022
849e3d6
Merge pull request #2815 from robintown/keepalive-leave
robintown Oct 27, 2022
f0d4ef7
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Oct 31, 2022
b9cccf9
Resolve races between initLocalCallFeed and leave
robintown Oct 31, 2022
94072a0
Merge pull request #2826 from robintown/init-leave-race
robintown Oct 31, 2022
6729c7d
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Nov 1, 2022
cb8123d
Add public/private modifiers
dbkr Nov 1, 2022
476f6f7
Add more access modifiers
dbkr Nov 1, 2022
7ec726e
Give everything that isn't web rtc back to element-web
dbkr Nov 1, 2022
7fb313c
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Nov 2, 2022
32d535c
Don't remove our own member for a split second when entering a call
robintown Nov 3, 2022
8235b65
Merge pull request #2844 from robintown/dont-remove-self
robintown Nov 3, 2022
fff4cda
Merge remote-tracking branch 'origin/develop' into dbkr/gcmerge_20221104
dbkr Nov 4, 2022
2dda837
Fix strict mode errors
dbkr Nov 4, 2022
c8dc71e
Merge pull request #2854 from matrix-org/dbkr/gcmerge_20221104
dbkr Nov 4, 2022
4f63ff2
Merge branch 'develop' into robertlong/group-call
dbkr Nov 4, 2022
f09853c
Merge remote-tracking branch 'origin/develop' into robertlong/group-call
dbkr Nov 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
* @matrix-org/element-web

/src/webrtc @matrix-org/element-call-reviewers
/spec/*/webrtc @matrix-org/element-call-reviewers
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@
],
"dependencies": {
"@babel/runtime": "^7.12.5",
"@types/sdp-transform": "^2.4.5",
"another-json": "^0.2.0",
"bs58": "^5.0.0",
"content-type": "^1.0.4",
"loglevel": "^1.7.1",
"matrix-events-sdk": "0.0.1-beta.7",
"matrix-widget-api": "^1.0.0",
"p-retry": "4",
"qs": "^6.9.6",
"sdp-transform": "^2.14.1",
"unhomoglyph": "^1.0.6"
},
"devDependencies": {
Expand Down Expand Up @@ -102,6 +105,7 @@
"exorcist": "^2.0.0",
"fake-indexeddb": "^4.0.0",
"jest": "^29.0.0",
"jest-environment-jsdom": "^28.1.3",
"jest-localstorage-mock": "^2.4.6",
"jest-mock": "^29.0.0",
"jsdoc": "^3.6.6",
Expand Down
28 changes: 28 additions & 0 deletions spec/test-utils/flushPromises.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Jest now uses @sinonjs/fake-timers which exposes tickAsync() and a number of
// other async methods which break the event loop, letting scheduled promise
// callbacks run. Unfortunately, Jest doesn't expose these, so we have to do
// it manually (this is what sinon does under the hood). We do both in a loop
// until the thing we expect happens: hopefully this is the least flakey way
// and avoids assuming anything about the app's behaviour.
const realSetTimeout = setTimeout;
export function flushPromises() {
return new Promise(r => {
realSetTimeout(r, 1);
});
}
Loading