Compare commits

...
Author SHA1 Message Date
Valere b0503f41ef use latest lk-jwt-service for CI 2025-07-31 17:10:40 +02:00
fkwp d59e794bdf add alias to nginx 2025-07-31 17:05:57 +02:00
Valere b35fcf9076 DevX: update dev backend to support jwt-token v3 2025-07-31 17:05:57 +02:00
Valere Fedronic 029827488c Merge pull request #3430 from element-hq/valere/fix_snapshot
fix snapshot test following commit 007a50d
2025-07-31 17:04:51 +02:00
Valere 4ee67fa4e5 keep lk-jwt-service on 0.2.3 for now 2025-07-31 16:58:14 +02:00
Valere 446a2d4080 fix snapshot test following commit 007a50d 2025-07-31 16:37:09 +02:00
Valere 007a50d0f1 Fix missing button styling on error dialog 2025-07-31 15:00:21 +02:00
Timo c7b0f9783d expose delayed_leave_event_restart_local_timeout_ms to config.json (#3415) 2025-07-30 14:58:45 +02:00
Valere Fedronic 391ca63b7e Merge pull request #3422 from element-hq/valere/bump-js-sdk-28-07-2025
bump js-sdk version 28/07/2025
2025-07-28 17:59:56 +02:00
Valere 5dfa420135 bump js-sdk version 2025-07-28 17:45:38 +02:00
Robin ff3f727c80 Merge pull request #3418 from element-hq/robin/notification-capability
Request capability to send call notifications
2025-07-28 16:04:21 +02:00
Robin f7565ef104 Request capability to send call notifications
0e0fba6575 added the ability to send call notification events when starting a call, but I forgot to give the widget the right capabilities to do this. The effect was that notifications just wouldn't send in widget mode.
2025-07-24 18:50:03 +02:00
TimoandRobin 2f55d8e30c UrlParams: Intent system update, split into configuration and propreties (#3376)
* refactor UrlParams to use a preset intent system

* change defaults for intend headers

* add: getEnumParam to ParamParser

* remove deprecated url params

* only allow skip lobby in widget (more strict needs test adjustment)

* fix tests that now require the url to be a widget url

Co-authored-by: Robin <robin@robin.town>
---------

Co-authored-by: Robin <robin@robin.town>
2025-07-24 17:46:26 +02:00
Will Hunt 3145bafd5e Trim extra characters from roomId parameter in URL (#3412)
* Trim roomId when parsing from URL

* fix char

* fixup

* limit to roomId

* Add a comment
2025-07-22 20:11:53 +01:00
Robin 7dd45acd29 Update matrix-js-sdk
To include https://github.com/matrix-org/matrix-js-sdk/pull/4927.
2025-07-21 21:01:00 +02:00
Valere Fedronic 8f561c0319 bump js-sdk to matrix-js-sdk 0ce944f3daa2c8926c673af33ae24e89b1e6796a (#3414) 2025-07-21 17:46:45 +02:00
Robin 4104db3e7a Merge pull request #3411 from element-hq/renovate/major-compound
Update dependency @vector-im/compound-design-tokens to v5
2025-07-21 14:16:24 +02:00
Robin d530997725 Merge pull request #3410 from element-hq/renovate/compound
Update dependency @vector-im/compound-web to v8.2.0
2025-07-21 14:15:58 +02:00
renovate[bot] fb0fefae10 Update dependency @vector-im/compound-design-tokens to v5 2025-07-21 00:47:44 +00:00
renovate[bot] 8bb79e6f33 Update dependency @vector-im/compound-web to v8.2.0 2025-07-21 00:47:32 +00:00
RobinandTimo 0e0fba6575 Send notification events when starting a call (#3248)
* Send notification events when starting a call

Previously this has been the responsibility of the hosting application (Element Web / Element X), but I would like to move this responsibility to Element Call itself to make it even more lightweight to integrate Element Call into a widget-capable client.

* use RTCNotification event

* add url param

* bump to latest js-sdk

* remove everything decline related

* use notification type in url params

* fix url .md docs

* back to `head=develop` and using js-sdk with send notification feature

* format

---------

Co-authored-by: Timo <toger5@hotmail.de>
2025-07-18 16:58:50 +02:00
Timo 5ea0759427 Earpiece follow up: Change labels and icons (#3401)
* fix collapse icon on android

* update wording `earpiece` -> `headset`

* update icon `earpiece` -> `phone`

* i18n

* update icons to solid (top right) and non solid (overlay)

* update snapshots

* add config.json to gitignore

* add offset for earpice overlay

* update snapshots to include offset spacer
2025-07-18 15:19:53 +02:00
Valere Fedronic 7ac378037f Merge pull request #3408 from element-hq/valere/bump-js-sdk
Bump js-sdk resolved commit to the latest develop
2025-07-18 10:59:11 +02:00
Valere ff7a00ed3d Bump js-sdk resolved commit 2025-07-18 10:43:06 +02:00
Robin e4915b5bd3 Merge pull request #3346 from element-hq/robin/behaviors
Create a type-level distinction between raw Observables and Behaviors
2025-07-17 19:14:35 -04:00
renovate[bot] 38fc34667c Update LiveKit components (#3407)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-17 13:41:10 +02:00
renovate[bot] 6873ef8dd6 Update dependency livekit-client to v2.15.3 (#3406)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-17 13:40:36 +02:00
Timo 6f0ffa84dc Merge branch 'livekit' into robin/behaviors 2025-07-14 19:03:18 +02:00
Timo 8458d198c9 Fix bluetooth iOS issue (device auto switches from Bluetooth to speaker) (#3388)
* fix ios bluetooth

Signed-off-by: Timo K <toger5@hotmail.de>

* fix lints

Signed-off-by: Timo K <toger5@hotmail.de>

---------

Signed-off-by: Timo K <toger5@hotmail.de>
2025-07-14 12:53:09 +02:00
Robin c34516e871 Use the initialValue parameter of 'behavior' instead of startWith 2025-07-12 00:34:52 -04:00
Robin 2b76d3dd70 Move 'behavior' to be a method on ObservableScope 2025-07-12 00:34:52 -04:00
Robin 32bf1c30d2 Use Behaviors even more consistently 2025-07-11 23:53:59 -04:00
Robin 586a923be3 Fix remaining tests 2025-07-11 23:53:31 -04:00
Timo 434712ba17 fixing some tests 2025-07-11 00:27:46 -04:00
Robin b3863748dc Replace many usages of useObservableEagerState with useBehavior
This hook is simpler in its implementation (therefore hopefully more correct & performant) and enforces a type-level distinction between raw Observables and Behaviors.
2025-07-11 00:24:46 -04:00
Robin 35ed313577 Replace ObservableScope.state with Observable.behavior 2025-07-10 23:57:33 -04:00
Robin 7e81eca068 Create a Behavior type 2025-07-10 17:39:18 -04:00
Robin dbcc0e2c18 Merge pull request #3395 from element-hq/renovate/livekit-components
Update dependency @livekit/components-react to v2.9.13
2025-07-10 16:26:13 -04:00
Robin 3bdb71ee40 Merge pull request #3392 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v4.0.5
2025-07-10 16:23:19 -04:00
Valere Fedronic 2e23bbbb94 Merge pull request #3398 from element-hq/valere/enable_new_encryption_mgr
Bump js-sdk dependency to have new encryption mgr
2025-07-09 19:01:50 +02:00
Valere f0d753e58d Bump js-sdk dependency to have new encryption mgr 2025-07-09 18:47:33 +02:00
renovate[bot] aad59ea624 Update dependency livekit-client to v2.15.2 (#3396)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-09 12:46:20 +02:00
renovate[bot] 23ff26a988 Update dependency @livekit/components-react to v2.9.13 2025-07-09 10:39:41 +00:00
renovate[bot] 8c1e69f15a Update dependency @vector-im/compound-design-tokens to v4.0.5 2025-07-07 01:31:26 +00:00
renovate[bot] 01ede7629e Update all non-major dependencies (#3377)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-01 10:28:43 +02:00
renovate[bot] ff382ec283 Update embedded package dependencies (#3378)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-07-01 10:28:19 +02:00
Timo 31355ba7af Update earpiece overlay button text for clarity (#3370)
* Update earpiece overlay button text for clarity

* update test snapshots
2025-06-27 15:24:46 +02:00
renovate[bot] 1ac9630964 Update dependency livekit-client to v2.14.0 (#3371)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-27 14:14:51 +02:00
Timo db3477ea17 Increase opacity of the EarpieceOverlay background for better visibility (#3369) 2025-06-27 11:55:15 +02:00
Robin 30eea63aae Merge pull request #3337 from element-hq/robin/error-fixes
Touch up some error screens
2025-06-26 09:52:35 -04:00
fkwp 825b83dc03 reduce wait after network error timeout down to 100 ms (#3365) 2025-06-26 11:54:41 +02:00
RobinandTimo f509c06cc6 Earpiece switcher and overlay (#3347)
* Add a global control for toggling earpiece mode

This will be used by Element X to show an earpiece toggle button in the header.

* Add an earpiece overlay


* Fix header
The header needs to be passed forward as a string to some components and as a bool (hideHeader) to others.
Also use a enum instead of string options.

* fix top clipping with header


* hide app bar in pip

* revert android overlay app_bar

* Modernize AppBarContext

* Style header icon color as desired and switch earpice/speaker icon

* fix initial selection when using controlled media

* Add "Back to video" button

* fix tests

* remove dead code

* add snapshot test

* fix back to video button

* Request capability to learn the room name

We now need the room name in order to implement the mobile (widget-based) designs with the app bar.

* Test the CallViewModel output switcher directly

---------

Co-authored-by: Timo <toger5@hotmail.de>
2025-06-26 11:08:57 +02:00
Robin c012aec909 Merge pull request #3353 from element-hq/toger5/device-permissions-request-possible-fix
Skip unnecassary media devices permissions requests (video feed flicker when opening settings)
2025-06-25 15:56:10 -04:00
Timo d08a180c54 Simplify and improve locality of the device name request logic 2025-06-25 15:50:53 -04:00
Robin db948cb718 Merge pull request #3364 from element-hq/renovate/livekit-components
Update LiveKit components
2025-06-25 15:49:25 -04:00
Timo c03e2c4bde simple subject instead of derived observable 2025-06-25 15:47:56 -04:00
Timo e47a743f1e Also fix camera reloading in widget mode 2025-06-25 15:47:56 -04:00
Timo 73ccb38c11 comment 2025-06-25 15:47:56 -04:00
Timo ab4eadf58f Only rerequest permissions if we do not yet get labels when enumerating 2025-06-25 15:47:56 -04:00
renovate[bot] 93cb7955c9 Update LiveKit components 2025-06-25 18:41:41 +00:00
Robin 8f841dfb59 Merge pull request #3363 from element-hq/toger5/fix-initial-device-selection-in-controlled-devices-mode
Fix initial selection when using controlled media
2025-06-25 13:47:42 -04:00
Robin f4d590c703 Use consistent name for preferred device IDs 2025-06-25 13:42:31 -04:00
Robin f3419f94c3 Fix empty string IDs not counting as devices 2025-06-25 13:40:39 -04:00
Timo a53585c96d Fix white borders in PiP mode android (Fix scroll issues in small documents) (#3362)
* Fix scroll issues in small documents (PiP mode android)
This scroll issue resulted in white borders on android PiP mode.
2025-06-25 19:38:51 +02:00
Robin 3b1ce22b71 Fold map operation into combineLatest 2025-06-25 13:38:47 -04:00
Valere FedronicandRobin 9787ac3abc bugfix: #3344 Reconnecting to the same SFU on membership change (#3361)
* bugfix: #3344 Reconnecting to the same SFU on membership change

* fixup! commit error

* Keep useActiveLivekitFocus from changing focus spuriously

* Remove redundant fix for spurious focus changes

We've now fixed it at the source by prohibiting state changes in useActiveLivekitFocus itself.

---------

Co-authored-by: Robin <robin@robin.town>
2025-06-25 19:35:50 +02:00
Timo 131bdc3522 fix initial selection when using controlled media 2025-06-25 12:14:05 +02:00
Robin daa931c3c4 Merge pull request #3358 from element-hq/robin/remove-forward-ref
Remove usages of forwardRef
2025-06-24 08:32:03 -04:00
Robin 0f8c4675cf Make condition simpler 2025-06-24 08:28:15 -04:00
Timo 337d09cd4d Use the platform property for ios detection (#3360) 2025-06-24 14:25:05 +02:00
Timo 6b6b679774 Make camera unavailable if using earpice mode (#3351) 2025-06-24 08:59:16 +00:00
Robin 3ffb118dc7 Modernize how we use React contexts (#3359)
* Replace useContext with use

The docs recommend the use hook because it is simpler and allows itself to be called conditionally.

* Simplify our context providers

React 19 lets you omit the '.Provider' bit.
2025-06-24 10:48:35 +02:00
TimoandRobin a507bcde90 Add onBackButtonPressed controls api (#3357)
* Add `onBackButtonPressed` controls api

* Update docs/controls.md

Co-authored-by: Robin <robin@robin.town>

---------

Co-authored-by: Robin <robin@robin.town>
2025-06-24 08:46:04 +00:00
Robin 0c27610119 Remove usages of forwardRef
It has been deprecated in React 19, which allows functional components to receive refs just like any other prop.
2025-06-23 23:06:33 -04:00
Robin f86c9fe0a0 Merge pull request #3355 from element-hq/renovate/major-compound
Update dependency @vector-im/compound-web to v8
2025-06-23 22:10:07 -04:00
renovate[bot] 3ae535bf31 Update dependency @vector-im/compound-web to v8 2025-06-23 00:39:22 +00:00
RobinandTimo 5e2e94d794 Refactor media devices to live outside React as Observables (#3334)
* Refactor media devices to live outside React as Observables

This moves the media devices state out of React to further our transition to a MVVM architecture in which we can more easily model and store complex application state. I have created an AppViewModel to act as the overarching state holder for any future non-React state we end up creating, and the MediaDevices reside within this. We should move more application logic (including the CallViewModel itself) there in the future.

* Address review feedback

* Fixes from ios debugging session: (#3342)

- dont use preferred vs selected concept in controlled media. Its not needed since we dont use the id for actual browser media devices (the id's are not even actual browser media devices)
  - add more logging
  - add more conditions to not accidently set a deviceId that is not a browser deviceId but one provided via controlled.

---------

Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
2025-06-20 18:37:25 +02:00
renovate[bot] 5bf7361d01 Update dependency livekit-client to v2.13.8 (#3352)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-20 10:01:31 +02:00
renovate[bot] 0fe8d16740 Update dependency @livekit/components-react to v2.9.10 (#3349)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-19 16:42:15 +02:00
renovate[bot] f1a2002072 Update dependency livekit-client to v2.13.7 (#3350)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-19 16:40:28 +02:00
renovate[bot] 1af1a8ed0b Update dependency livekit-client to v2.13.6 (#3348)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-19 13:19:31 +02:00
renovate[bot] 0970db8297 Update dependency livekit-client to v2.13.5 (#3343)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-06-18 13:59:35 +02:00
Robin a36e72147c Hide error screen icon from accessibility technologies
It does not have any meaningful accessible label to contribute beyond what is already stated in the heading.
2025-06-16 16:48:13 -04:00
Robin 7f4a5a8bab Merge pull request #3338 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v4.0.4
2025-06-16 08:50:53 -04:00
renovate[bot] 442fc1fc16 Update dependency @vector-im/compound-design-tokens to v4.0.4 2025-06-16 01:46:00 +00:00
Robin 905177f0b6 Don't present internal error messages as if they are localized 2025-06-13 00:15:25 -04:00
Robin 31c35583fb Replace technical & unlocalized error message with "Connection lost" 2025-06-13 00:15:25 -04:00
Robin 764c6fce24 Fix missing text on "Call not found" screen 2025-06-12 23:54:40 -04:00
Robin 86aa459a84 Center the heading on the error screen 2025-06-12 23:47:33 -04:00
fkwp 32b6250cc3 fix: Force the docker image for lk-jwt-service to be pulled everytime (#3325)
lk-jwt-service latest-ci to be force pulled every time
2025-06-12 16:42:06 +02:00
Timo 4a6dbf350f bump js-sdk to latest develop (containing a fix for membership manager resend join event issue) (#3333)
Signed-off-by: Timo K <toger5@hotmail.de>
2025-06-12 16:28:00 +02:00
fkwp 29968a3eba Apply new timing constants to MatrixRTC session (#3332)
Apply new timing constants
2025-06-12 14:10:54 +02:00
fkwp aa092c2195 Merge pull request #3323 from element-hq/fkwp/dev_build
Add developer build mode to GitHub action build-element-call.yaml
2025-06-11 22:56:38 +02:00
fkwp 0bf5c4a835 simplify package.json scripts and remove NODE_ENV variables since we dont use them 2025-06-11 16:54:10 +02:00
fkwp 3d47609cff Since we are now using templating anyhow we can also combine full and embedded build into one step 2025-06-10 18:17:16 +02:00
Timo 1425de8726 Expose keep alive event configurarion in ec config and update defaults. (#3303) 2025-06-10 18:09:52 +02:00
fkwp c1aa1888f0 Merge pull request #3327 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.13.4
2025-06-10 16:12:11 +02:00
fkwp 58ebbfeed7 Merge pull request #3326 from element-hq/fkwp/doc_self-hosting_update
Add tools section to self-hosting guide and adding Matrixtester to it
2025-06-10 15:59:12 +02:00
Timo 02f3f1b71a Improvements to audio renderer codebase. (#3308)
* Improvements to audio renderer codebase.

* review
2025-06-10 13:00:21 +00:00
renovate[bot] f7a6e20ae4 Update dependency livekit-client to v2.13.4 2025-06-10 12:31:41 +00:00
fkwp 378d59e948 prettier 2025-06-10 14:27:15 +02:00
fkwp a07dbe645e tools section to self-hosting guide and adding Matrixtester to it 2025-06-10 14:24:59 +02:00
Timo a596eb71a9 add onAudioPlaybackStarted callback for controls (#3309)
* add onAudioTrackReady callback for controls

* more details in controls.md for `onAudioPlaybackStarted`
2025-06-10 12:35:04 +02:00
Robin c8a1cae18b Merge pull request #2874 from element-hq/renovate/major-react-monorepo
Update react monorepo to v19 (major)
2025-06-09 11:59:26 -04:00
Robin 4f1450aaf0 Replace react-use-clipboard with copy-to-clipboard
We didn't need the complexity of the (admittedly very small) React hook, and the package hasn't declared compatibility with React 19, so let's just switch to copying things manually via copy-to-clipboard.
2025-06-09 11:53:58 -04:00
Robin 8704b44b78 Update test snapshots for React 19 changes 2025-06-09 11:48:01 -04:00
Robin 0ee11af3c5 Upgrade react-spring to v10
For React 19 compatibility.
2025-06-09 11:47:47 -04:00
Andrew Ferrazzuttiandfkwp 13fac57b01 Build Docker image on slim base (#3204)
* Build Docker image on slim base

* Run Playwright tests against Docker container

For Playwright end-to-end tests in CI, instead of running a development
webserver with `yarn dev`, build and deploy a Docker container for
Element Call and use that as the webserver to test against.

* Shut down playwright webserver gracefully

When using a containerized webserver, this stops the container once
tests finish.

* Increase Playwright timeout in CI

---------

Co-authored-by: fkwp <github-fkwp@w4ve.de>
2025-06-06 12:04:57 -04:00
Robin e0ce58b2a2 Merge pull request #3320 from element-hq/revert-3319-revert-3313-misc/migrate-to-maven-central-portal
Upgrade Android publishing to use Maven Central Portal (again)
2025-06-06 10:18:20 -04:00
fkwp 6f9adfe3e8 fix: add misssing yarn 2025-06-06 00:21:23 +02:00
fkwp d47e579994 add build_mode also to build_embedded_element_call 2025-06-06 00:20:11 +02:00
fkwp 61d8f9a412 Merge branch 'livekit' into fkwp/dev_build 2025-06-06 00:14:45 +02:00
fkwp 31185ae365 make build_mode optional 2025-06-06 00:13:49 +02:00
fkwp e07c7c864b prettier 2025-06-06 00:02:19 +02:00
fkwp b88bce5220 add production and developt build scripts to package.json 2025-06-05 23:58:51 +02:00
fkwp 775e110ca3 Add build_mode to inputs of build_full_element_call. derive build_mode from PR label 'development build' 2025-06-05 23:58:24 +02:00
fkwp 97d548ee3a add build_mode input and use it in run commands 2025-06-05 23:51:02 +02:00
Timo 34724b7a8c revert "custom compare logic" 2025-06-05 14:39:06 +02:00
Timo b005f36ac7 custom compare logic 2025-06-05 14:36:43 +02:00
Robin b0587fcfb3 Avoid reactivity bugs in how we track external state (#3316)
* Avoid reactivity bugs in how we track external state

Many of our hooks which attempt to bridge external state from an EventEmitter or EventTarget into React had subtle bugs which could cause them to fail to react to certain updates. The conditions necessary for triggering these bugs are explained by the tests that I've included.

In the majority of cases, I don't think we were triggering these bugs in practice. They could've become problems if we refactored our components in certain ways. The one concrete case I'm aware of in which we actually triggered such a bug was the race condition with the useRoomEncryptionSystem shared secret logic (addressed by a1110af6d5).

But, particularly with all the weird reactivity issues we're debugging this week, I think we need to eliminate the possibility that any of the bugs in these hooks are the cause of our current headaches.

* Reuse useTypedEventEmitterState in useLocalStorage

* Fix type error
2025-06-05 13:54:57 +02:00
fkwp b8eccc6d7a use vite minify depending on vite mode 2025-06-05 12:16:22 +02:00
Jorge Martin Espinosa 34df584366 Revert "Revert "Upgrade Android publishing to use Maven Central Portal"" 2025-06-05 11:20:47 +02:00
Jorge Martin Espinosa a62b0be831 Merge pull request #3319 from element-hq/revert-3313-misc/migrate-to-maven-central-portal 2025-06-05 11:20:36 +02:00
Jorge Martin Espinosa 01240fb59d Revert "Upgrade Android publishing to use Maven Central Portal" 2025-06-05 11:10:03 +02:00
Robin 7851b9c289 Merge pull request #3318 from element-hq/robin/deep-compare
Use the same function for deep equality everywhere
2025-06-04 18:12:08 -04:00
Robin 15bcaef3a5 Use the same function for deep equality everywhere 2025-06-04 17:41:42 -04:00
Timo 3c831fc5e6 Fix react errors in settings tab (#3314)
* Fix react errors in settings tab

* review
2025-06-04 23:29:49 +02:00
Robin 26efbc1389 Merge pull request #3317 from element-hq/robin/reactive-members
Always render audio from the current set of participants
2025-06-04 17:25:29 -04:00
Robin 929367c9ce Always render audio from the current set of participants
We forgot to tell React that we need the audio renderer to react to changes in the set of MatrixRTC participants; instead we had it referencing rtcSession.memberships non-reactively.

Now, I'm not 100% confident that this is going to fix the "speaking from the void" issues observed in the wild, because I can't reproduce them and, in my testing, the InCallView component always seemed to be rendered redundantly when the MatrixRTC participants change, even though we hadn't explicitly stated that it needs to react. (This makes sense as we haven't memoized the component.) But it's worth a shot.
2025-06-04 17:21:48 -04:00
TimoandRobin 2f3e0b419d Leave issue refactor (#3302)
* Simplify key local storage management.

* Refactor useLivekit to only ever connect to one room.
This change also tries to make the code more explicit so that we only do the things we really need to do and rely less on react updating everything correctly.

It also surfaces, that we are currently implementing useLivekit in a way, so that we can change the encryption system on the fly and recreate the room. I am not sure this is a case we need to support?

* simplify the useLivekit hook even more
This is possible because we concluded that we do not need to be able to hot reload the e2ee system.

* review

* linter

* Update src/room/InCallView.tsx

Co-authored-by: Robin <robin@robin.town>

---------

Co-authored-by: Robin <robin@robin.town>
2025-06-04 20:51:13 +00:00
Robin ef41ef85eb Merge pull request #3311 from element-hq/robin/break-safari-loop
Break loop in acquiring media on Safari
2025-06-04 11:58:56 -04:00
Robin d9b91778b1 Merge pull request #3304 from element-hq/renovate/embedded-package-dependencies
Update embedded package dependencies
2025-06-04 11:56:52 -04:00
Robin 2f6bae5e5e Merge pull request #3313 from element-hq/misc/migrate-to-maven-central-portal
Upgrade Android publishing to use Maven Central Portal
2025-06-04 11:56:11 -04:00
Robin 40b351d76d Ignore spurious 'devicechange' events
This gives us the additional insurance of breaking the Safari media acquisition loop at the source by admitting that they can be spurious in practice. Safari, why!?
2025-06-04 11:23:20 -04:00
Jorge Martín 8bc914a70f Upgrade Android publishing to use Maven Central Portal
- Upgrade maven publishing plugin to `v0.32.0`.
- Change the `SonatypeHost` to point to `CENTRAL_PORTAL`.
2025-06-04 12:21:14 +02:00
Robin 83bfb721e7 Break loop in acquiring media on Safari 2025-06-03 17:22:20 -04:00
Robin 64e27152c6 Merge pull request #3307 from element-hq/renovate/livekit-components
Update dependency @livekit/components-react to v2.9.9
2025-06-03 09:40:48 -04:00
Robin f4a5ca9e84 Merge pull request #3306 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v4.0.3
2025-06-03 09:39:26 -04:00
renovate[bot] 789f37611b Update react monorepo to v19 2025-06-03 13:28:48 +00:00
Robin 931cc9ddd7 Merge pull request #3305 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2025-06-03 09:27:44 -04:00
Robin 65846dcf7d Revert eslint-plugin-matrix-org to 2.1.0
See 7eae5b0ffb.
2025-06-03 09:22:44 -04:00
renovate[bot] aa1b690b11 Update dependency @livekit/components-react to v2.9.9 2025-06-03 12:53:27 +00:00
renovate[bot] e5561dbd20 Update all non-major dependencies 2025-06-03 12:53:08 +00:00
renovate[bot] e68b403808 Update embedded package dependencies 2025-06-02 19:19:33 +00:00
renovate[bot] 85d91de2e7 Update dependency @vector-im/compound-design-tokens to v4.0.3 2025-06-02 01:32:10 +00:00
Robin 5f8a8d4c5b Merge pull request #3294 from element-hq/fkwp/docker_compose/resolve_conflicting_ports
Fix Playwright tests
2025-05-30 10:42:05 -04:00
Robin d2534748eb Merge pull request #3300 from element-hq/robin/synchronize-blocked
Run the 'Prevent blocked' check whenever a PR branch is updated
2025-05-30 10:26:10 -04:00
fkwp a548c5d592 test.skip() does only skip the test call back but not the fiturex. Hence, disabling the whole test 2025-05-30 15:03:43 +02:00
fkwp 08ab38280a prettier 2025-05-30 14:49:29 +02:00
fkwp a732fcc604 linting 2025-05-30 14:46:35 +02:00
fkwp 7e19b58976 define the widget test as a slow test 2025-05-30 14:29:17 +02:00
fkwp e56fb7cfc8 use .toBeVisible instead of continueButton.isVisible 2025-05-30 14:10:57 +02:00
fkwp aabfe16021 prettier 2025-05-30 13:51:55 +02:00
fkwp d572977922 refactor: splitout registerUser into its own function. Make the'Confirm your identity by entering your account password below.' flow optional 2025-05-30 13:38:45 +02:00
fkwp 6e0eee3509 Merge pull request #3283 from element-hq/fkwp/docker_compose_allow_local_lk_service
Add nginx upstream group of servers for JWT Service
2025-05-30 12:43:05 +02:00
Timo 87186058ab Only use ios platform logic when in controlled media device condition (#3295) 2025-05-30 12:03:22 +02:00
Robin fbafc9f3f6 Merge pull request #3301 from element-hq/renovate/npm-vite-vulnerability
Update dependency vite to v6.2.7 [SECURITY]
2025-05-28 18:20:30 -04:00
renovate[bot] 4f944ea72e Update dependency vite to v6.2.7 [SECURITY] 2025-05-28 22:14:42 +00:00
Robin 61d2da2259 Merge pull request #3036 from element-hq/renovate/major-compound
Update dependency @vector-im/compound-design-tokens to v4
2025-05-28 18:13:37 -04:00
Robin 0661486676 Merge branch 'livekit' into renovate/major-compound 2025-05-28 18:07:30 -04:00
Robin 07a4244c05 Upgrade Compound Web to v7.12.0 2025-05-28 18:04:29 -04:00
Robin 03f92ed6e4 Merge pull request #3172 from element-hq/renovate/livekit-components
Update LiveKit components
2025-05-28 17:43:07 -04:00
Robin 469ec63fec Fix LiveKit types import 2025-05-28 17:34:33 -04:00
Robin 50caca7bd3 Merge branch 'livekit' into renovate/livekit-components 2025-05-28 17:26:03 -04:00
Robin 81caa3321f Merge pull request #3186 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2025-05-28 17:22:38 -04:00
Robin 3c3fce96e7 Upgrade to OpenTelemetry v2 SDKs
Necessitated by our minor version upgrade of @opentelemetry/exporter-trace-otlp-http.
2025-05-28 17:17:31 -04:00
Robin e757f7af6b Run the 'Prevent blocked' check whenever a PR branch is updated
Because we're now requiring the 'Prevent blocked' check to pass before merging a PR, GitHub Actions now expects it to be associated with the latest Git ref of the PR's branch whenever the branch is updated. Therefore we need to re-run the workflow on the 'synchronize' event.
2025-05-28 17:00:57 -04:00
Robin 7eae5b0ffb Revert eslint-plugin-matrix-org to 2.1.0
Because the latest version requires eslint-plugin-unicorn v57, which requires eslint v9, and eslint-plugin-matrix-org is not yet compatible with eslint v9.
2025-05-28 16:25:21 -04:00
renovate[bot] d82b91ad4a Update all non-major dependencies 2025-05-28 07:09:25 +00:00
renovate[bot] 82b41ae86c Update LiveKit components 2025-05-28 07:08:55 +00:00
Timo 68396f8a83 Merge pull request #3293 from element-hq/toger5/more-disconnect-logging
Fix creating two lk rooms if there is no local store setup (fixes a resulting disconnect bug)
2025-05-28 09:01:00 +02:00
fkwp ebc714b73f force to pull the latest docker images 2025-05-27 20:06:28 +02:00
fkwp e4fd630f37 fix element web fixture 2025-05-27 19:03:53 +02:00
Timo a52b723414 code styling 2025-05-27 18:17:41 +02:00
fkwp 99fc7162e2 fix widget fixture 2025-05-27 18:04:34 +02:00
fkwp 8953936d3d fix docker compose playwright override 2025-05-27 17:53:06 +02:00
Timo a1110af6d5 Fix the actual leaving issue 2025-05-27 17:38:54 +02:00
Timo b8951944ab start with a couple of more logs 2025-05-27 17:38:45 +02:00
fkwp 16aa4ae3a9 Merge branch 'fkwp/docker_compose/resolve_conflicting_ports' into fkwp/docker_compose_allow_local_lk_service 2025-05-27 16:40:28 +02:00
fkwp d585f6232e change JWT port ot 6080 to not conflict with the playwright tests. 2025-05-27 16:30:06 +02:00
Timo b1ca464c58 Merge pull request #3292 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.13.1
2025-05-26 12:42:32 +02:00
renovate[bot] 0b8e7e9cae Update dependency livekit-client to v2.13.1 2025-05-26 03:06:25 +00:00
TimoandRobin 5374342d98 Disable device switching when in controlled audio devices mode (#3290)
* Disable device switching when in controlled audio devices mode

* Temporarily switch matrix-js-sdk to robin/embedded-no-update-state

To allow us to test this change on Element X, which does not yet support the update_state action.

* Also add a check for controlled audio devices in useAudioContext

* use develop branch

* fix tests

---------

Co-authored-by: Robin <robin@robin.town>
2025-05-23 15:54:47 +00:00
Robin 0971a15c40 Merge pull request #3270 from element-hq/robin/audio-output-controls
Audio device controls for mobile native audio device selection
2025-05-22 14:09:04 -04:00
Robin 78c59bb41c Fix formatting 2025-05-22 14:03:33 -04:00
Robin 045d861ad1 Merge branch 'livekit' into robin/audio-output-controls 2025-05-22 14:00:19 -04:00
TimoandRobin 269565d317 Update docs/url-params.md
Co-authored-by: Robin <robin@robin.town>
2025-05-22 19:28:20 +02:00
Timo f0403c80bc also add non deprecated audio url parameter 2025-05-22 19:18:04 +02:00
Robin a21da9417c Merge pull request #3285 from element-hq/robin/reset-develop
Reset to develop branch of matrix-js-sdk
2025-05-22 13:10:56 -04:00
TimoandRobin fa0b5210fe Update docs/controls.md
Co-authored-by: Robin <robin@robin.town>
2025-05-22 19:07:47 +02:00
Timo 9f84a5cae0 Deprecate old naming and introduce new words 2025-05-22 18:58:18 +02:00
Timo 4eb867436a Merge branch 'livekit' into robin/audio-output-controls 2025-05-22 14:10:03 +02:00
Timo 323e088378 use js-sdk branch as in livekit branch 2025-05-22 14:08:35 +02:00
Timo ab9dfc75f0 Comment to explain the usage/impact of: controlledMediaDevices 2025-05-22 13:04:42 +02:00
fkwp b969857583 Allow the jwt service to be running locallay rather than part of the docker-compose. This helps with developing the lk-jwt-service 2025-05-22 12:49:37 +02:00
Timo a056a28423 review 2025-05-21 12:53:17 +02:00
Timo 435a7d0adb earpice -> earpiece 2025-05-20 16:37:14 +02:00
Timo a1759a46de rename everything to controlledMediaDevices to make it consistent with the actual name in the url parameters (controlledOutput is now only used for the hook that provides the output handle) 2025-05-20 15:30:02 +02:00
Timo 1cf11b91c1 Back to translated button 2025-05-20 10:17:25 +02:00
Timo 0412629871 fix start with for output devices. 2025-05-20 10:14:08 +02:00
Timo c11a37ca61 back to non translated label 2025-05-19 20:01:59 +02:00
Timo fb95ba278e make the button prettty again 2025-05-19 19:59:35 +02:00
Timo aa00a951b6 ITS A FORM NOOOOO 2025-05-19 19:56:12 +02:00
Timo 7fd7dc3794 use normal button 2025-05-19 19:52:08 +02:00
Timo ed234a1ad1 change label on button 2025-05-19 19:44:19 +02:00
Timo d7e0abc55c remove the whole button on click logic 2025-05-19 19:26:50 +02:00
Timo e8c6d79a89 logger instead of native window picker 2025-05-19 19:20:26 +02:00
Timo d94feaa8db smaller diff 2025-05-19 19:08:39 +02:00
Timo 6d0697cf2f inform ios about earpice mode 2025-05-19 18:44:48 +02:00
Timo 5d6ec19ca0 Allow some controls to be set before the call view is loaded. 2025-05-19 14:14:08 +02:00
Timo 956b7fc480 actually test the impl 2025-05-19 13:42:13 +02:00
Timo 2946b307c2 fix no audio thinko. 2025-05-19 13:35:21 +02:00
Timo c22e0cb7e2 better logging 2025-05-19 13:03:16 +02:00
Timo 01a2cd1410 bump livekit client (the current version has an issue on safari) 2025-05-16 19:12:18 +02:00
Timo 7f4b0a33f6 isBluetooth -> isExternalHeadset 2025-05-16 17:06:54 +02:00
Timo 35963bbc9e Add flags to optimize EC device handling 2025-05-16 15:50:19 +02:00
Timo abf683f275 Hide the input list on both, android+ios.
This will now be decided based on controlled media devices.
2025-05-16 15:23:44 +02:00
Timo acaf69ca1b add change audio button with callback on ios 2025-05-16 12:28:49 +02:00
Timo 7a4c189249 test for mute all audio 2025-05-16 11:56:07 +02:00
Timo 7227c7b368 Merge branch 'livekit' into robin/audio-output-controls 2025-05-16 11:36:33 +02:00
Timo 2012b09845 review cleanup 2025-05-16 11:32:32 +02:00
Timo abd66f50db fix mute all audio via controls 2025-05-15 20:21:43 +02:00
Timo 610e792394 rename setOutputDevices-> setAvailableOutputDevices 2025-05-15 17:20:12 +02:00
Timo 7fa534d70d refactor
- `MediaDevice`->`MediaDeviceHandle`
 - use just one provider and switch inside the
 MediaDevicesProvider between: controlledAudioOutput, webViewAudioOutput
 - fix muteAllAudio
2025-05-15 15:34:35 +02:00
Timo c8091ac111 Quickfix for testing 2025-05-15 11:37:01 +02:00
Timo 86beaeb20f apply mute from mobile controls 2025-05-14 20:09:39 +02:00
Timo 6b39d0a5fd turn on url flag by default 2025-05-14 19:58:34 +02:00
Timo f69c75322f add earpice mode 2025-05-14 19:55:08 +02:00
Timo f9b04ae38e temp 2025-05-14 19:07:36 +02:00
Robin 53adfa4497 WIP 2025-05-14 19:07:36 +02:00
Timo 18a59dd7db use optional audio context and effect to initiate it + review 2025-05-14 17:23:42 +02:00
Timo 6b8c620bbb Add tests 2025-05-14 10:59:23 +02:00
Timo 56328108ca Add custom audio renderer to only render joined participants & add ios earpice workaround
fix left right to match chromium + safari
(firefox is swapped)

earpice as setting

Simpler code and documentation
The doc explains, what this class actually does and why it is so complicated.

Signed-off-by: Timo K <toger5@hotmail.de>

use only one audioContext, remove (non working) standby fallback
2025-05-14 10:41:03 +02:00
renovate[bot] f78b8dd153 Update dependency @vector-im/compound-design-tokens to v4 2025-03-27 18:22:52 +00:00
136 changed files with 7734 additions and 4908 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ module.exports = {
], ],
// To encourage good usage of RxJS: // To encourage good usage of RxJS:
"rxjs/no-exposed-subjects": "error", "rxjs/no-exposed-subjects": "error",
"rxjs/finnish": "error", "rxjs/finnish": ["error", { names: { "^this$": false } }],
}, },
settings: { settings: {
react: { react: {
+1 -1
View File
@@ -1,7 +1,7 @@
name: Prevent blocked name: Prevent blocked
on: on:
pull_request_target: pull_request_target:
types: [opened, labeled, unlabeled] types: [opened, labeled, unlabeled, synchronize]
jobs: jobs:
prevent-blocked: prevent-blocked:
name: Prevent blocked name: Prevent blocked
+7 -14
View File
@@ -9,6 +9,11 @@ on:
type: string # This would ideally be a `choice` type, but that isn't supported yet type: string # This would ideally be a `choice` type, but that isn't supported yet
description: The package type to be built. Must be one of 'full' or 'embedded' description: The package type to be built. Must be one of 'full' or 'embedded'
required: true required: true
build_mode:
type: string # This would ideally be a `choice` type, but that isn't supported yet
description: The build mode for vite. Must be either 'development' or 'production'
required: false
default: production
secrets: secrets:
SENTRY_ORG: SENTRY_ORG:
required: true required: true
@@ -37,20 +42,8 @@ jobs:
node-version-file: ".node-version" node-version-file: ".node-version"
- name: Install dependencies - name: Install dependencies
run: "yarn install --immutable" run: "yarn install --immutable"
- name: Build full version - name: Build Element Call
if: ${{ inputs.package == 'full' }} run: ${{ format('yarn run build:{0}:{1}', inputs.package, inputs.build_mode) }}
run: "yarn run build:full"
env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
VITE_APP_VERSION: ${{ inputs.vite_app_version }}
NODE_OPTIONS: "--max-old-space-size=4096"
- name: Build embedded
if: ${{ inputs.package == 'embedded' }}
run: "yarn run build:embedded"
env: env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
+2
View File
@@ -14,6 +14,7 @@ jobs:
with: with:
package: full package: full
vite_app_version: ${{ github.event.release.tag_name || github.sha }} vite_app_version: ${{ github.event.release.tag_name || github.sha }}
build_mode: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'development build') && 'development' || 'production' }}
secrets: secrets:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
@@ -61,6 +62,7 @@ jobs:
with: with:
package: embedded package: embedded
vite_app_version: ${{ github.event.release.tag_name || github.sha }} vite_app_version: ${{ github.event.release.tag_name || github.sha }}
build_mode: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'development build') && 'development' || 'production' }}
secrets: secrets:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
+5 -4
View File
@@ -30,7 +30,7 @@ jobs:
fail_ci_if_error: true fail_ci_if_error: true
playwright: playwright:
name: Run end-to-end tests name: Run end-to-end tests
timeout-minutes: 10 timeout-minutes: 30
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
@@ -46,11 +46,12 @@ jobs:
run: yarn playwright install --with-deps run: yarn playwright install --with-deps
- name: Run backend components - name: Run backend components
run: | run: |
docker compose -f playwright-backend-docker-compose.yml up -d docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml pull
docker compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml up -d
docker ps docker ps
- name: Copy config file
run: cp config/config.devenv.json public/config.json
- name: Run Playwright tests - name: Run Playwright tests
env:
USE_DOCKER: 1
run: yarn playwright test run: yarn playwright test
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: ${{ !cancelled() }} if: ${{ !cancelled() }}
+1
View File
@@ -9,6 +9,7 @@ dist-ssr
public/config.json public/config.json
backend/synapse_tmp/* backend/synapse_tmp/*
/coverage /coverage
config.json
# Yarn # Yarn
yarn-error.log yarn-error.log
+1 -1
View File
@@ -6,7 +6,7 @@ COPY ./dist /dist
WORKDIR /dist/assets WORKDIR /dist/assets
RUN gzip -k ../index.html *.js *.map *.css *.wasm *-app-*.json RUN gzip -k ../index.html *.js *.map *.css *.wasm *-app-*.json
FROM nginxinc/nginx-unprivileged:alpine FROM nginxinc/nginx-unprivileged:alpine-slim
COPY --from=builder ./dist /app COPY --from=builder ./dist /app
+2
View File
@@ -21,3 +21,5 @@ turn:
external_tls: true external_tls: true
keys: keys:
devkey: secret devkey: secret
room:
auto_create: false
+8 -2
View File
@@ -43,6 +43,11 @@ server {
# MatrixRTC reverse proxy # MatrixRTC reverse proxy
# - MatrixRTC Authorization Service # - MatrixRTC Authorization Service
# - LiveKit SFU websocket signaling connection # - LiveKit SFU websocket signaling connection
upstream jwt-auth-services {
server auth-server:6080;
server host.docker.internal:6080;
}
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
@@ -62,8 +67,9 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
# JWT Service running at port 8080 # JWT Service running at port 6080
proxy_pass http://auth-server:8080/; proxy_pass http://jwt-auth-services/;
} }
location ^~ /livekit/sfu/ { location ^~ /livekit/sfu/ {
+8 -1
View File
@@ -8,5 +8,12 @@
"features": { "features": {
"feature_use_device_session_member_events": true "feature_use_device_session_member_events": true
}, },
"ssla": "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf" "ssla": "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
"matrix_rtc_session": {
"wait_for_key_rotation_ms": 3000,
"membership_event_expiry_ms": 180000000,
"delayed_leave_event_delay_ms": 18000,
"delayed_leave_event_restart_ms": 4000,
"network_error_retry_ms": 100
}
} }
+8 -1
View File
@@ -11,5 +11,12 @@
"features": { "features": {
"feature_use_device_session_member_events": true "feature_use_device_session_member_events": true
}, },
"ssla": "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf" "ssla": "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
"matrix_rtc_session": {
"wait_for_key_rotation_ms": 3000,
"membership_event_expiry_ms": 180000000,
"delayed_leave_event_delay_ms": 18000,
"delayed_leave_event_restart_ms": 4000,
"network_error_retry_ms": 100
}
} }
+8
View File
@@ -5,6 +5,14 @@
"server_name": "call-unstable.ems.host" "server_name": "call-unstable.ems.host"
} }
}, },
"ssla": "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
"matrix_rtc_session": {
"wait_for_key_rotation_ms": 3000,
"membership_event_expiry_ms": 180000000,
"delayed_leave_event_delay_ms": 18000,
"delayed_leave_event_restart_ms": 4000,
"network_error_retry_ms": 100
},
"posthog": { "posthog": {
"api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU", "api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU",
"api_host": "https://posthog-element-call.element.io" "api_host": "https://posthog-element-call.element.io"
+7 -3
View File
@@ -4,21 +4,23 @@ networks:
services: services:
auth-service: auth-service:
image: ghcr.io/element-hq/lk-jwt-service:latest-ci image: ghcr.io/element-hq/lk-jwt-service:latest-ci
pull_policy: always
hostname: auth-server hostname: auth-server
environment: environment:
- LIVEKIT_JWT_PORT=8080 - LIVEKIT_JWT_PORT=6080
- LIVEKIT_URL=wss://matrix-rtc.m.localhost/livekit/sfu - LIVEKIT_URL=wss://matrix-rtc.m.localhost/livekit/sfu
- LIVEKIT_KEY=devkey - LIVEKIT_KEY=devkey
- LIVEKIT_SECRET=secret - LIVEKIT_SECRET=secret
# If the configured homeserver runs on localhost, it'll probably be using # If the configured homeserver runs on localhost, it'll probably be using
# a self-signed certificate # a self-signed certificate
- LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING - LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING
- LIVEKIT_FULL_ACCESS_HOMESERVERS=*
deploy: deploy:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
ports: ports:
# HOST_PORT:CONTAINER_PORT # HOST_PORT:CONTAINER_PORT
- 8080:8080 - 6080:6080
networks: networks:
- ecbackend - ecbackend
@@ -100,4 +102,6 @@ services:
depends_on: depends_on:
- synapse - synapse
networks: networks:
- ecbackend ecbackend:
aliases:
- matrix-rtc.m.localhost
+25 -1
View File
@@ -1,7 +1,31 @@
# Global JS controls # Global JS controls
A few aspects of Element Call's interface can be controlled through a global API on the `window`: A few aspects of Element Call's interface can be controlled through a global API on the `window`.
## Picture-in-picture
- `controls.canEnterPip(): boolean` Determines whether it's possible to enter picture-in-picture mode. - `controls.canEnterPip(): boolean` Determines whether it's possible to enter picture-in-picture mode.
- `controls.enablePip(): void` Puts the call interface into picture-in-picture mode. Throws if not in a call. - `controls.enablePip(): void` Puts the call interface into picture-in-picture mode. Throws if not in a call.
- `controls.disablePip(): void` Takes the call interface out of picture-in-picture mode, restoring it to its natural display mode. Throws if not in a call. - `controls.disablePip(): void` Takes the call interface out of picture-in-picture mode, restoring it to its natural display mode. Throws if not in a call.
## Audio devices
On mobile platforms (iOS, Android), web views do not reliably support selecting audio output devices such as the main speaker, earpiece, or headset. To address this limitation, the following functions allow the hosting application (e.g., Element Web, Element X) to manage audio devices via exposed JavaScript interfaces. These functions must be enabled using the URL parameter `controlledAudioDevices` to take effect.
- `controls.setAvailableAudioDevices(devices: { id: string, name: string, forEarpiece?: boolean, isEarpiece?: boolean isSpeaker?: boolean, isExternalHeadset?, boolean; }[]): void` Sets the list of available audio outputs. `forEarpiece` is used on iOS only.
It flags the device that should be used if the user selects earpiece mode. This should be the main stereo loudspeaker of the device.
- `controls.onAudioDeviceSelect: ((id: string) => void) | undefined` Callback called whenever the user or application selects a new audio output.
- `controls.setAudioDevice(id: string): void` Sets the selected audio device in Element Call's menu. This should be used if the OS decides to automatically switch to Bluetooth, for example.
- `controls.setAudioEnabled(enabled: boolean)` Enables/disables all audio output from the application. Output is enabled by default.
- `controls.onAudioPlaybackStarted: ((id: string) => void) | undefined`: This will be called the first time we start
playing audio in the webview. It can be helpful to do device setup on the native app when the webviews audio is ready.
In particular android is using it to setup the output channel so that the call volume can
be controlled by the hardware volume rocker.
## Element Call button delegation
Callbacks for buttons in EC that are handled by the native application
- `showNativeAudioDevicePicker: (() => void) | undefined`. Callback called whenever the user presses the output button in the settings menu.
This button is only shown on iOS. (`/iPad|iPhone|iPod|Mac/.test(navigator.userAgent)`)
- `onBackButtonPressed: (() => void) | undefined`. Callback when the webview detects a tab on the header's back button.
+5 -1
View File
@@ -255,13 +255,17 @@ self-hosters and developers working with Element Call.
- [How to resolve stuck MatrixRTC calls](https://sspaeth.de/2025/02/how-to-resolve-stuck-matrixrtc-calls/) - [How to resolve stuck MatrixRTC calls](https://sspaeth.de/2025/02/how-to-resolve-stuck-matrixrtc-calls/)
## 🛠️ How-Tos & Tutorials ## 📝 How-Tos & Tutorials
- [MatrixRTC aka Element-call setup (Geek warning)](https://sspaeth.de/2024/11/sfu/) - [MatrixRTC aka Element-call setup (Geek warning)](https://sspaeth.de/2024/11/sfu/)
- [MatrixRTC with Synology Container Manager (Docker)](https://ztfr.de/matrixrtc-with-synology-container-manager-docker/) - [MatrixRTC with Synology Container Manager (Docker)](https://ztfr.de/matrixrtc-with-synology-container-manager-docker/)
- [Encrypted & Scalable Video Calls: How to deploy an Element Call backend with Synapse Using Docker-Compose](https://willlewis.co.uk/blog/posts/deploy-element-call-backend-with-synapse-and-docker-compose/) - [Encrypted & Scalable Video Calls: How to deploy an Element Call backend with Synapse Using Docker-Compose](https://willlewis.co.uk/blog/posts/deploy-element-call-backend-with-synapse-and-docker-compose/)
- [Element Call einrichten: Verschlüsselte Videoanrufe mit Element X und Matrix Synapse](https://www.cleveradmin.de/blog/2025/04/matrixrtc-element-call-backend-einrichten/) - [Element Call einrichten: Verschlüsselte Videoanrufe mit Element X und Matrix Synapse](https://www.cleveradmin.de/blog/2025/04/matrixrtc-element-call-backend-einrichten/)
## 🛠️ Tools
- [A Matrix server sanity tester including tests for proper MatrixRTC setup](https://codeberg.org/spaetz/testmatrix)
## 🤝 Want to Contribute? ## 🤝 Want to Contribute?
Have a guide or blog post you'd like to share? Open a Have a guide or blog post you'd like to share? Open a
+3 -1
View File
@@ -56,18 +56,20 @@ These parameters are relevant to both [widget](./embedded-standalone.md) and [st
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. | | `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
| `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. | | `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. |
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. | | `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
| `hideHeader` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the room header when in a call. | | `header` | `none`, `standard` or `app_bar` | No, defaults to `standard` | No, defaults to `standard` | The style of headers to show. `standard` is the default arrangement, `none` hides the header entirely, and `app_bar` produces a header with a back button like you might see in mobile apps. The callback for the back button is `window.controls.onBackButtonPressed`. |
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. | | `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. | | `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
| `intent` | `start_call` or `join_existing` | No, defaults to `start_call` | No, defaults to `start_call` | The intent of the user with respect to the call. e.g. if they clicked a Start Call button, this would be `start_call`. If it was a Join Call button, it would be `join_existing`. | | `intent` | `start_call` or `join_existing` | No, defaults to `start_call` | No, defaults to `start_call` | The intent of the user with respect to the call. e.g. if they clicked a Start Call button, this would be `start_call`. If it was a Join Call button, it would be `join_existing`. |
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. | | `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) | | `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
| `perParticipantE2EE` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Enables per participant encryption with Keys exchanged over encrypted matrix room messages. | | `perParticipantE2EE` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Enables per participant encryption with Keys exchanged over encrypted matrix room messages. |
| `controlledAudioDevices` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the [global JS controls for audio devices](./controls.md#audio-devices) should be enabled, allowing the list of audio devices to be controlled by the app hosting Element Call. |
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. | | `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. | | `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) | | `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. | | `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. | | `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
### Widget-only parameters ### Widget-only parameters
+2 -2
View File
@@ -2,11 +2,11 @@
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format # https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
[versions] [versions]
android_gradle_plugin = "8.10.0" android_gradle_plugin = "8.11.0"
[libraries] [libraries]
android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "android_gradle_plugin" } android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "android_gradle_plugin" }
[plugins] [plugins]
android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" } android_library = { id = "com.android.library", version.ref = "android_gradle_plugin" }
maven_publish = { id = "com.vanniktech.maven.publish", version = "0.31.0" } maven_publish = { id = "com.vanniktech.maven.publish", version = "0.33.0" }
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-all.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
+1 -1
View File
@@ -27,7 +27,7 @@ android {
} }
mavenPublishing { mavenPublishing {
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true) publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications() signAllPublications()
+1 -1
View File
@@ -175,7 +175,7 @@
"camera_numbered": "Kamera {{n}}", "camera_numbered": "Kamera {{n}}",
"default": "Standard", "default": "Standard",
"default_named": "Standard<2> ({{name}} )</2>", "default_named": "Standard<2> ({{name}} )</2>",
"earpiece": "Ohrhörer", "handset": "Ohrhörer",
"microphone": "Mikrofon", "microphone": "Mikrofon",
"microphone_numbered": "Mikrofon{{n}}", "microphone_numbered": "Mikrofon{{n}}",
"speaker": "Lautsprecher", "speaker": "Lautsprecher",
+9 -2
View File
@@ -82,7 +82,7 @@
"error": { "error": {
"call_is_not_supported": "Call is not supported", "call_is_not_supported": "Call is not supported",
"call_not_found": "Call not found", "call_not_found": "Call not found",
"call_not_found_description": "<0>That link doesn't appear to belong to any existing call. Check that you have the right link, or <1>create a new one</1>.</0>", "call_not_found_description": "<0>That link doesn't appear to belong to any existing call. Check that you have the right link, or <2>create a new one</2>.</0>",
"connection_lost": "Connection lost", "connection_lost": "Connection lost",
"connection_lost_description": "You were disconnected from the call.", "connection_lost_description": "You were disconnected from the call.",
"e2ee_unsupported": "Incompatible browser", "e2ee_unsupported": "Incompatible browser",
@@ -105,6 +105,11 @@
"knock_reject_heading": "Access denied", "knock_reject_heading": "Access denied",
"reason": "Reason: {{reason}}" "reason": "Reason: {{reason}}"
}, },
"handset": {
"overlay_back_button": "Back to Speaker Mode",
"overlay_description": "Only works while using app",
"overlay_title": "Handset Mode"
},
"hangup_button_label": "End call", "hangup_button_label": "End call",
"header_label": "Element Call Home", "header_label": "Element Call Home",
"header_participants_label": "Participants", "header_participants_label": "Participants",
@@ -173,9 +178,11 @@
"devices": { "devices": {
"camera": "Camera", "camera": "Camera",
"camera_numbered": "Camera {{n}}", "camera_numbered": "Camera {{n}}",
"change_device_button": "Change audio device",
"default": "Default", "default": "Default",
"default_named": "Default <2>({{name}})</2>", "default_named": "Default <2>({{name}})</2>",
"earpiece": "Earpiece", "handset": "Handset",
"loudspeaker": "Loudspeaker",
"microphone": "Microphone", "microphone": "Microphone",
"microphone_numbered": "Microphone {{n}}", "microphone_numbered": "Microphone {{n}}",
"speaker": "Speaker", "speaker": "Speaker",
+21 -16
View File
@@ -8,7 +8,11 @@
"dev:embedded": "vite --config vite-embedded.config.js", "dev:embedded": "vite --config vite-embedded.config.js",
"build": "yarn build:full", "build": "yarn build:full",
"build:full": "NODE_OPTIONS=--max-old-space-size=16384 vite build", "build:full": "NODE_OPTIONS=--max-old-space-size=16384 vite build",
"build:full:production": "yarn build:full",
"build:full:development": "yarn build:full --mode development",
"build:embedded": "yarn build:full --config vite-embedded.config.js", "build:embedded": "yarn build:full --config vite-embedded.config.js",
"build:embedded:production": "yarn build:embedded",
"build:embedded:development": "yarn build:embedded --mode development",
"serve": "vite preview", "serve": "vite preview",
"prettier:check": "prettier -c .", "prettier:check": "prettier -c .",
"prettier:format": "prettier -w .", "prettier:format": "prettier -w .",
@@ -22,6 +26,7 @@
"test": "vitest", "test": "vitest",
"test:coverage": "vitest --coverage", "test:coverage": "vitest --coverage",
"backend": "docker-compose -f dev-backend-docker-compose.yml up", "backend": "docker-compose -f dev-backend-docker-compose.yml up",
"backend-playwright": "docker-compose -f playwright-backend-docker-compose.yml -f playwright-backend-docker-compose.override.yml up",
"test:playwright": "playwright test", "test:playwright": "playwright test",
"test:playwright:open": "yarn test:playwright --ui", "test:playwright:open": "yarn test:playwright --ui",
"links:enable": "mv .links.disabled.yaml .links.yaml & touch .links.yaml", "links:enable": "mv .links.disabled.yaml .links.yaml & touch .links.yaml",
@@ -43,17 +48,17 @@
"@livekit/track-processors": "^0.5.5", "@livekit/track-processors": "^0.5.5",
"@mediapipe/tasks-vision": "^0.10.18", "@mediapipe/tasks-vision": "^0.10.18",
"@opentelemetry/api": "^1.4.0", "@opentelemetry/api": "^1.4.0",
"@opentelemetry/core": "^1.25.1", "@opentelemetry/core": "^2.0.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.57.0", "@opentelemetry/exporter-trace-otlp-http": "^0.202.0",
"@opentelemetry/resources": "^1.25.1", "@opentelemetry/resources": "^2.0.0",
"@opentelemetry/sdk-trace-base": "^1.25.1", "@opentelemetry/sdk-trace-base": "^2.0.0",
"@opentelemetry/sdk-trace-web": "^1.9.1", "@opentelemetry/sdk-trace-web": "^2.0.0",
"@opentelemetry/semantic-conventions": "^1.25.1", "@opentelemetry/semantic-conventions": "^1.25.1",
"@playwright/test": "^1.52.0", "@playwright/test": "^1.52.0",
"@radix-ui/react-dialog": "^1.0.4", "@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-slider": "^1.1.2", "@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-visually-hidden": "^1.0.3", "@radix-ui/react-visually-hidden": "^1.0.3",
"@react-spring/web": "^9.4.4", "@react-spring/web": "^10.0.0",
"@sentry/react": "^8.0.0", "@sentry/react": "^8.0.0",
"@sentry/vite-plugin": "^3.0.0", "@sentry/vite-plugin": "^3.0.0",
"@stylistic/eslint-plugin": "^3.0.0", "@stylistic/eslint-plugin": "^3.0.0",
@@ -69,26 +74,27 @@
"@types/node": "^22.0.0", "@types/node": "^22.0.0",
"@types/pako": "^2.0.3", "@types/pako": "^2.0.3",
"@types/qrcode": "^1.5.5", "@types/qrcode": "^1.5.5",
"@types/react": "^18.3.0", "@types/react": "^19.0.0",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^19.0.0",
"@types/sdp-transform": "^2.4.5", "@types/sdp-transform": "^2.4.5",
"@types/uuid": "10", "@types/uuid": "10",
"@typescript-eslint/eslint-plugin": "^8.31.0", "@typescript-eslint/eslint-plugin": "^8.31.0",
"@typescript-eslint/parser": "^8.31.0", "@typescript-eslint/parser": "^8.31.0",
"@use-gesture/react": "^10.2.11", "@use-gesture/react": "^10.2.11",
"@vector-im/compound-design-tokens": "^3.0.0", "@vector-im/compound-design-tokens": "^5.0.0",
"@vector-im/compound-web": "^7.2.0", "@vector-im/compound-web": "^8.0.0",
"@vitejs/plugin-react": "^4.0.1", "@vitejs/plugin-react": "^4.0.1",
"@vitest/coverage-v8": "^3.0.0", "@vitest/coverage-v8": "^3.0.0",
"babel-plugin-transform-vite-meta-env": "^1.0.3", "babel-plugin-transform-vite-meta-env": "^1.0.3",
"classnames": "^2.3.1", "classnames": "^2.3.1",
"copy-to-clipboard": "^3.3.3",
"eslint": "^8.14.0", "eslint": "^8.14.0",
"eslint-config-google": "^0.14.0", "eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.0.0", "eslint-config-prettier": "^10.0.0",
"eslint-plugin-deprecate": "^0.8.2", "eslint-plugin-deprecate": "^0.8.2",
"eslint-plugin-import": "^2.26.0", "eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-matrix-org": "^2.0.0", "eslint-plugin-matrix-org": "2.1.0",
"eslint-plugin-react": "^7.29.4", "eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^5.0.0", "eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-rxjs": "^5.0.3", "eslint-plugin-rxjs": "^5.0.3",
@@ -99,7 +105,7 @@
"i18next-parser": "^9.1.0", "i18next-parser": "^9.1.0",
"jsdom": "^26.0.0", "jsdom": "^26.0.0",
"knip": "^5.27.2", "knip": "^5.27.2",
"livekit-client": "^2.11.3", "livekit-client": "^2.13.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"loglevel": "^1.9.1", "loglevel": "^1.9.1",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#head=develop", "matrix-js-sdk": "github:matrix-org/matrix-js-sdk#head=develop",
@@ -112,11 +118,10 @@
"posthog-js": "1.160.3", "posthog-js": "1.160.3",
"prettier": "^3.0.0", "prettier": "^3.0.0",
"qrcode": "^1.5.4", "qrcode": "^1.5.4",
"react": "18", "react": "19",
"react-dom": "18", "react-dom": "19",
"react-i18next": "^15.0.0", "react-i18next": "^15.0.0",
"react-router-dom": "^7.0.0", "react-router-dom": "^7.0.0",
"react-use-clipboard": "^1.0.7",
"react-use-measure": "^2.1.1", "react-use-measure": "^2.1.1",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"sass": "^1.42.1", "sass": "^1.42.1",
@@ -125,7 +130,7 @@
"unique-names-generator": "^4.6.0", "unique-names-generator": "^4.6.0",
"vaul": "^1.0.0", "vaul": "^1.0.0",
"vite": "^6.0.0", "vite": "^6.0.0",
"vite-plugin-generate-file": "^0.2.0", "vite-plugin-generate-file": "^0.3.0",
"vite-plugin-html": "^3.2.2", "vite-plugin-html": "^3.2.2",
"vite-plugin-svgr": "^4.0.0", "vite-plugin-svgr": "^4.0.0",
"vitest": "^3.0.0", "vitest": "^3.0.0",
+11 -3
View File
@@ -7,6 +7,10 @@ Please see LICENSE in the repository root for full details.
import { defineConfig, devices } from "@playwright/test"; import { defineConfig, devices } from "@playwright/test";
const baseURL = process.env.USE_DOCKER
? "http://localhost:8080"
: "https://localhost:3000";
/** /**
* See https://playwright.dev/docs/test-configuration. * See https://playwright.dev/docs/test-configuration.
*/ */
@@ -25,7 +29,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: { use: {
/* Base URL to use in actions like `await page.goto('/')`. */ /* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "https://localhost:3000", baseURL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry", trace: "on-first-retry",
@@ -73,9 +77,13 @@ export default defineConfig({
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
webServer: { webServer: {
command: "yarn dev", command: "./scripts/playwright-webserver-command.sh",
url: "https://localhost:3000", url: baseURL,
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
ignoreHTTPSErrors: true, ignoreHTTPSErrors: true,
gracefulShutdown: {
signal: "SIGTERM",
timeout: 500,
},
}, },
}); });
+85 -66
View File
@@ -5,7 +5,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type Page, test, expect, type JSHandle } from "@playwright/test"; import {
type Browser,
type Page,
test,
expect,
type JSHandle,
} from "@playwright/test";
import type { MatrixClient } from "matrix-js-sdk"; import type { MatrixClient } from "matrix-js-sdk";
@@ -30,8 +36,8 @@ const PASSWORD = "foobarbaz1!";
const CONFIG_JSON = { const CONFIG_JSON = {
default_server_config: { default_server_config: {
"m.homeserver": { "m.homeserver": {
base_url: "http://synapse.localhost:8008", base_url: "https://synapse.m.localhost",
server_name: "synapse.localhost", server_name: "synapse.m.localhost",
}, },
}, },
@@ -63,15 +69,72 @@ const CONFIG_JSON = {
* Set the Element Call URL in the dev tool settings using `window.mxSettingsStore` via `page.evaluate`. * Set the Element Call URL in the dev tool settings using `window.mxSettingsStore` via `page.evaluate`.
* @param page * @param page
*/ */
async function setDevToolElementCallDevUrl(page: Page): Promise<void> { const setDevToolElementCallDevUrl = process.env.USE_DOCKER
await page.evaluate(() => { ? async (page: Page): Promise<void> => {
window.mxSettingsStore.setValue( await page.evaluate(() => {
"Developer.elementCallUrl", window.mxSettingsStore.setValue(
null, "Developer.elementCallUrl",
"device", null,
"https://localhost:3000/room", "device",
); "http://localhost:8080/room",
);
});
}
: async (page: Page): Promise<void> => {
await page.evaluate(() => {
window.mxSettingsStore.setValue(
"Developer.elementCallUrl",
null,
"device",
"https://localhost:3000/room",
);
});
};
/**
* Registers a new user and returns page, clientHandle and mxId.
*/
async function registerUser(
browser: Browser,
username: string,
): Promise<{ page: Page; clientHandle: JSHandle<MatrixClient>; mxId: string }> {
const userContext = await browser.newContext({
reducedMotion: "reduce",
}); });
const page = await userContext.newPage();
await page.goto("http://localhost:8081/#/welcome");
await page.getByRole("link", { name: "Create Account" }).click();
await page.getByRole("textbox", { name: "Username" }).fill(username);
await page
.getByRole("textbox", { name: "Password", exact: true })
.fill(PASSWORD);
await page.getByRole("textbox", { name: "Confirm password" }).click();
await page.getByRole("textbox", { name: "Confirm password" }).fill(PASSWORD);
await page.getByRole("button", { name: "Register" }).click();
const continueButton = page.getByRole("button", { name: "Continue" });
try {
await expect(continueButton).toBeVisible({ timeout: 5000 });
await page
.getByRole("textbox", { name: "Password", exact: true })
.fill(PASSWORD);
await continueButton.click();
} catch {
// continueButton not visible, continue as normal
}
await expect(
page.getByRole("heading", { name: `Welcome ${username}` }),
).toBeVisible();
await setDevToolElementCallDevUrl(page);
const clientHandle = await page.evaluateHandle(() =>
window.mxMatrixClientPeg.get(),
);
const mxId = (await clientHandle.evaluate(
(cli: MatrixClient) => cli.getUserId(),
clientHandle,
))!;
return { page, clientHandle, mxId };
} }
export const widgetTest = test.extend<MyFixtures>({ export const widgetTest = test.extend<MyFixtures>({
@@ -83,61 +146,17 @@ export const widgetTest = test.extend<MyFixtures>({
const userA = `brooks_${Date.now()}`; const userA = `brooks_${Date.now()}`;
const userB = `whistler_${Date.now()}`; const userB = `whistler_${Date.now()}`;
const user1Context = await browser.newContext({ // Register users
reducedMotion: "reduce", const {
}); page: ewPage1,
const ewPage1 = await user1Context.newPage(); clientHandle: brooksClientHandle,
// Register the first user mxId: brooksMxId,
await ewPage1.goto("http://localhost:8081/#/welcome"); } = await registerUser(browser, userA);
await ewPage1.getByRole("link", { name: "Create Account" }).click(); const {
await ewPage1.getByRole("textbox", { name: "Username" }).fill(userA); page: ewPage2,
await ewPage1 clientHandle: whistlerClientHandle,
.getByRole("textbox", { name: "Password", exact: true }) mxId: whistlerMxId,
.fill(PASSWORD); } = await registerUser(browser, userB);
await ewPage1.getByRole("textbox", { name: "Confirm password" }).click();
await ewPage1
.getByRole("textbox", { name: "Confirm password" })
.fill(PASSWORD);
await ewPage1.getByRole("button", { name: "Register" }).click();
await expect(
ewPage1.getByRole("heading", { name: `Welcome ${userA}` }),
).toBeVisible();
await setDevToolElementCallDevUrl(ewPage1);
const brooksClientHandle = await ewPage1.evaluateHandle(() =>
window.mxMatrixClientPeg.get(),
);
const brooksMxId = (await brooksClientHandle.evaluate((cli) => {
return cli.getUserId();
}, brooksClientHandle))!;
const user2Context = await browser.newContext({
reducedMotion: "reduce",
});
const ewPage2 = await user2Context.newPage();
// Register the second user
await ewPage2.goto("http://localhost:8081/#/welcome");
await ewPage2.getByRole("link", { name: "Create Account" }).click();
await ewPage2.getByRole("textbox", { name: "Username" }).fill(userB);
await ewPage2
.getByRole("textbox", { name: "Password", exact: true })
.fill(PASSWORD);
await ewPage2.getByRole("textbox", { name: "Confirm password" }).click();
await ewPage2
.getByRole("textbox", { name: "Confirm password" })
.fill(PASSWORD);
await ewPage2.getByRole("button", { name: "Register" }).click();
await expect(
ewPage2.getByRole("heading", { name: `Welcome ${userB}` }),
).toBeVisible();
await setDevToolElementCallDevUrl(ewPage2);
const whistlerClientHandle = await ewPage2.evaluateHandle(() =>
window.mxMatrixClientPeg.get(),
);
const whistlerMxId = (await whistlerClientHandle.evaluate((cli) => {
return cli.getUserId();
}, whistlerClientHandle))!;
// Invite the second user // Invite the second user
await ewPage1.getByRole("button", { name: "Add room" }).click(); await ewPage1.getByRole("button", { name: "Add room" }).click();
+104
View File
@@ -0,0 +1,104 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { expect, test } from "@playwright/test";
test("When creator left, avoid reconnect to the same SFU", async ({
browser,
}) => {
// Use reduce motion to disable animations that are making the tests a bit flaky
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
const creatorPage = await creatorContext.newPage();
await creatorPage.goto("/");
// ========
// ARRANGE: The first user creates a call as guest, join it, then click the invite button to copy the invite link
// ========
await creatorPage.getByTestId("home_callName").click();
await creatorPage.getByTestId("home_callName").fill("Welcome");
await creatorPage.getByTestId("home_displayName").click();
await creatorPage.getByTestId("home_displayName").fill("Inviter");
await creatorPage.getByTestId("home_go").click();
await expect(creatorPage.locator("video")).toBeVisible();
// join
await creatorPage.getByTestId("lobby_joinCall").click();
// Spotlight mode to make checking the test visually clearer
await creatorPage.getByRole("radio", { name: "Spotlight" }).check();
// Get the invite link
await creatorPage.getByRole("button", { name: "Invite" }).click();
await expect(
creatorPage.getByRole("heading", { name: "Invite to this call" }),
).toBeVisible();
await expect(creatorPage.getByRole("img", { name: "QR Code" })).toBeVisible();
await expect(creatorPage.getByTestId("modal_inviteLink")).toBeVisible();
await expect(creatorPage.getByTestId("modal_inviteLink")).toBeVisible();
await creatorPage.getByTestId("modal_inviteLink").click();
const inviteLink = (await creatorPage.evaluate(
"navigator.clipboard.readText()",
)) as string;
expect(inviteLink).toContain("room/#/");
// ========
// ACT: The other user use the invite link to join the call as a guest
// ========
const guestB = await browser.newContext({
reducedMotion: "reduce",
});
const guestBPage = await guestB.newPage();
await guestBPage.goto(inviteLink);
await guestBPage.getByTestId("joincall_displayName").fill("Invitee");
await expect(guestBPage.getByTestId("joincall_joincall")).toBeVisible();
await guestBPage.getByTestId("joincall_joincall").click();
await guestBPage.getByTestId("lobby_joinCall").click();
await guestBPage.getByRole("radio", { name: "Spotlight" }).check();
// ========
// ACT: add a third user to the call to reproduce the bug
// ========
const guestC = await browser.newContext({
reducedMotion: "reduce",
});
const guestCPage = await guestC.newPage();
let sfuGetCallCount = 0;
await guestCPage.route("**/livekit/jwt/sfu/get", async (route) => {
sfuGetCallCount++;
await route.continue();
});
// Track WebSocket connections
let wsConnectionCount = 0;
await guestCPage.routeWebSocket("**", (ws) => {
// For some reason the interception is not working with the **
if (ws.url().includes("livekit/sfu/rtc")) {
wsConnectionCount++;
}
ws.connectToServer();
});
await guestCPage.goto(inviteLink);
await guestCPage.getByTestId("joincall_displayName").fill("Invitee");
await expect(guestCPage.getByTestId("joincall_joincall")).toBeVisible();
await guestCPage.getByTestId("joincall_joincall").click();
await guestCPage.getByTestId("lobby_joinCall").click();
await guestCPage.getByRole("radio", { name: "Spotlight" }).check();
await guestCPage.waitForTimeout(1000);
// ========
// the creator leaves the call
await creatorPage.getByTestId("incall_leave").click();
await guestCPage.waitForTimeout(2000);
// https://github.com/element-hq/element-call/issues/3344
// The app used to request a new jwt token then to reconnect to the SFU
expect(wsConnectionCount).toBe(1);
expect(sfuGetCallCount).toBe(1);
});
+7 -4
View File
@@ -9,11 +9,14 @@ import { expect, test } from "@playwright/test";
import { widgetTest } from "../fixtures/widget-user.ts"; import { widgetTest } from "../fixtures/widget-user.ts";
// Skip test, including Fixtures
widgetTest.skip(
({ browserName }) => browserName === "firefox",
"This test is not working on firefox, after hangup brooks is locked in a strange state with a blank widget",
);
widgetTest("Start a new call as widget", async ({ asWidget, browserName }) => { widgetTest("Start a new call as widget", async ({ asWidget, browserName }) => {
test.skip( test.slow(); // Triples the timeout
browserName === "firefox",
"This test is not working on firefox, after hangup brooks is locked in a strange state with a blank widget",
);
const { brooks, whistler } = asWidget; const { brooks, whistler } = asWidget;
+1 -1
View File
@@ -59,7 +59,7 @@
} }
], ],
"semanticCommits": "disabled", "semanticCommits": "disabled",
"ignoreDeps": ["posthog-js"], "ignoreDeps": ["posthog-js", "eslint-plugin-matrix-org"],
"vulnerabilityAlerts": { "vulnerabilityAlerts": {
"schedule": ["at any time"], "schedule": ["at any time"],
"prHourlyLimit": 0, "prHourlyLimit": 0,
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
if [ -n "$USE_DOCKER" ]; then
set -ex
yarn build
docker build -t element-call:testing .
exec docker run --rm --name element-call-testing -p 8080:8080 -v ./config/config.devenv.json:/app/config.json:ro,Z element-call:testing
else
cp config/config.devenv.json public/config.json
exec yarn dev
fi
+49 -33
View File
@@ -5,7 +5,14 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type FC, type JSX, Suspense, useEffect, useState } from "react"; import {
type FC,
type JSX,
Suspense,
useEffect,
useMemo,
useState,
} from "react";
import { BrowserRouter, Route, useLocation, Routes } from "react-router-dom"; import { BrowserRouter, Route, useLocation, Routes } from "react-router-dom";
import * as Sentry from "@sentry/react"; import * as Sentry from "@sentry/react";
import { TooltipProvider } from "@vector-im/compound-web"; import { TooltipProvider } from "@vector-im/compound-web";
@@ -19,10 +26,13 @@ import { ClientProvider } from "./ClientContext";
import { ErrorPage, LoadingPage } from "./FullScreenView"; import { ErrorPage, LoadingPage } from "./FullScreenView";
import { DisconnectedBanner } from "./DisconnectedBanner"; import { DisconnectedBanner } from "./DisconnectedBanner";
import { Initializer } from "./initializer"; import { Initializer } from "./initializer";
import { MediaDevicesProvider } from "./livekit/MediaDevicesContext";
import { widget } from "./widget"; import { widget } from "./widget";
import { useTheme } from "./useTheme"; import { useTheme } from "./useTheme";
import { ProcessorProvider } from "./livekit/TrackProcessorContext"; import { ProcessorProvider } from "./livekit/TrackProcessorContext";
import { type AppViewModel } from "./state/AppViewModel";
import { MediaDevicesContext } from "./MediaDevicesContext";
import { getUrlParams, HeaderStyle } from "./UrlParams";
import { AppBar } from "./AppBar";
const SentryRoute = Sentry.withSentryReactRouterV7Routing(Route); const SentryRoute = Sentry.withSentryReactRouterV7Routing(Route);
@@ -50,7 +60,11 @@ const ThemeProvider: FC<SimpleProviderProps> = ({ children }) => {
return children; return children;
}; };
export const App: FC = () => { interface Props {
vm: AppViewModel;
}
export const App: FC<Props> = ({ vm }) => {
const [loaded, setLoaded] = useState(false); const [loaded, setLoaded] = useState(false);
useEffect(() => { useEffect(() => {
Initializer.init() Initializer.init()
@@ -62,41 +76,43 @@ export const App: FC = () => {
.catch(logger.error); .catch(logger.error);
}); });
// Since we are outside the router component, we cannot use useUrlParams here
const { header } = useMemo(getUrlParams, []);
const content = loaded ? (
<ClientProvider>
<MediaDevicesContext value={vm.mediaDevices}>
<ProcessorProvider>
<Sentry.ErrorBoundary
fallback={(error) => <ErrorPage error={error} widget={widget} />}
>
<DisconnectedBanner />
<Routes>
<SentryRoute path="/" element={<HomePage />} />
<SentryRoute path="/login" element={<LoginPage />} />
<SentryRoute path="/register" element={<RegisterPage />} />
<SentryRoute path="*" element={<RoomPage />} />
</Routes>
</Sentry.ErrorBoundary>
</ProcessorProvider>
</MediaDevicesContext>
</ClientProvider>
) : (
<LoadingPage />
);
return ( return (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
<BrowserRouter> <BrowserRouter>
<BackgroundProvider> <BackgroundProvider>
<ThemeProvider> <ThemeProvider>
<TooltipProvider> <TooltipProvider>
{loaded ? ( <Suspense fallback={null}>
<Suspense fallback={null}> {header === HeaderStyle.AppBar ? (
<ClientProvider> <AppBar>{content}</AppBar>
<MediaDevicesProvider> ) : (
<ProcessorProvider> content
<Sentry.ErrorBoundary )}
fallback={(error) => ( </Suspense>
<ErrorPage error={error} widget={widget} />
)}
>
<DisconnectedBanner />
<Routes>
<SentryRoute path="/" element={<HomePage />} />
<SentryRoute path="/login" element={<LoginPage />} />
<SentryRoute
path="/register"
element={<RegisterPage />}
/>
<SentryRoute path="*" element={<RoomPage />} />
</Routes>
</Sentry.ErrorBoundary>
</ProcessorProvider>
</MediaDevicesProvider>
</ClientProvider>
</Suspense>
) : (
<LoadingPage />
)}
</TooltipProvider> </TooltipProvider>
</ThemeProvider> </ThemeProvider>
</BackgroundProvider> </BackgroundProvider>
+23
View File
@@ -0,0 +1,23 @@
.bar {
block-size: 64px;
flex-shrink: 0;
}
.bar > header {
position: absolute;
inset-inline: 0;
inset-block-start: 0;
block-size: 64px;
z-index: var(--call-view-header-footer-layer);
}
.bar svg path {
fill: var(--cpd-color-icon-primary);
}
.bar > header > h1 {
margin: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
+25
View File
@@ -0,0 +1,25 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { render } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { TooltipProvider } from "@vector-im/compound-web";
import { AppBar } from "./AppBar";
describe("AppBar", () => {
it("renders", () => {
const { container } = render(
<TooltipProvider>
<AppBar>
<p>This is the content.</p>
</AppBar>
</TooltipProvider>,
);
expect(container).toMatchSnapshot();
});
});
+130
View File
@@ -0,0 +1,130 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import {
createContext,
type FC,
type MouseEvent,
type ReactNode,
use,
useCallback,
useEffect,
useMemo,
useState,
} from "react";
import { Heading, IconButton, Tooltip } from "@vector-im/compound-web";
import { CollapseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import { useTranslation } from "react-i18next";
import { Header, LeftNav, RightNav } from "./Header";
import { platform } from "./Platform";
import styles from "./AppBar.module.css";
interface AppBarContext {
setTitle: (value: string) => void;
setSecondaryButton: (value: ReactNode) => void;
setHidden: (value: boolean) => void;
}
const AppBarContext = createContext<AppBarContext | null>(null);
interface Props {
children: ReactNode;
}
/**
* A "top app bar" featuring a back button, title and possibly a secondary
* button, similar to what you might see in mobile apps.
*/
export const AppBar: FC<Props> = ({ children }) => {
const { t } = useTranslation();
const onBackClick = useCallback((e: MouseEvent) => {
e.preventDefault();
window.controls.onBackButtonPressed?.();
}, []);
const [title, setTitle] = useState<string>("");
const [hidden, setHidden] = useState<boolean>(false);
const [secondaryButton, setSecondaryButton] = useState<ReactNode>(null);
const context = useMemo(
() => ({ setTitle, setSecondaryButton, setHidden }),
[setTitle, setHidden, setSecondaryButton],
);
return (
<>
<div
style={{ display: hidden ? "none" : "block" }}
className={styles.bar}
>
<Header>
<LeftNav>
<Tooltip label={t("common.back")}>
<IconButton onClick={onBackClick}>
<CollapseIcon />
</IconButton>
</Tooltip>
</LeftNav>
{title && (
<Heading
type="body"
size="lg"
weight={platform === "android" ? "medium" : "semibold"}
>
{title}
</Heading>
)}
<RightNav>{secondaryButton}</RightNav>
</Header>
</div>
<AppBarContext value={context}>{children}</AppBarContext>
</>
);
};
/**
* React hook which sets the title to be shown in the app bar, if present. It is
* an error to call this hook from multiple sites in the same component tree.
*/
export function useAppBarTitle(title: string): void {
const setTitle = use(AppBarContext)?.setTitle;
useEffect(() => {
if (setTitle !== undefined) {
setTitle(title);
return (): void => setTitle("");
}
}, [title, setTitle]);
}
/**
* React hook which sets the title to be shown in the app bar, if present. It is
* an error to call this hook from multiple sites in the same component tree.
*/
export function useAppBarHidden(hidden: boolean): void {
const setHidden = use(AppBarContext)?.setHidden;
useEffect(() => {
if (setHidden !== undefined) {
setHidden(hidden);
return (): void => setHidden(false);
}
}, [setHidden, hidden]);
}
/**
* React hook which sets the secondary button to be shown in the app bar, if
* present. It is an error to call this hook from multiple sites in the same
* component tree.
*/
export function useAppBarSecondaryButton(button: ReactNode): void {
const setSecondaryButton = use(AppBarContext)?.setSecondaryButton;
useEffect(() => {
if (setSecondaryButton !== undefined) {
setSecondaryButton(button);
return (): void => setSecondaryButton("");
}
}, [button, setSecondaryButton]);
}
+3 -6
View File
@@ -11,7 +11,7 @@ import {
useEffect, useEffect,
useState, useState,
createContext, createContext,
useContext, use,
useRef, useRef,
useMemo, useMemo,
type JSX, type JSX,
@@ -69,8 +69,7 @@ const ClientContext = createContext<ClientState | undefined>(undefined);
export const ClientContextProvider = ClientContext.Provider; export const ClientContextProvider = ClientContext.Provider;
export const useClientState = (): ClientState | undefined => export const useClientState = (): ClientState | undefined => use(ClientContext);
useContext(ClientContext);
export function useClient(): { export function useClient(): {
client?: MatrixClient; client?: MatrixClient;
@@ -350,9 +349,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
return <ErrorPage widget={widget} error={alreadyOpenedErr} />; return <ErrorPage widget={widget} error={alreadyOpenedErr} />;
} }
return ( return <ClientContext value={state}>{children}</ClientContext>;
<ClientContext.Provider value={state}>{children}</ClientContext.Provider>
);
}; };
export type InitResult = { export type InitResult = {
+1
View File
@@ -12,6 +12,7 @@
.error > h1 { .error > h1 {
margin: 0; margin: 0;
text-align: center;
} }
.error > p { .error > p {
+1 -1
View File
@@ -99,7 +99,7 @@ export const ErrorView: FC<Props> = ({
return ( return (
<div className={styles.error}> <div className={styles.error}>
<BigIcon className={styles.icon}> <BigIcon className={styles.icon}>
<Icon /> <Icon aria-hidden />
</BigIcon> </BigIcon>
<Heading as="h1" weight="semibold" size="md"> <Heading as="h1" weight="semibold" size="md">
{title} {title}
+4 -4
View File
@@ -10,7 +10,7 @@ import classNames from "classnames";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import * as Sentry from "@sentry/react"; import * as Sentry from "@sentry/react";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { ErrorIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; import { ErrorSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import { Header, HeaderLogo, LeftNav, RightNav } from "./Header"; import { Header, HeaderLogo, LeftNav, RightNav } from "./Header";
import styles from "./FullScreenView.module.css"; import styles from "./FullScreenView.module.css";
@@ -28,10 +28,10 @@ export const FullScreenView: FC<FullScreenViewProps> = ({
className, className,
children, children,
}) => { }) => {
const { hideHeader } = useUrlParams(); const { header } = useUrlParams();
return ( return (
<div className={classNames(styles.page, className)}> <div className={classNames(styles.page, className)}>
{!hideHeader && ( {header === "standard" && (
<Header> <Header>
<LeftNav> <LeftNav>
<HeaderLogo /> <HeaderLogo />
@@ -67,7 +67,7 @@ export const ErrorPage = ({ error, widget }: ErrorPageProps): ReactElement => {
) : ( ) : (
<ErrorView <ErrorView
widget={widget} widget={widget}
Icon={ErrorIcon} Icon={ErrorSolidIcon}
title={t("error.generic")} title={t("error.generic")}
rageshake rageshake
fatal fatal
+18 -19
View File
@@ -6,12 +6,7 @@ Please see LICENSE in the repository root for full details.
*/ */
import classNames from "classnames"; import classNames from "classnames";
import { import { type Ref, type FC, type HTMLAttributes, type ReactNode } from "react";
type FC,
type HTMLAttributes,
type ReactNode,
forwardRef,
} from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Heading, Text } from "@vector-im/compound-web"; import { Heading, Text } from "@vector-im/compound-web";
@@ -24,23 +19,27 @@ import { EncryptionLock } from "./room/EncryptionLock";
import { useMediaQuery } from "./useMediaQuery"; import { useMediaQuery } from "./useMediaQuery";
interface HeaderProps extends HTMLAttributes<HTMLElement> { interface HeaderProps extends HTMLAttributes<HTMLElement> {
ref?: Ref<HTMLElement>;
children: ReactNode; children: ReactNode;
className?: string; className?: string;
} }
export const Header = forwardRef<HTMLElement, HeaderProps>( export const Header: FC<HeaderProps> = ({
({ children, className, ...rest }, ref) => { ref,
return ( children,
<header className,
ref={ref} ...rest
className={classNames(styles.header, className)} }) => {
{...rest} return (
> <header
{children} ref={ref}
</header> className={classNames(styles.header, className)}
); {...rest}
}, >
); {children}
</header>
);
};
Header.displayName = "Header"; Header.displayName = "Header";
+56
View File
@@ -0,0 +1,56 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { createContext, use, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks";
import { type MediaDevices } from "./state/MediaDevices";
export const MediaDevicesContext = createContext<MediaDevices | undefined>(
undefined,
);
export function useMediaDevices(): MediaDevices {
const mediaDevices = use(MediaDevicesContext);
if (mediaDevices === undefined)
throw new Error(
"useMediaDevices must be used within a MediaDevices context provider",
);
return mediaDevices;
}
export const useIsEarpiece = (): boolean => {
const devices = useMediaDevices();
const audioOutput = useObservableEagerState(devices.audioOutput.selected$);
const available = useObservableEagerState(devices.audioOutput.available$);
if (!audioOutput?.id) return false;
return available.get(audioOutput.id)?.type === "earpiece";
};
/**
* A convenience hook to get the audio node configuration for the earpiece.
* It will check the `useAsEarpiece` of the `audioOutput` device and return
* the appropriate pan and volume values.
*
* @returns pan and volume values for the earpiece audio node configuration.
*/
export const useEarpieceAudioConfig = (): {
pan: number;
volume: number;
} => {
const devices = useMediaDevices();
const audioOutput = useObservableEagerState(devices.audioOutput.selected$);
const isVirtualEarpiece = audioOutput?.virtualEarpiece ?? false;
return {
// We use only the right speaker (pan = 1) for the earpiece.
// This mimics the behavior of the native earpiece speaker (only the top speaker on an iPhone)
pan: useMemo(() => (isVirtualEarpiece ? 1 : 0), [isVirtualEarpiece]),
// We also do lower the volume by a factor of 10 to optimize for the usecase where
// a user is holding the phone to their ear.
volume: useMemo(() => (isVirtualEarpiece ? 0.1 : 1), [isVirtualEarpiece]),
};
};
+72 -10
View File
@@ -10,7 +10,7 @@ import { describe, expect, it } from "vitest";
import { import {
getRoomIdentifierFromUrl, getRoomIdentifierFromUrl,
getUrlParams, getUrlParams,
UserIntent, HeaderStyle,
} from "../src/UrlParams"; } from "../src/UrlParams";
const ROOM_NAME = "roomNameHere"; const ROOM_NAME = "roomNameHere";
@@ -82,6 +82,16 @@ describe("UrlParams", () => {
getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId, getRoomIdentifierFromUrl("", `?roomId=${ROOM_ID}`, "").roomId,
).toBe(ROOM_ID); ).toBe(ROOM_ID);
}); });
it("(roomId with unprintable characters)", () => {
const invisibleChar = "\u2066";
expect(
getRoomIdentifierFromUrl(
"",
`?roomId=${invisibleChar}${ROOM_ID}${invisibleChar}`,
"",
).roomId,
).toBe(ROOM_ID);
});
}); });
it("ignores room alias", () => { it("ignores room alias", () => {
@@ -201,24 +211,68 @@ describe("UrlParams", () => {
}); });
describe("intent", () => { describe("intent", () => {
it("defaults to unknown", () => { const noIntentDefaults = {
expect(getUrlParams().intent).toBe(UserIntent.Unknown); confineToRoom: false,
appPrompt: true,
preload: false,
header: HeaderStyle.Standard,
showControls: true,
hideScreensharing: false,
allowIceFallback: false,
perParticipantE2EE: false,
controlledAudioDevices: false,
skipLobby: false,
returnToLobby: false,
sendNotificationType: undefined,
};
const startNewCallDefaults = (platform: string): object => ({
confineToRoom: true,
appPrompt: false,
preload: true,
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
showControls: true,
hideScreensharing: false,
allowIceFallback: true,
perParticipantE2EE: true,
controlledAudioDevices: platform === "desktop" ? false : true,
skipLobby: true,
returnToLobby: false,
sendNotificationType: "notification",
});
const joinExistingCallDefaults = (platform: string): object => ({
confineToRoom: true,
appPrompt: false,
preload: true,
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
showControls: true,
hideScreensharing: false,
allowIceFallback: true,
perParticipantE2EE: true,
controlledAudioDevices: platform === "desktop" ? false : true,
skipLobby: false,
returnToLobby: false,
sendNotificationType: "notification",
});
it("use no-intent-defaults with unknown intent", () => {
expect(getUrlParams()).toMatchObject(noIntentDefaults);
}); });
it("ignores intent if it is not a valid value", () => { it("ignores intent if it is not a valid value", () => {
expect(getUrlParams("?intent=foo").intent).toBe(UserIntent.Unknown); expect(getUrlParams("?intent=foo")).toMatchObject(noIntentDefaults);
}); });
it("accepts start_call", () => { it("accepts start_call", () => {
expect(getUrlParams("?intent=start_call").intent).toBe( expect(
UserIntent.StartNewCall, getUrlParams("?intent=start_call&widgetId=1234&parentUrl=parent.org"),
); ).toMatchObject(startNewCallDefaults("desktop"));
}); });
it("accepts join_existing", () => { it("accepts join_existing", () => {
expect(getUrlParams("?intent=join_existing").intent).toBe( expect(
UserIntent.JoinExistingCall, getUrlParams(
); "?intent=join_existing&widgetId=1234&parentUrl=parent.org",
),
).toMatchObject(joinExistingCallDefaults("desktop"));
}); });
}); });
@@ -243,4 +297,12 @@ describe("UrlParams", () => {
expect(getUrlParams("?intent=join_existing").skipLobby).toBe(false); expect(getUrlParams("?intent=join_existing").skipLobby).toBe(false);
}); });
}); });
describe("header", () => {
it("uses header if provided", () => {
expect(getUrlParams("?header=app_bar&hideHeader=true").header).toBe(
"app_bar",
);
expect(getUrlParams("?header=none&hideHeader=false").header).toBe("none");
});
});
}); });
+234 -108
View File
@@ -8,10 +8,13 @@ Please see LICENSE in the repository root for full details.
import { useMemo } from "react"; import { useMemo } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { type RTCNotificationType } from "matrix-js-sdk/lib/matrixrtc";
import { pickBy } from "lodash-es";
import { Config } from "./config/Config"; import { Config } from "./config/Config";
import { type EncryptionSystem } from "./e2ee/sharedKeyManagement"; import { type EncryptionSystem } from "./e2ee/sharedKeyManagement";
import { E2eeType } from "./e2ee/e2eeType"; import { E2eeType } from "./e2ee/e2eeType";
import { platform } from "./Platform";
interface RoomIdentifier { interface RoomIdentifier {
roomAlias: string | null; roomAlias: string | null;
@@ -20,17 +23,24 @@ interface RoomIdentifier {
} }
export enum UserIntent { export enum UserIntent {
// TODO: add DM vs room call
StartNewCall = "start_call", StartNewCall = "start_call",
JoinExistingCall = "join_existing", JoinExistingCall = "join_existing",
Unknown = "unknown", Unknown = "unknown",
} }
// If you need to add a new flag to this interface, prefer a name that describes export enum HeaderStyle {
// a specific behavior (such as 'confineToRoom'), rather than one that describes None = "none",
// the situations that call for this behavior ('isEmbedded'). This makes it Standard = "standard",
// clearer what each flag means, and helps us avoid coupling Element Call's AppBar = "app_bar",
// behavior to the needs of specific consumers. }
export interface UrlParams {
/**
* The UrlProperties are used to pass required data to the widget.
* Those are different in different rooms, users, devices. They do not configure the behavior of the
* widget but provide the required data to the widget.
*/
export interface UrlProperties {
// Widget api related params // Widget api related params
widgetId: string | null; widgetId: string | null;
parentUrl: string | null; parentUrl: string | null;
@@ -42,42 +52,11 @@ export interface UrlParams {
* is also not validated, where it is in useRoomIdentifier(). * is also not validated, where it is in useRoomIdentifier().
*/ */
roomId: string | null; roomId: string | null;
/**
* Whether the app should keep the user confined to the current call/room.
*/
confineToRoom: boolean;
/**
* Whether upon entering a room, the user should be prompted to launch the
* native mobile app. (Affects only Android and iOS.)
*
* The app prompt must also be enabled in the config for this to take effect.
*/
appPrompt: boolean;
/**
* Whether the app should pause before joining the call until it sees an
* io.element.join widget action, allowing it to be preloaded.
*/
preload: boolean;
/**
* Whether to hide the room header when in a call.
*/
hideHeader: boolean;
/**
* Whether the controls should be shown. For screen recording no controls can be desired.
*/
showControls: boolean;
/**
* Whether to hide the screen-sharing button.
*/
hideScreensharing: boolean;
/**
* Whether to use end-to-end encryption.
*/
e2eEnabled: boolean;
/** /**
* The user's ID (only used in matryoshka mode). * The user's ID (only used in matryoshka mode).
*/ */
userId: string | null; userId: string | null;
/** /**
* The display name to use for auto-registration. * The display name to use for auto-registration.
*/ */
@@ -115,18 +94,106 @@ export interface UrlParams {
*/ */
posthogApiKey: string | null; posthogApiKey: string | null;
/** /**
* Whether the app is allowed to use fallback STUN servers for ICE in case the * Whether to use end-to-end encryption.
* user's homeserver doesn't provide any.
*/ */
allowIceFallback: boolean; e2eEnabled: boolean;
/** /**
* E2EE password * E2EE password
*/ */
password: string | null; password: string | null;
/** This defines the homeserver that is going to be used when joining a room.
* It has to be set to a non default value for links to rooms
* that are not on the default homeserver,
* that is in use for the current user.
*/
viaServers: string | null;
/** /**
* Whether we the app should use per participant keys for E2EE. * This defines the homeserver that is going to be used when registering
* a new (guest) user.
* This can be user to configure a non default guest user server when
* creating a spa link.
*/
homeserver: string | null;
/**
* The rageshake submit URL. This is only used in the embedded package of Element Call.
*/
rageshakeSubmitUrl: string | null;
/**
* The Sentry DSN. This is only used in the embedded package of Element Call.
*/
sentryDsn: string | null;
/**
* The Sentry environment. This is only used in the embedded package of Element Call.
*/
sentryEnvironment: string | null;
/**
* The theme to use for element call.
* can be "light", "dark", "light-high-contrast" or "dark-high-contrast".
*/
theme: string | null;
}
/**
* The configuration for the app, which can be set via URL parameters.
* Those property are different to the UrlProperties, since they are all optional
* and configure the behavior of the app. Their value is the same if EC is used in
* the same context but with different accounts/users.
*
* Their defaults can be controlled by the `intent` property.
*/
export interface UrlConfiguration {
/**
* Whether the app should keep the user confined to the current call/room.
*/
confineToRoom: boolean;
/**
* Whether upon entering a room, the user should be prompted to launch the
* native mobile app. (Affects only Android and iOS.)
*
* The app prompt must also be enabled in the config for this to take effect.
*/
appPrompt: boolean;
/**
* Whether the app should pause before joining the call until it sees an
* io.element.join widget action, allowing it to be preloaded.
*/
preload: boolean;
/**
* The style of headers to show. "standard" is the default arrangement, "none"
* hides the header entirely, and "app_bar" produces a header with a back
* button like you might see in mobile apps. The callback for the back button
* is window.controls.onBackButtonPressed.
*/
header: HeaderStyle;
/**
* Whether the controls should be shown. For screen recording no controls can be desired.
*/
showControls: boolean;
/**
* Whether to hide the screen-sharing button.
*/
hideScreensharing: boolean;
/**
* Whether the app is allowed to use fallback STUN servers for ICE in case the
* user's homeserver doesn't provide any.
*/
allowIceFallback: boolean;
/**
* Whether the app should use per participant keys for E2EE.
*/ */
perParticipantE2EE: boolean; perParticipantE2EE: boolean;
/**
* Whether the global JS controls for audio output devices should be enabled,
* allowing the list of output devices to be controlled by the app hosting
* Element Call.
*/
controlledAudioDevices: boolean;
/** /**
* Setting this flag skips the lobby and brings you in the call directly. * Setting this flag skips the lobby and brings you in the call directly.
* In the widget this can be combined with preload to pass the device settings * In the widget this can be combined with preload to pass the device settings
@@ -139,46 +206,18 @@ export interface UrlParams {
*/ */
returnToLobby: boolean; returnToLobby: boolean;
/** /**
* The theme to use for element call. * Whether and what type of notification EC should send, when the user joins the call.
* can be "light", "dark", "light-high-contrast" or "dark-high-contrast".
*/ */
theme: string | null; sendNotificationType?: RTCNotificationType;
/** This defines the homeserver that is going to be used when joining a room.
* It has to be set to a non default value for links to rooms
* that are not on the default homeserver,
* that is in use for the current user.
*/
viaServers: string | null;
/**
* This defines the homeserver that is going to be used when registering
* a new (guest) user.
* This can be user to configure a non default guest user server when
* creating a spa link.
*/
homeserver: string | null;
/**
* The user's intent with respect to the call.
* e.g. if they clicked a Start Call button, this would be `start_call`.
* If it was a Join Call button, it would be `join_existing`.
*/
intent: string | null;
/**
* The rageshake submit URL. This is only used in the embedded package of Element Call.
*/
rageshakeSubmitUrl: string | null;
/**
* The Sentry DSN. This is only used in the embedded package of Element Call.
*/
sentryDsn: string | null;
/**
* The Sentry environment. This is only used in the embedded package of Element Call.
*/
sentryEnvironment: string | null;
} }
// If you need to add a new flag to this interface, prefer a name that describes
// a specific behavior (such as 'confineToRoom'), rather than one that describes
// the situations that call for this behavior ('isEmbedded'). This makes it
// clearer what each flag means, and helps us avoid coupling Element Call's
// behavior to the needs of specific consumers.
export interface UrlParams extends UrlProperties, UrlConfiguration {}
// This is here as a stopgap, but what would be far nicer is a function that // This is here as a stopgap, but what would be far nicer is a function that
// takes a UrlParams and returns a query string. That would enable us to // takes a UrlParams and returns a query string. That would enable us to
// consolidate all the data about URL parameters and their meanings to this one // consolidate all the data about URL parameters and their meanings to this one
@@ -219,6 +258,17 @@ class ParamParser {
return this.fragmentParams.get(name) ?? this.queryParams.get(name); return this.fragmentParams.get(name) ?? this.queryParams.get(name);
} }
public getEnumParam<T extends string>(
name: string,
type: { [s: string]: T } | ArrayLike<T>,
): T | undefined {
const value = this.getParam(name);
if (value !== null && Object.values(type).includes(value as T)) {
return value as T;
}
return undefined;
}
public getAllParams(name: string): string[] { public getAllParams(name: string): string[] {
return [ return [
...this.fragmentParams.getAll(name), ...this.fragmentParams.getAll(name),
@@ -230,6 +280,10 @@ class ParamParser {
const param = this.getParam(name); const param = this.getParam(name);
return param === null ? defaultValue : param !== "false"; return param === null ? defaultValue : param !== "false";
} }
public getFlag(name: string): boolean | undefined {
const param = this.getParam(name);
return param !== null ? param !== "false" : undefined;
}
} }
/** /**
@@ -246,32 +300,79 @@ export const getUrlParams = (
const fontScale = parseFloat(parser.getParam("fontScale") ?? ""); const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
let intent = parser.getParam("intent");
if (!intent || !Object.values(UserIntent).includes(intent as UserIntent)) {
intent = UserIntent.Unknown;
}
const widgetId = parser.getParam("widgetId"); const widgetId = parser.getParam("widgetId");
const parentUrl = parser.getParam("parentUrl"); const parentUrl = parser.getParam("parentUrl");
const isWidget = !!widgetId && !!parentUrl; const isWidget = !!widgetId && !!parentUrl;
return { /**
* The user's intent with respect to the call.
* e.g. if they clicked a Start Call button, this would be `start_call`.
* If it was a Join Call button, it would be `join_existing`.
* This is a platform specific default set of parameters, that allows to minize the configuration
* needed to start a call. And empowers the EC codebase to control the platform/intent behavior in
* a central place.
*
* In short: either provide url query parameters of UrlConfiguration or set the intent
* (or the global defaults will be used).
*/
const intent = !isWidget
? UserIntent.Unknown
: (parser.getEnumParam("intent", UserIntent) ?? UserIntent.Unknown);
// Here we only use constants and `platform` to determine the intent preset.
let intentPreset: UrlConfiguration;
const inAppDefault = {
confineToRoom: true,
appPrompt: false,
preload: true,
header: platform === "desktop" ? HeaderStyle.None : HeaderStyle.AppBar,
showControls: true,
hideScreensharing: false,
allowIceFallback: true,
perParticipantE2EE: true,
controlledAudioDevices: platform === "desktop" ? false : true,
skipLobby: true,
returnToLobby: false,
sendNotificationType: "notification" as RTCNotificationType,
};
switch (intent) {
case UserIntent.StartNewCall:
intentPreset = {
...inAppDefault,
skipLobby: true,
};
break;
case UserIntent.JoinExistingCall:
intentPreset = {
...inAppDefault,
skipLobby: false,
};
break;
// Non widget usecase defaults
default:
intentPreset = {
confineToRoom: false,
appPrompt: true,
preload: false,
header: HeaderStyle.Standard,
showControls: true,
hideScreensharing: false,
allowIceFallback: false,
perParticipantE2EE: false,
controlledAudioDevices: false,
skipLobby: false,
returnToLobby: false,
sendNotificationType: undefined,
};
}
const properties: UrlProperties = {
widgetId, widgetId,
parentUrl, parentUrl,
// NB. we don't validate roomId here as we do in getRoomIdentifierFromUrl: // NB. we don't validate roomId here as we do in getRoomIdentifierFromUrl:
// what would we do if it were invalid? If the widget API says that's what // what would we do if it were invalid? If the widget API says that's what
// the room ID is, then that's what it is. // the room ID is, then that's what it is.
roomId: parser.getParam("roomId"), roomId: parser.getParam("roomId"),
password: parser.getParam("password"), password: parser.getParam("password"),
// This flag has 'embed' as an alias for historical reasons
confineToRoom:
parser.getFlagParam("confineToRoom") || parser.getFlagParam("embed"),
appPrompt: parser.getFlagParam("appPrompt", true),
preload: isWidget ? parser.getFlagParam("preload") : false,
hideHeader: parser.getFlagParam("hideHeader"),
showControls: parser.getFlagParam("showControls", true),
hideScreensharing: parser.getFlagParam("hideScreensharing"),
e2eEnabled: parser.getFlagParam("enableE2EE", true),
userId: isWidget ? parser.getParam("userId") : null, userId: isWidget ? parser.getParam("userId") : null,
displayName: parser.getParam("displayName"), displayName: parser.getParam("displayName"),
deviceId: isWidget ? parser.getParam("deviceId") : null, deviceId: isWidget ? parser.getParam("deviceId") : null,
@@ -279,19 +380,9 @@ export const getUrlParams = (
lang: parser.getParam("lang"), lang: parser.getParam("lang"),
fonts: parser.getAllParams("font"), fonts: parser.getAllParams("font"),
fontScale: Number.isNaN(fontScale) ? null : fontScale, fontScale: Number.isNaN(fontScale) ? null : fontScale,
allowIceFallback: parser.getFlagParam("allowIceFallback"),
perParticipantE2EE: parser.getFlagParam("perParticipantE2EE"),
skipLobby: parser.getFlagParam(
"skipLobby",
isWidget && intent === UserIntent.StartNewCall,
),
// In SPA mode the user should always exit to the home screen when hanging
// up, rather than being sent back to the lobby
returnToLobby: isWidget ? parser.getFlagParam("returnToLobby") : false,
theme: parser.getParam("theme"), theme: parser.getParam("theme"),
viaServers: !isWidget ? parser.getParam("viaServers") : null, viaServers: !isWidget ? parser.getParam("viaServers") : null,
homeserver: !isWidget ? parser.getParam("homeserver") : null, homeserver: !isWidget ? parser.getParam("homeserver") : null,
intent,
posthogApiHost: parser.getParam("posthogApiHost"), posthogApiHost: parser.getParam("posthogApiHost"),
posthogApiKey: parser.getParam("posthogApiKey"), posthogApiKey: parser.getParam("posthogApiKey"),
posthogUserId: posthogUserId:
@@ -299,6 +390,35 @@ export const getUrlParams = (
rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"), rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"),
sentryDsn: parser.getParam("sentryDsn"), sentryDsn: parser.getParam("sentryDsn"),
sentryEnvironment: parser.getParam("sentryEnvironment"), sentryEnvironment: parser.getParam("sentryEnvironment"),
e2eEnabled: parser.getFlagParam("enableE2EE", true),
};
const configuration: Partial<UrlConfiguration> = {
confineToRoom: parser.getFlag("confineToRoom"),
appPrompt: parser.getFlag("appPrompt"),
preload: isWidget ? parser.getFlag("preload") : undefined,
// Check hideHeader for backwards compatibility. If header is set, hideHeader
// is ignored.
header: parser.getEnumParam("header", HeaderStyle),
showControls: parser.getFlag("showControls"),
hideScreensharing: parser.getFlag("hideScreensharing"),
allowIceFallback: parser.getFlag("allowIceFallback"),
perParticipantE2EE: parser.getFlag("perParticipantE2EE"),
controlledAudioDevices: parser.getFlag("controlledAudioDevices"),
skipLobby: isWidget ? parser.getFlag("skipLobby") : false,
// In SPA mode the user should always exit to the home screen when hanging
// up, rather than being sent back to the lobby
returnToLobby: isWidget ? parser.getFlag("returnToLobby") : false,
sendNotificationType: parser.getEnumParam("sendNotificationType", [
"ring",
"notification",
]),
};
return {
...properties,
...intentPreset,
...pickBy(configuration, (v) => v !== undefined),
}; };
}; };
@@ -357,10 +477,16 @@ export function getRoomIdentifierFromUrl(
// Make sure roomId is valid // Make sure roomId is valid
let roomId: string | null = parser.getParam("roomId"); let roomId: string | null = parser.getParam("roomId");
if (!roomId?.startsWith("!")) { if (roomId !== null) {
roomId = null; // Replace any non-printable characters that another client may have inserted.
} else if (!roomId.includes("")) { // For instance on iOS, some copied links end up with zero width characters on the end which get encoded into the URL.
roomId = null; // This isn't valid for a roomId, so we can freely strip the content.
roomId = roomId.replaceAll(/^[^ -~]+|[^ -~]+$/g, "");
if (!roomId.startsWith("!")) {
roomId = null;
} else if (!roomId.includes("")) {
roomId = null;
}
} }
return { return {
+50
View File
@@ -0,0 +1,50 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`AppBar > renders 1`] = `
<div>
<div
class="bar"
style="display: block;"
>
<header
class="header"
>
<div
class="nav leftNav"
>
<button
aria-labelledby="«r0»"
class="_icon-button_1pz9o_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
>
<div
class="_indicator-icon_zr2a0_17"
style="--cpd-icon-button-size: 100%;"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 11.034a1 1 0 0 0 .29.702l.005.005c.18.18.43.29.705.29h8a1 1 0 0 0 0-2h-5.586L22 3.445a1 1 0 0 0-1.414-1.414L14 8.617V3.031a1 1 0 1 0-2 0zm0 1.963a1 1 0 0 0-.29-.702l-.005-.004A1 1 0 0 0 11 12H3a1 1 0 1 0 0 2h5.586L2 20.586A1 1 0 1 0 3.414 22L10 15.414V21a1 1 0 0 0 2 0z"
/>
</svg>
</div>
</button>
</div>
<div
class="nav rightNav"
/>
</header>
</div>
<p>
This is the content.
</p>
</div>
`;
+8 -8
View File
@@ -2,10 +2,10 @@
exports[`the content is rendered when the modal is open 1`] = ` exports[`the content is rendered when the modal is open 1`] = `
<div <div
aria-labelledby="radix-:r4:" aria-labelledby="radix-«r4»"
class="overlay animate modal dialog _glass_1x9g9_17" class="overlay animate modal dialog _glass_sepwu_8"
data-state="open" data-state="open"
id="radix-:r3:" id="radix-«r3»"
role="dialog" role="dialog"
style="pointer-events: auto;" style="pointer-events: auto;"
tabindex="-1" tabindex="-1"
@@ -17,8 +17,8 @@ exports[`the content is rendered when the modal is open 1`] = `
class="header" class="header"
> >
<h2 <h2
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
id="radix-:r4:" id="radix-«r4»"
> >
My modal My modal
</h2> </h2>
@@ -36,7 +36,7 @@ exports[`the content is rendered when the modal is open 1`] = `
exports[`the modal renders as a drawer in mobile viewports 1`] = ` exports[`the modal renders as a drawer in mobile viewports 1`] = `
<div <div
aria-labelledby="radix-:ra:" aria-labelledby="radix-«ra»"
class="overlay modal drawer" class="overlay modal drawer"
data-state="open" data-state="open"
data-vaul-animate="true" data-vaul-animate="true"
@@ -45,7 +45,7 @@ exports[`the modal renders as a drawer in mobile viewports 1`] = `
data-vaul-drawer="" data-vaul-drawer=""
data-vaul-drawer-direction="bottom" data-vaul-drawer-direction="bottom"
data-vaul-snap-points="false" data-vaul-snap-points="false"
id="radix-:r9:" id="radix-«r9»"
role="dialog" role="dialog"
style="pointer-events: auto;" style="pointer-events: auto;"
tabindex="-1" tabindex="-1"
@@ -60,7 +60,7 @@ exports[`the modal renders as a drawer in mobile viewports 1`] = `
class="handle" class="handle"
/> />
<h2 <h2
id="radix-:ra:" id="radix-«ra»"
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;" style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
> >
My modal My modal
+4 -4
View File
@@ -2,18 +2,18 @@
exports[`Toast > renders 1`] = ` exports[`Toast > renders 1`] = `
<button <button
aria-labelledby="radix-:r4:" aria-labelledby="radix-«r4»"
class="overlay animate toast" class="overlay animate toast"
data-state="open" data-state="open"
id="radix-:r3:" id="radix-«r3»"
role="dialog" role="dialog"
style="pointer-events: auto;" style="pointer-events: auto;"
tabindex="-1" tabindex="-1"
type="button" type="button"
> >
<h3 <h3
class="_typography_yh5dq_162 _font-body-sm-semibold_yh5dq_45" class="_typography_6v6n8_153 _font-body-sm-semibold_6v6n8_36"
id="radix-:r4:" id="radix-«r4»"
> >
Hello world! Hello world!
</h3> </h3>
+2 -2
View File
@@ -107,13 +107,13 @@ export class RageshakeSpanProcessor implements SpanProcessor {
startTime, startTime,
duration, duration,
references: references:
span.parentSpanId === undefined span.parentSpanContext?.spanId === undefined
? [] ? []
: [ : [
{ {
refType: "CHILD_OF", refType: "CHILD_OF",
traceID: traceId, traceID: traceId,
spanID: span.parentSpanId, spanID: span.parentSpanContext?.spanId,
}, },
], ],
tags: dumpAttributes(span.attributes), tags: dumpAttributes(span.attributes),
+14 -19
View File
@@ -5,11 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { import { type ComponentProps, type FC, type MouseEvent } from "react";
type ComponentPropsWithoutRef,
forwardRef,
type MouseEvent,
} from "react";
import { Link as CpdLink } from "@vector-im/compound-web"; import { Link as CpdLink } from "@vector-im/compound-web";
import { type LinkProps, useHref, useLinkClickHandler } from "react-router-dom"; import { type LinkProps, useHref, useLinkClickHandler } from "react-router-dom";
import classNames from "classnames"; import classNames from "classnames";
@@ -26,31 +22,30 @@ export function useLink(
return [href, onClick]; return [href, onClick];
} }
type Props = Omit< type Props = Omit<ComponentProps<typeof CpdLink>, "href" | "onClick"> & {
ComponentPropsWithoutRef<typeof CpdLink>, to: LinkProps["to"];
"href" | "onClick" state?: unknown;
> & { to: LinkProps["to"]; state?: unknown }; };
/** /**
* A version of Compound's link component that integrates with our router setup. * A version of Compound's link component that integrates with our router setup.
* This is only for app-internal links. * This is only for app-internal links.
*/ */
export const Link = forwardRef<HTMLAnchorElement, Props>(function Link( export const Link: FC<Props> = ({ ref, to, state, ...props }) => {
{ to, state, ...props },
ref,
) {
const [path, onClick] = useLink(to, state); const [path, onClick] = useLink(to, state);
return <CpdLink ref={ref} {...props} href={path} onClick={onClick} />; return <CpdLink ref={ref} {...props} href={path} onClick={onClick} />;
}); };
/** /**
* A link to an external web page, made to fit into blocks of text more subtly * A link to an external web page, made to fit into blocks of text more subtly
* than the normal Compound link component. * than the normal Compound link component.
*/ */
export const ExternalLink = forwardRef< export const ExternalLink: FC<ComponentProps<"a">> = ({
HTMLAnchorElement, ref,
ComponentPropsWithoutRef<"a"> className,
>(function ExternalLink({ className, children, ...props }, ref) { children,
...props
}) => {
return ( return (
<a <a
ref={ref} ref={ref}
@@ -62,4 +57,4 @@ export const ExternalLink = forwardRef<
{children} {children}
</a> </a>
); );
}); };
+9 -11
View File
@@ -5,24 +5,22 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type ComponentPropsWithoutRef, forwardRef } from "react"; import { type ComponentProps, type FC } from "react";
import { Button } from "@vector-im/compound-web"; import { Button } from "@vector-im/compound-web";
import type { LinkProps } from "react-router-dom"; import type { LinkProps } from "react-router-dom";
import { useLink } from "./Link"; import { useLink } from "./Link";
type Props = Omit< type Props = Omit<ComponentProps<typeof Button<"a">>, "as" | "href"> & {
ComponentPropsWithoutRef<typeof Button<"a">>, to: LinkProps["to"];
"as" | "href" state?: unknown;
> & { to: LinkProps["to"]; state?: unknown }; };
/** /**
* A version of Compound's button component that acts as a link and integrates * A version of Compound's button component that acts as a link and integrates
* with our router setup. * with our router setup.
*/ */
export const LinkButton = forwardRef<HTMLAnchorElement, Props>( export const LinkButton: FC<Props> = ({ ref, to, state, ...props }) => {
function LinkButton({ to, state, ...props }, ref) { const [path, onClick] = useLink(to, state);
const [path, onClick] = useLink(to, state); return <Button as="a" ref={ref} {...props} href={path} onClick={onClick} />;
return <Button as="a" ref={ref} {...props} href={path} onClick={onClick} />; };
},
);
+3 -8
View File
@@ -24,8 +24,6 @@ import {
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import classNames from "classnames"; import classNames from "classnames";
import { useObservableState } from "observable-hooks";
import { map } from "rxjs";
import { useReactionsSender } from "../reactions/useReactionsSender"; import { useReactionsSender } from "../reactions/useReactionsSender";
import styles from "./ReactionToggleButton.module.css"; import styles from "./ReactionToggleButton.module.css";
@@ -36,6 +34,7 @@ import {
} from "../reactions"; } from "../reactions";
import { Modal } from "../Modal"; import { Modal } from "../Modal";
import { type CallViewModel } from "../state/CallViewModel"; import { type CallViewModel } from "../state/CallViewModel";
import { useBehavior } from "../useBehavior";
interface InnerButtonProps extends ComponentPropsWithoutRef<"button"> { interface InnerButtonProps extends ComponentPropsWithoutRef<"button"> {
raised: boolean; raised: boolean;
@@ -180,12 +179,8 @@ export function ReactionToggleButton({
const [showReactionsMenu, setShowReactionsMenu] = useState(false); const [showReactionsMenu, setShowReactionsMenu] = useState(false);
const [errorText, setErrorText] = useState<string>(); const [errorText, setErrorText] = useState<string>();
const isHandRaised = useObservableState( const isHandRaised = !!useBehavior(vm.handsRaised$)[identifier];
vm.handsRaised$.pipe(map((v) => !!v[identifier])), const canReact = !useBehavior(vm.reactions$)[identifier];
);
const canReact = useObservableState(
vm.reactions$.pipe(map((v) => !v[identifier])),
);
useEffect(() => { useEffect(() => {
// Clear whenever the reactions menu state changes. // Clear whenever the reactions menu state changes.
@@ -9,8 +9,8 @@ exports[`Can close reaction dialog 1`] = `
aria-disabled="false" aria-disabled="false"
aria-expanded="true" aria-expanded="true"
aria-haspopup="true" aria-haspopup="true"
aria-labelledby=":rb5:" aria-labelledby="«rb5»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -26,7 +26,7 @@ exports[`Can close reaction dialog 1`] = `
> >
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10m3.536-6.464a1 1 0 0 0-1.415-1.415A3 3 0 0 1 12 15a3 3 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A5 5 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464M10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
@@ -43,8 +43,8 @@ exports[`Can fully expand emoji picker 1`] = `
aria-disabled="false" aria-disabled="false"
aria-expanded="true" aria-expanded="true"
aria-haspopup="true" aria-haspopup="true"
aria-labelledby=":r7m:" aria-labelledby="«r7m»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -60,7 +60,7 @@ exports[`Can fully expand emoji picker 1`] = `
> >
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10m3.536-6.464a1 1 0 0 0-1.415-1.415A3 3 0 0 1 12 15a3 3 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A5 5 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464M10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
@@ -74,8 +74,8 @@ exports[`Can lower hand 1`] = `
aria-disabled="false" aria-disabled="false"
aria-expanded="false" aria-expanded="false"
aria-haspopup="true" aria-haspopup="true"
aria-labelledby=":r36:" aria-labelledby="«r36»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="secondary" data-kind="secondary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -91,7 +91,7 @@ exports[`Can lower hand 1`] = `
> >
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10m3.536-6.464a1 1 0 0 0-1.415-1.415A3 3 0 0 1 12 15a3 3 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A5 5 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464M10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
@@ -108,8 +108,8 @@ exports[`Can open menu 1`] = `
aria-disabled="false" aria-disabled="false"
aria-expanded="true" aria-expanded="true"
aria-haspopup="true" aria-haspopup="true"
aria-labelledby=":r0:" aria-labelledby="«r0»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -125,7 +125,7 @@ exports[`Can open menu 1`] = `
> >
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10m3.536-6.464a1 1 0 0 0-1.415-1.415A3 3 0 0 1 12 15a3 3 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A5 5 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464M10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
@@ -139,8 +139,8 @@ exports[`Can raise hand 1`] = `
aria-disabled="false" aria-disabled="false"
aria-expanded="false" aria-expanded="false"
aria-haspopup="true" aria-haspopup="true"
aria-labelledby=":r1j:" aria-labelledby="«r1j»"
class="_button_i91xf_17 raisedButton _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 raisedButton _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -155,7 +155,7 @@ exports[`Can raise hand 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M11 3a1 1 0 1 1 2 0v8.5a.5.5 0 0 0 1 0V4a1 1 0 1 1 2 0v10.2l3.284-2.597a1.081 1.081 0 0 1 1.47 1.577c-.613.673-1.214 1.367-1.818 2.064-1.267 1.463-2.541 2.934-3.944 4.235A6 6 0 0 1 5 15V7a1 1 0 0 1 2 0v5.5a.5.5 0 0 0 1 0V4a1 1 0 0 1 2 0v7.5a.5.5 0 0 0 1 0V3Z" d="M11 3a1 1 0 1 1 2 0v8.5a.5.5 0 0 0 1 0V4a1 1 0 1 1 2 0v10.2l3.284-2.597a1.081 1.081 0 0 1 1.47 1.577c-.613.673-1.214 1.367-1.818 2.064-1.267 1.463-2.541 2.934-3.943 4.235A6 6 0 0 1 5 15V7a1 1 0 0 1 1.999 0v5.5a.5.5 0 0 0 1 0V4a1 1 0 0 1 2 0v7.5a.5.5 0 0 0 1 0z"
/> />
</svg> </svg>
</button> </button>
+39 -5
View File
@@ -14,6 +14,7 @@ export interface ConfigOptions {
api_key: string; api_key: string;
api_host: string; api_host: string;
}; };
/** /**
* The Sentry endpoint to which crash data will be sent. * The Sentry endpoint to which crash data will be sent.
* This is only used in the full package of Element Call. * This is only used in the full package of Element Call.
@@ -22,6 +23,7 @@ export interface ConfigOptions {
DSN: string; DSN: string;
environment: string; environment: string;
}; };
/** /**
* The rageshake server to which feedback and debug logs will be sent. * The rageshake server to which feedback and debug logs will be sent.
* This is only used in the full package of Element Call. * This is only used in the full package of Element Call.
@@ -66,6 +68,7 @@ export interface ConfigOptions {
* Allow to join group calls without audio and video. * Allow to join group calls without audio and video.
*/ */
feature_group_calls_without_video_and_audio?: boolean; feature_group_calls_without_video_and_audio?: boolean;
/** /**
* Send device-specific call session membership state events instead of * Send device-specific call session membership state events instead of
* legacy user-specific call membership state events. * legacy user-specific call membership state events.
@@ -86,6 +89,7 @@ export interface ConfigOptions {
* Defines whether participants should start with audio enabled by default. * Defines whether participants should start with audio enabled by default.
*/ */
enable_audio?: boolean; enable_audio?: boolean;
/** /**
* Defines whether participants should start with video enabled by default. * Defines whether participants should start with video enabled by default.
*/ */
@@ -109,19 +113,49 @@ export interface ConfigOptions {
* How long (in milliseconds) to wait before rotating end-to-end media encryption keys * How long (in milliseconds) to wait before rotating end-to-end media encryption keys
* when someone leaves a call. * when someone leaves a call.
*/ */
wait_for_key_rotation_ms?: number;
/** @deprecated use wait_for_key_rotation_ms instead */
key_rotation_on_leave_delay?: number; key_rotation_on_leave_delay?: number;
/** /**
* How often (in milliseconds) keep-alive messages should be sent to the server for * The duration (in milliseconds) after the most recent keep-alive (delayed leave event restart)
* the MatrixRTC membership event. * that the server waits before sending the leave MatrixRTC membership event.
*/ */
delayed_leave_event_delay_ms?: number;
/** @deprecated use delayed_leave_event_delay_ms instead */
membership_server_side_expiry_timeout?: number;
/**
* The time (in milliseconds) after which a we consider a delayed event restart http request to have failed.
* Setting this to a lower value will result in more frequent retries but also a higher chance of failiour.
*
* In the presence of network packet loss (hurting TCP connections), the custom delayedEventRestartLocalTimeoutMs
* helps by keeping more delayed event reset candidates in flight,
* improving the chances of a successful reset. (its is equivalent to the js-sdk `localTimeout` configuration,
* but only applies to calls to the `_unstable_updateDelayedEvent` endpoint with a body of `{action:"restart"}`.)
*/
delayed_leave_event_restart_local_timeout_ms?: number;
/**
* The time interval (in milliseconds) at which the client sends membership keep-alive
* messages to the server by restarting the timer for the delayed leave event.
*/
delayed_leave_event_restart_ms?: number;
/** @deprecated use delayed_leave_event_restart_ms instead */
membership_keep_alive_period?: number; membership_keep_alive_period?: number;
/** /**
* How long (in milliseconds) after the last keep-alive the server should expire the * How long we wait before retrying after a network error on any of the requests.
* MatrixRTC membership event.
*/ */
membership_server_side_expiry_timeout?: number; network_error_retry_ms?: number;
/**
* The timeout (in milliseconds) after we joined the call, that our membership should expire
* unless we have explicitly updated it.
*
* This is what goes into the m.rtc.member event expiry field and is typically set to a number of hours.
*/
membership_event_expiry_ms?: number;
}; };
} }
+86 -4
View File
@@ -1,20 +1,74 @@
/* /*
Copyright 2024 New Vector Ltd. Copyright 2024-2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
const logger = rootLogger.getChild("[controlled-output]");
export interface Controls { export interface Controls {
canEnterPip: () => boolean; canEnterPip(): boolean;
enablePip: () => void; enablePip(): void;
disablePip: () => void; disablePip(): void;
setAvailableAudioDevices(devices: OutputDevice[]): void;
setAudioDevice(id: string): void;
onAudioDeviceSelect?: (id: string) => void;
onAudioPlaybackStarted?: () => void;
setAudioEnabled(enabled: boolean): void;
showNativeAudioDevicePicker?: () => void;
onBackButtonPressed?: () => void;
/** @deprecated use setAvailableAudioDevices instead*/
setAvailableOutputDevices(devices: OutputDevice[]): void;
/** @deprecated use setAudioDevice instead*/
setOutputDevice(id: string): void;
/** @deprecated use onAudioDeviceSelect instead*/
onOutputDeviceSelect?: (id: string) => void;
/** @deprecated use setAudioEnabled instead*/
setOutputEnabled(enabled: boolean): void;
/** @deprecated use showNativeAudioDevicePicker instead*/
showNativeOutputDevicePicker?: () => void;
} }
export interface OutputDevice {
id: string;
name: string;
forEarpiece?: boolean;
isEarpiece?: boolean;
isSpeaker?: boolean;
isExternalHeadset?: boolean;
}
/**
* If pipMode is enabled, EC will render a adapted call view layout.
*/
export const setPipEnabled$ = new Subject<boolean>(); export const setPipEnabled$ = new Subject<boolean>();
export const availableOutputDevices$ = new Subject<OutputDevice[]>();
export const outputDevice$ = new Subject<string>();
/**
* This allows the os to mute the call if the user
* presses the volume down button when it is at the minimum volume.
*
* This should also be used to display a darkened overlay screen letting the user know that audio is muted.
*/
export const setAudioEnabled$ = new Subject<boolean>();
let playbackStartedEmitted = false;
export const setPlaybackStarted = (): void => {
if (!playbackStartedEmitted) {
playbackStartedEmitted = true;
window.controls.onAudioPlaybackStarted?.();
}
};
window.controls = { window.controls = {
canEnterPip(): boolean { canEnterPip(): boolean {
return setPipEnabled$.observed; return setPipEnabled$.observed;
@@ -27,4 +81,32 @@ window.controls = {
if (!setPipEnabled$.observed) throw new Error("No call is running"); if (!setPipEnabled$.observed) throw new Error("No call is running");
setPipEnabled$.next(false); setPipEnabled$.next(false);
}, },
setAvailableAudioDevices(devices: OutputDevice[]): void {
logger.info("setAvailableAudioDevices called from native:", devices);
availableOutputDevices$.next(devices);
},
setAudioDevice(id: string): void {
logger.info("setAudioDevice called from native", id);
outputDevice$.next(id);
},
setAudioEnabled(enabled: boolean): void {
logger.info("setAudioEnabled called from native:", enabled);
if (!setAudioEnabled$.observed)
throw new Error(
"Output controls are disabled. No setAudioEnabled$ observer",
);
setAudioEnabled$.next(enabled);
},
// wrappers for the deprecated controls fields
setOutputEnabled(enabled: boolean): void {
this.setAudioEnabled(enabled);
},
setAvailableOutputDevices(devices: OutputDevice[]): void {
this.setAvailableAudioDevices(devices);
},
setOutputDevice(id: string): void {
this.setAudioDevice(id);
},
}; };
+54 -48
View File
@@ -6,58 +6,70 @@ Please see LICENSE in the repository root for full details.
*/ */
import { useEffect, useMemo } from "react"; import { useEffect, useMemo } from "react";
import { logger } from "matrix-js-sdk/lib/logger";
import { setLocalStorageItem, useLocalStorage } from "../useLocalStorage"; import {
import { type UrlParams, getUrlParams, useUrlParams } from "../UrlParams"; setLocalStorageItemReactive,
useLocalStorage,
} from "../useLocalStorage";
import { getUrlParams } from "../UrlParams";
import { E2eeType } from "./e2eeType"; import { E2eeType } from "./e2eeType";
import { useClient } from "../ClientContext"; import { useClient } from "../ClientContext";
/**
* This setter will update the state for all `useRoomSharedKey` hooks
* if the password is different from the one in local storage or if its not yet in the local storage.
*/
export function saveKeyForRoom(roomId: string, password: string): void { export function saveKeyForRoom(roomId: string, password: string): void {
setLocalStorageItem(getRoomSharedKeyLocalStorageKey(roomId), password); if (
localStorage.getItem(getRoomSharedKeyLocalStorageKey(roomId)) !== password
)
setLocalStorageItemReactive(
getRoomSharedKeyLocalStorageKey(roomId),
password,
);
} }
const getRoomSharedKeyLocalStorageKey = (roomId: string): string => const getRoomSharedKeyLocalStorageKey = (roomId: string): string =>
`room-shared-key-${roomId}`; `room-shared-key-${roomId}`;
const useInternalRoomSharedKey = (roomId: string): string | null => { /**
const key = getRoomSharedKeyLocalStorageKey(roomId); * An upto-date shared key for the room. Either from local storage or the value from `setInitialValue`.
const roomSharedKey = useLocalStorage(key)[0]; * @param roomId
* @param setInitialValue The value we get from the URL. The hook will overwrite the local storage value with this.
* @returns [roomSharedKey, setRoomSharedKey] like a react useState hook.
*/
const useRoomSharedKey = (
roomId: string,
setInitialValue?: string,
): [string | null, setKey: (key: string) => void] => {
const [roomSharedKey, setRoomSharedKey] = useLocalStorage(
getRoomSharedKeyLocalStorageKey(roomId),
);
useEffect(() => {
// If setInitialValue is available, update the local storage (usually the password from the url).
// This will update roomSharedKey but wont update the returned value since
// that already defaults to setInitialValue.
if (setInitialValue) setRoomSharedKey(setInitialValue);
}, [setInitialValue, setRoomSharedKey]);
return roomSharedKey; // make sure we never return the initial null value from `useLocalStorage`
return [setInitialValue ?? roomSharedKey, setRoomSharedKey];
}; };
export function getKeyForRoom(roomId: string): string | null { export function getKeyForRoom(roomId: string): string | null {
saveKeyFromUrlParams(getUrlParams()); const { roomId: urlRoomId, password } = getUrlParams();
const key = getRoomSharedKeyLocalStorageKey(roomId); if (roomId !== urlRoomId)
return localStorage.getItem(key); logger.warn(
"requested key for a roomId which is not the current call room id (from the URL)",
roomId,
urlRoomId,
);
return (
password ?? localStorage.getItem(getRoomSharedKeyLocalStorageKey(roomId))
);
} }
function saveKeyFromUrlParams(urlParams: UrlParams): void {
if (!urlParams.password || !urlParams.roomId) return;
// Take the key from the URL and save it.
// It's important to always use the room ID specified in the URL
// when saving keys rather than whatever the current room ID might be,
// in case we've moved to a different room but the URL hasn't changed.
saveKeyForRoom(urlParams.roomId, urlParams.password);
}
/**
* Extracts the room password from the URL if one is present, saving it in localstorage
* and returning it in a tuple with the corresponding room ID from the URL.
* @returns A tuple of the roomId and password from the URL if the URL has both,
* otherwise [undefined, undefined]
*/
const useKeyFromUrl = (): [string, string] | [undefined, undefined] => {
const urlParams = useUrlParams();
useEffect(() => saveKeyFromUrlParams(urlParams), [urlParams]);
return urlParams.roomId && urlParams.password
? [urlParams.roomId, urlParams.password]
: [undefined, undefined];
};
export type Unencrypted = { kind: E2eeType.NONE }; export type Unencrypted = { kind: E2eeType.NONE };
export type SharedSecret = { kind: E2eeType.SHARED_KEY; secret: string }; export type SharedSecret = { kind: E2eeType.SHARED_KEY; secret: string };
export type PerParticipantE2EE = { kind: E2eeType.PER_PARTICIPANT }; export type PerParticipantE2EE = { kind: E2eeType.PER_PARTICIPANT };
@@ -66,12 +78,11 @@ export type EncryptionSystem = Unencrypted | SharedSecret | PerParticipantE2EE;
export function useRoomEncryptionSystem(roomId: string): EncryptionSystem { export function useRoomEncryptionSystem(roomId: string): EncryptionSystem {
const { client } = useClient(); const { client } = useClient();
// make sure we've extracted the key from the URL first const [storedPassword] = useRoomSharedKey(
// (and we still need to take the value it returns because getRoomSharedKeyLocalStorageKey(roomId),
// the effect won't run in time for it to save to localstorage in getKeyForRoom(roomId) ?? undefined,
// time for us to read it out again). );
const [urlRoomId, passwordFromUrl] = useKeyFromUrl();
const storedPassword = useInternalRoomSharedKey(roomId);
const room = client?.getRoom(roomId); const room = client?.getRoom(roomId);
const e2eeSystem = <EncryptionSystem>useMemo(() => { const e2eeSystem = <EncryptionSystem>useMemo(() => {
if (!room) return { kind: E2eeType.NONE }; if (!room) return { kind: E2eeType.NONE };
@@ -80,15 +91,10 @@ export function useRoomEncryptionSystem(roomId: string): EncryptionSystem {
kind: E2eeType.SHARED_KEY, kind: E2eeType.SHARED_KEY,
secret: storedPassword, secret: storedPassword,
}; };
if (urlRoomId === roomId)
return {
kind: E2eeType.SHARED_KEY,
secret: passwordFromUrl,
};
if (room.hasEncryptionStateEvent()) { if (room.hasEncryptionStateEvent()) {
return { kind: E2eeType.PER_PARTICIPANT }; return { kind: E2eeType.PER_PARTICIPANT };
} }
return { kind: E2eeType.NONE }; return { kind: E2eeType.NONE };
}, [passwordFromUrl, room, roomId, storedPassword, urlRoomId]); }, [room, storedPassword]);
return e2eeSystem; return e2eeSystem;
} }
+18 -14
View File
@@ -6,28 +6,32 @@ Please see LICENSE in the repository root for full details.
*/ */
import classNames from "classnames"; import classNames from "classnames";
import { type FormEventHandler, forwardRef, type ReactNode } from "react"; import {
type FC,
type Ref,
type FormEventHandler,
type ReactNode,
} from "react";
import styles from "./Form.module.css"; import styles from "./Form.module.css";
interface FormProps { interface FormProps {
ref?: Ref<HTMLFormElement>;
className: string; className: string;
onSubmit: FormEventHandler<HTMLFormElement>; onSubmit: FormEventHandler<HTMLFormElement>;
children: ReactNode[]; children: ReactNode[];
} }
export const Form = forwardRef<HTMLFormElement, FormProps>( export const Form: FC<FormProps> = ({ ref, children, className, onSubmit }) => {
({ children, className, onSubmit }, ref) => { return (
return ( <form
<form onSubmit={onSubmit}
onSubmit={onSubmit} className={classNames(styles.form, className)}
className={classNames(styles.form, className)} ref={ref}
ref={ref} >
> {children}
{children} </form>
</form> );
); };
},
);
Form.displayName = "Form"; Form.displayName = "Form";
+23 -24
View File
@@ -18,23 +18,22 @@ import {
type ComponentType, type ComponentType,
type Dispatch, type Dispatch,
type FC, type FC,
type LegacyRef,
type ReactNode, type ReactNode,
type Ref,
type SetStateAction, type SetStateAction,
createContext, createContext,
forwardRef,
memo, memo,
useContext, use,
useCallback,
useEffect, useEffect,
useMemo, useMemo,
useRef, useRef,
useState, useState,
useSyncExternalStore,
} from "react"; } from "react";
import useMeasure from "react-use-measure"; import useMeasure from "react-use-measure";
import classNames from "classnames"; import classNames from "classnames";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { useObservableEagerState } from "observable-hooks";
import { fromEvent, map, startWith } from "rxjs";
import styles from "./Grid.module.css"; import styles from "./Grid.module.css";
import { useMergedRefs } from "../useMergedRefs"; import { useMergedRefs } from "../useMergedRefs";
@@ -124,7 +123,7 @@ interface LayoutContext {
const LayoutContext = createContext<LayoutContext | null>(null); const LayoutContext = createContext<LayoutContext | null>(null);
function useLayoutContext(): LayoutContext { function useLayoutContext(): LayoutContext {
const context = useContext(LayoutContext); const context = use(LayoutContext);
if (context === null) if (context === null)
throw new Error("useUpdateLayout called outside a Grid layout context"); throw new Error("useUpdateLayout called outside a Grid layout context");
return context; return context;
@@ -156,13 +155,8 @@ export function useVisibleTiles(callback: VisibleTilesCallback): void {
); );
} }
const windowHeightObservable$ = fromEvent(window, "resize").pipe(
startWith(null),
map(() => window.innerHeight),
);
export interface LayoutProps<LayoutModel, TileModel, R extends HTMLElement> { export interface LayoutProps<LayoutModel, TileModel, R extends HTMLElement> {
ref: LegacyRef<R>; ref?: Ref<R>;
model: LayoutModel; model: LayoutModel;
/** /**
* Component creating an invisible "slot" for a tile to go in. * Component creating an invisible "slot" for a tile to go in.
@@ -171,7 +165,7 @@ export interface LayoutProps<LayoutModel, TileModel, R extends HTMLElement> {
} }
export interface TileProps<Model, R extends HTMLElement> { export interface TileProps<Model, R extends HTMLElement> {
ref: LegacyRef<R>; ref?: Ref<R>;
className?: string; className?: string;
style?: ComponentProps<typeof animated.div>["style"]; style?: ComponentProps<typeof animated.div>["style"];
/** /**
@@ -262,7 +256,13 @@ export function Grid<
const [gridRoot, gridRef2] = useState<HTMLElement | null>(null); const [gridRoot, gridRef2] = useState<HTMLElement | null>(null);
const gridRef = useMergedRefs<HTMLElement>(gridRef1, gridRef2); const gridRef = useMergedRefs<HTMLElement>(gridRef1, gridRef2);
const windowHeight = useObservableEagerState(windowHeightObservable$); const windowHeight = useSyncExternalStore(
useCallback((onChange) => {
window.addEventListener("resize", onChange);
return (): void => window.removeEventListener("resize", onChange);
}, []),
useCallback(() => window.innerHeight, []),
);
const [layoutRoot, setLayoutRoot] = useState<HTMLElement | null>(null); const [layoutRoot, setLayoutRoot] = useState<HTMLElement | null>(null);
const [generation, setGeneration] = useState<number | null>(null); const [generation, setGeneration] = useState<number | null>(null);
const [visibleTilesCallback, setVisibleTilesCallback] = const [visibleTilesCallback, setVisibleTilesCallback] =
@@ -297,14 +297,13 @@ export function Grid<
// render of Grid causes a re-render of Layout, which in turn re-renders Grid // render of Grid causes a re-render of Layout, which in turn re-renders Grid
const LayoutMemo = useMemo( const LayoutMemo = useMemo(
() => () =>
memo( memo(function LayoutMemo({
forwardRef< ref,
LayoutRef, Layout,
LayoutMemoProps<LayoutModel, TileModel, LayoutRef> ...props
>(function LayoutMemo({ Layout, ...props }, ref): ReactNode { }: LayoutMemoProps<LayoutModel, TileModel, LayoutRef>): ReactNode {
return <Layout {...props} ref={ref} />; return <Layout {...props} ref={ref} />;
}), }),
),
[], [],
); );
@@ -532,14 +531,14 @@ export function Grid<
className={classNames(className, styles.grid)} className={classNames(className, styles.grid)}
style={style} style={style}
> >
<LayoutContext.Provider value={context}> <LayoutContext value={context}>
<LayoutMemo <LayoutMemo
ref={setLayoutRoot} ref={setLayoutRoot}
Layout={Layout} Layout={Layout}
model={model} model={model}
Slot={Slot} Slot={Slot}
/> />
</LayoutContext.Provider> </LayoutContext>
{tileTransitions((spring, { id, model, onDrag, width, height }) => ( {tileTransitions((spring, { id, model, onDrag, width, height }) => (
<TileWrapper <TileWrapper
key={id} key={id}
+10 -5
View File
@@ -5,7 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type CSSProperties, forwardRef, useCallback, useMemo } from "react"; import {
type CSSProperties,
type ReactNode,
useCallback,
useMemo,
} from "react";
import { distinctUntilChanged } from "rxjs"; import { distinctUntilChanged } from "rxjs";
import { useObservableEagerState } from "observable-hooks"; import { useObservableEagerState } from "observable-hooks";
@@ -33,7 +38,7 @@ export const makeGridLayout: CallLayout<GridLayoutModel> = ({
// The "fixed" (non-scrolling) part of the layout is where the spotlight tile // The "fixed" (non-scrolling) part of the layout is where the spotlight tile
// lives // lives
fixed: forwardRef(function GridLayoutFixed({ model, Slot }, ref) { fixed: function GridLayoutFixed({ ref, model, Slot }): ReactNode {
useUpdateLayout(); useUpdateLayout();
const alignment = useObservableEagerState( const alignment = useObservableEagerState(
useInitial(() => useInitial(() =>
@@ -68,10 +73,10 @@ export const makeGridLayout: CallLayout<GridLayoutModel> = ({
)} )}
</div> </div>
); );
}), },
// The scrolling part of the layout is where all the grid tiles live // The scrolling part of the layout is where all the grid tiles live
scrolling: forwardRef(function GridLayout({ model, Slot }, ref) { scrolling: function GridLayout({ ref, model, Slot }): ReactNode {
useUpdateLayout(); useUpdateLayout();
useVisibleTiles(model.setVisibleTiles); useVisibleTiles(model.setVisibleTiles);
const { width, height: minHeight } = useObservableEagerState(minBounds$); const { width, height: minHeight } = useObservableEagerState(minBounds$);
@@ -98,5 +103,5 @@ export const makeGridLayout: CallLayout<GridLayoutModel> = ({
))} ))}
</div> </div>
); );
}), },
}); });
+7 -6
View File
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { forwardRef, useCallback, useMemo } from "react"; import { type ReactNode, useCallback, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks"; import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames"; import classNames from "classnames";
@@ -13,6 +13,7 @@ import { type OneOnOneLayout as OneOnOneLayoutModel } from "../state/CallViewMod
import { type CallLayout, arrangeTiles } from "./CallLayout"; import { type CallLayout, arrangeTiles } from "./CallLayout";
import styles from "./OneOnOneLayout.module.css"; import styles from "./OneOnOneLayout.module.css";
import { type DragCallback, useUpdateLayout } from "./Grid"; import { type DragCallback, useUpdateLayout } from "./Grid";
import { useBehavior } from "../useBehavior";
/** /**
* An implementation of the "one-on-one" layout, in which the remote participant * An implementation of the "one-on-one" layout, in which the remote participant
@@ -24,15 +25,15 @@ export const makeOneOnOneLayout: CallLayout<OneOnOneLayoutModel> = ({
}) => ({ }) => ({
scrollingOnTop: false, scrollingOnTop: false,
fixed: forwardRef(function OneOnOneLayoutFixed(_props, ref) { fixed: function OneOnOneLayoutFixed({ ref }): ReactNode {
useUpdateLayout(); useUpdateLayout();
return <div ref={ref} />; return <div ref={ref} />;
}), },
scrolling: forwardRef(function OneOnOneLayoutScrolling({ model, Slot }, ref) { scrolling: function OneOnOneLayoutScrolling({ ref, model, Slot }): ReactNode {
useUpdateLayout(); useUpdateLayout();
const { width, height } = useObservableEagerState(minBounds$); const { width, height } = useObservableEagerState(minBounds$);
const pipAlignmentValue = useObservableEagerState(pipAlignment$); const pipAlignmentValue = useBehavior(pipAlignment$);
const { tileWidth, tileHeight } = useMemo( const { tileWidth, tileHeight } = useMemo(
() => arrangeTiles(width, height, 1), () => arrangeTiles(width, height, 1),
[width, height], [width, height],
@@ -66,5 +67,5 @@ export const makeOneOnOneLayout: CallLayout<OneOnOneLayoutModel> = ({
</Slot> </Slot>
</div> </div>
); );
}), },
}); });
+13 -11
View File
@@ -5,13 +5,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { forwardRef, useCallback } from "react"; import { type ReactNode, useCallback } from "react";
import { useObservableEagerState } from "observable-hooks";
import { type SpotlightExpandedLayout as SpotlightExpandedLayoutModel } from "../state/CallViewModel"; import { type SpotlightExpandedLayout as SpotlightExpandedLayoutModel } from "../state/CallViewModel";
import { type CallLayout } from "./CallLayout"; import { type CallLayout } from "./CallLayout";
import { type DragCallback, useUpdateLayout } from "./Grid"; import { type DragCallback, useUpdateLayout } from "./Grid";
import styles from "./SpotlightExpandedLayout.module.css"; import styles from "./SpotlightExpandedLayout.module.css";
import { useBehavior } from "../useBehavior";
/** /**
* An implementation of the "expanded spotlight" layout, in which the spotlight * An implementation of the "expanded spotlight" layout, in which the spotlight
@@ -22,10 +22,11 @@ export const makeSpotlightExpandedLayout: CallLayout<
> = ({ pipAlignment$ }) => ({ > = ({ pipAlignment$ }) => ({
scrollingOnTop: true, scrollingOnTop: true,
fixed: forwardRef(function SpotlightExpandedLayoutFixed( fixed: function SpotlightExpandedLayoutFixed({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
return ( return (
@@ -37,14 +38,15 @@ export const makeSpotlightExpandedLayout: CallLayout<
/> />
</div> </div>
); );
}), },
scrolling: forwardRef(function SpotlightExpandedLayoutScrolling( scrolling: function SpotlightExpandedLayoutScrolling({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
const pipAlignmentValue = useObservableEagerState(pipAlignment$); const pipAlignmentValue = useBehavior(pipAlignment$);
const onDragPip: DragCallback = useCallback( const onDragPip: DragCallback = useCallback(
({ xRatio, yRatio }) => ({ xRatio, yRatio }) =>
@@ -69,5 +71,5 @@ export const makeSpotlightExpandedLayout: CallLayout<
)} )}
</div> </div>
); );
}), },
}); });
+11 -9
View File
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { forwardRef } from "react"; import { type ReactNode } from "react";
import { useObservableEagerState } from "observable-hooks"; import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames"; import classNames from "classnames";
@@ -24,10 +24,11 @@ export const makeSpotlightLandscapeLayout: CallLayout<
> = ({ minBounds$ }) => ({ > = ({ minBounds$ }) => ({
scrollingOnTop: false, scrollingOnTop: false,
fixed: forwardRef(function SpotlightLandscapeLayoutFixed( fixed: function SpotlightLandscapeLayoutFixed({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
useObservableEagerState(minBounds$); useObservableEagerState(minBounds$);
@@ -43,12 +44,13 @@ export const makeSpotlightLandscapeLayout: CallLayout<
<div className={styles.grid} /> <div className={styles.grid} />
</div> </div>
); );
}), },
scrolling: forwardRef(function SpotlightLandscapeLayoutScrolling( scrolling: function SpotlightLandscapeLayoutScrolling({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
useVisibleTiles(model.setVisibleTiles); useVisibleTiles(model.setVisibleTiles);
useObservableEagerState(minBounds$); useObservableEagerState(minBounds$);
@@ -69,5 +71,5 @@ export const makeSpotlightLandscapeLayout: CallLayout<
</div> </div>
</div> </div>
); );
}), },
}); });
+13 -11
View File
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type CSSProperties, forwardRef } from "react"; import { type ReactNode, type CSSProperties } from "react";
import { useObservableEagerState } from "observable-hooks"; import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames"; import classNames from "classnames";
@@ -13,6 +13,7 @@ import { type CallLayout, arrangeTiles } from "./CallLayout";
import { type SpotlightPortraitLayout as SpotlightPortraitLayoutModel } from "../state/CallViewModel"; import { type SpotlightPortraitLayout as SpotlightPortraitLayoutModel } from "../state/CallViewModel";
import styles from "./SpotlightPortraitLayout.module.css"; import styles from "./SpotlightPortraitLayout.module.css";
import { useUpdateLayout, useVisibleTiles } from "./Grid"; import { useUpdateLayout, useVisibleTiles } from "./Grid";
import { useBehavior } from "../useBehavior";
interface GridCSSProperties extends CSSProperties { interface GridCSSProperties extends CSSProperties {
"--grid-gap": string; "--grid-gap": string;
@@ -30,10 +31,11 @@ export const makeSpotlightPortraitLayout: CallLayout<
> = ({ minBounds$ }) => ({ > = ({ minBounds$ }) => ({
scrollingOnTop: false, scrollingOnTop: false,
fixed: forwardRef(function SpotlightPortraitLayoutFixed( fixed: function SpotlightPortraitLayoutFixed({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
return ( return (
@@ -47,12 +49,13 @@ export const makeSpotlightPortraitLayout: CallLayout<
</div> </div>
</div> </div>
); );
}), },
scrolling: forwardRef(function SpotlightPortraitLayoutScrolling( scrolling: function SpotlightPortraitLayoutScrolling({
{ model, Slot },
ref, ref,
) { model,
Slot,
}): ReactNode {
useUpdateLayout(); useUpdateLayout();
useVisibleTiles(model.setVisibleTiles); useVisibleTiles(model.setVisibleTiles);
const { width } = useObservableEagerState(minBounds$); const { width } = useObservableEagerState(minBounds$);
@@ -63,8 +66,7 @@ export const makeSpotlightPortraitLayout: CallLayout<
width, width,
model.grid.length, model.grid.length,
); );
const withIndicators = const withIndicators = useBehavior(model.spotlight.media$).length > 1;
useObservableEagerState(model.spotlight.media$).length > 1;
return ( return (
<div <div
@@ -90,5 +92,5 @@ export const makeSpotlightPortraitLayout: CallLayout<
</div> </div>
</div> </div>
); );
}), },
}); });
+12 -8
View File
@@ -37,12 +37,14 @@ import { Form } from "../form/Form";
import { AnalyticsNotice } from "../analytics/AnalyticsNotice"; import { AnalyticsNotice } from "../analytics/AnalyticsNotice";
import { E2eeType } from "../e2ee/e2eeType"; import { E2eeType } from "../e2ee/e2eeType";
import { useOptInAnalytics } from "../settings/settings"; import { useOptInAnalytics } from "../settings/settings";
import { useUrlParams } from "../UrlParams";
interface Props { interface Props {
client: MatrixClient; client: MatrixClient;
} }
export const RegisteredView: FC<Props> = ({ client }) => { export const RegisteredView: FC<Props> = ({ client }) => {
const { header } = useUrlParams();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error>(); const [error, setError] = useState<Error>();
const [optInAnalytics] = useOptInAnalytics(); const [optInAnalytics] = useOptInAnalytics();
@@ -114,14 +116,16 @@ export const RegisteredView: FC<Props> = ({ client }) => {
return ( return (
<> <>
<div className={commonStyles.container}> <div className={commonStyles.container}>
<Header> {header === "standard" && (
<LeftNav> <Header>
<HeaderLogo /> <LeftNav>
</LeftNav> <HeaderLogo />
<RightNav> </LeftNav>
<UserMenuContainer /> <RightNav>
</RightNav> <UserMenuContainer />
</Header> </RightNav>
</Header>
)}
<main className={commonStyles.main}> <main className={commonStyles.main}>
<HeaderLogo className={commonStyles.logo} /> <HeaderLogo className={commonStyles.logo} />
<Heading size="lg" weight="semibold"> <Heading size="lg" weight="semibold">
+12 -8
View File
@@ -34,9 +34,11 @@ import { Config } from "../config/Config";
import { E2eeType } from "../e2ee/e2eeType"; import { E2eeType } from "../e2ee/e2eeType";
import { useOptInAnalytics } from "../settings/settings"; import { useOptInAnalytics } from "../settings/settings";
import { ExternalLink, Link } from "../button/Link"; import { ExternalLink, Link } from "../button/Link";
import { useUrlParams } from "../UrlParams";
export const UnauthenticatedView: FC = () => { export const UnauthenticatedView: FC = () => {
const { setClient } = useClient(); const { setClient } = useClient();
const { header } = useUrlParams();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error>(); const [error, setError] = useState<Error>();
const [optInAnalytics] = useOptInAnalytics(); const [optInAnalytics] = useOptInAnalytics();
@@ -141,14 +143,16 @@ export const UnauthenticatedView: FC = () => {
return ( return (
<> <>
<div className={commonStyles.container}> <div className={commonStyles.container}>
<Header> {header === "standard" && (
<LeftNav> <Header>
<HeaderLogo /> <LeftNav>
</LeftNav> <HeaderLogo />
<RightNav hideMobile> </LeftNav>
<UserMenuContainer /> <RightNav hideMobile>
</RightNav> <UserMenuContainer />
</Header> </RightNav>
</Header>
)}
<main className={commonStyles.main}> <main className={commonStyles.main}>
<HeaderLogo className={commonStyles.logo} /> <HeaderLogo className={commonStyles.logo} />
<Heading size="lg" weight="semibold"> <Heading size="lg" weight="semibold">
+3 -2
View File
@@ -81,8 +81,9 @@ function sortRooms(client: MatrixClient, rooms: Room[]): Room[] {
} }
const roomIsJoinable = (room: Room): boolean => { const roomIsJoinable = (room: Room): boolean => {
if (!room.hasEncryptionStateEvent() && !getKeyForRoom(room.roomId)) { const password = getKeyForRoom(room.roomId);
// if we have an non encrypted room (no encryption state event) we need a locally stored shared key. if (!room.hasEncryptionStateEvent() && !password) {
// if we have a non encrypted room (no encryption state event) we need a locally stored shared key.
// in case this key also does not exists we cannot join the room. // in case this key also does not exists we cannot join the room.
return false; return false;
} }
+10
View File
@@ -45,6 +45,9 @@ layer(compound);
--small-drop-shadow: 0px 1.2px 2.4px 0px rgba(0, 0, 0, 0.15); --small-drop-shadow: 0px 1.2px 2.4px 0px rgba(0, 0, 0, 0.15);
--subtle-drop-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05); --subtle-drop-shadow: 0px 1px 2px 0px rgba(16, 24, 40, 0.05);
--background-gradient: url("graphics/backgroundGradient.svg"); --background-gradient: url("graphics/backgroundGradient.svg");
--call-view-overlay-layer: 1;
--call-view-header-footer-layer: 2;
} }
:root, :root,
@@ -71,6 +74,13 @@ body {
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
} }
/* This prohibits the view to scroll for pages smaller than 122px in width
we use this for mobile pip webviews */
.no-scroll-body {
position: fixed;
width: 100%;
}
/* We use this to not render the page at all until we know the theme.*/ /* We use this to not render the page at all until we know the theme.*/
.no-theme { .no-theme {
opacity: 0; opacity: 0;
+74 -80
View File
@@ -9,10 +9,10 @@ import {
type ChangeEvent, type ChangeEvent,
type FC, type FC,
type ForwardedRef, type ForwardedRef,
forwardRef,
type ReactNode, type ReactNode,
useId, useId,
type JSX, type JSX,
type Ref,
} from "react"; } from "react";
import classNames from "classnames"; import classNames from "classnames";
@@ -54,6 +54,7 @@ function Field({ children, className }: FieldProps): JSX.Element {
} }
interface InputFieldProps { interface InputFieldProps {
ref?: Ref<HTMLInputElement | HTMLTextAreaElement>;
label?: string; label?: string;
type: string; type: string;
prefix?: string; prefix?: string;
@@ -78,88 +79,81 @@ interface InputFieldProps {
onChange?: (event: ChangeEvent<HTMLInputElement>) => void; onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
} }
export const InputField = forwardRef< export const InputField: FC<InputFieldProps> = ({
HTMLInputElement | HTMLTextAreaElement, ref,
InputFieldProps id,
>( label,
( className,
{ type,
id, checked,
label, prefix,
className, suffix,
type, description,
checked, disabled,
prefix, min,
suffix, ...rest
description, }) => {
disabled, const descriptionId = useId();
min,
...rest
},
ref,
) => {
const descriptionId = useId();
return ( return (
<Field <Field
className={classNames( className={classNames(
type === "checkbox" ? styles.checkboxField : styles.inputField, type === "checkbox" ? styles.checkboxField : styles.inputField,
{ {
[styles.prefix]: !!prefix, [styles.prefix]: !!prefix,
[styles.disabled]: disabled, [styles.disabled]: disabled,
}, },
className, className,
)} )}
> >
{prefix && <span>{prefix}</span>} {prefix && <span>{prefix}</span>}
{type === "textarea" ? ( {type === "textarea" ? (
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
<textarea <textarea
id={id} id={id}
ref={ref as ForwardedRef<HTMLTextAreaElement>} ref={ref as ForwardedRef<HTMLTextAreaElement>}
disabled={disabled} disabled={disabled}
aria-describedby={descriptionId} aria-describedby={descriptionId}
{...rest} {...rest}
/> />
) : ( ) : (
<input <input
id={id} id={id}
ref={ref as ForwardedRef<HTMLInputElement>} ref={ref as ForwardedRef<HTMLInputElement>}
type={type} type={type}
checked={checked} checked={checked}
disabled={disabled} disabled={disabled}
aria-describedby={descriptionId} aria-describedby={descriptionId}
min={min} min={min}
{...rest} {...rest}
/> />
)} )}
<label htmlFor={id}> <label htmlFor={id}>
{type === "checkbox" && ( {type === "checkbox" && (
<div className={styles.checkbox}> <div className={styles.checkbox}>
<CheckIcon /> <CheckIcon />
</div> </div>
)}
{label}
</label>
{suffix && <span>{suffix}</span>}
{description && (
<p
id={descriptionId}
className={
label
? styles.description
: classNames(styles.description, styles.noLabel)
}
>
{description}
</p>
)} )}
</Field> {label}
); </label>
}, {suffix && <span>{suffix}</span>}
); {description && (
<p
id={descriptionId}
className={
label
? styles.description
: classNames(styles.description, styles.noLabel)
}
>
{description}
</p>
)}
</Field>
);
};
InputField.displayName = "InputField"; InputField.displayName = "InputField";
+27 -14
View File
@@ -17,12 +17,14 @@ import { type ReactNode } from "react";
import { useTracks } from "@livekit/components-react"; import { useTracks } from "@livekit/components-react";
import { testAudioContext } from "../useAudioContext.test"; import { testAudioContext } from "../useAudioContext.test";
import * as MediaDevicesContext from "./MediaDevicesContext"; import * as MediaDevicesContext from "../MediaDevicesContext";
import { MatrixAudioRenderer } from "./MatrixAudioRenderer"; import { MatrixAudioRenderer } from "./MatrixAudioRenderer";
import { mockTrack } from "../utils/test"; import { mockMediaDevices, mockTrack } from "../utils/test";
export const TestAudioContextConstructor = vi.fn(() => testAudioContext); export const TestAudioContextConstructor = vi.fn(() => testAudioContext);
const MediaDevicesProvider = MediaDevicesContext.MediaDevicesContext.Provider;
beforeEach(() => { beforeEach(() => {
vi.stubGlobal("AudioContext", TestAudioContextConstructor); vi.stubGlobal("AudioContext", TestAudioContextConstructor);
}); });
@@ -51,18 +53,24 @@ vi.mocked(useTracks).mockReturnValue(tracks);
it("should render for member", () => { it("should render for member", () => {
const { container, queryAllByTestId } = render( const { container, queryAllByTestId } = render(
<MatrixAudioRenderer <MediaDevicesProvider value={mockMediaDevices({})}>
members={[{ sender: "test", deviceId: "123" }] as CallMembership[]} <MatrixAudioRenderer
/>, members={[{ sender: "test", deviceId: "123" }] as CallMembership[]}
/>
</MediaDevicesProvider>,
); );
expect(container).toBeTruthy(); expect(container).toBeTruthy();
expect(queryAllByTestId("audio")).toHaveLength(1); expect(queryAllByTestId("audio")).toHaveLength(1);
}); });
it("should not render without member", () => { it("should not render without member", () => {
const memberships = [
{ sender: "othermember", deviceId: "123" },
] as CallMembership[];
const { container, queryAllByTestId } = render( const { container, queryAllByTestId } = render(
<MatrixAudioRenderer <MediaDevicesProvider value={mockMediaDevices({})}>
members={[{ sender: "othermember", deviceId: "123" }] as CallMembership[]} <MatrixAudioRenderer members={memberships} />
/>, </MediaDevicesProvider>,
); );
expect(container).toBeTruthy(); expect(container).toBeTruthy();
expect(queryAllByTestId("audio")).toHaveLength(0); expect(queryAllByTestId("audio")).toHaveLength(0);
@@ -70,9 +78,11 @@ it("should not render without member", () => {
it("should not setup audioContext gain and pan if there is no need to.", () => { it("should not setup audioContext gain and pan if there is no need to.", () => {
render( render(
<MatrixAudioRenderer <MediaDevicesProvider value={mockMediaDevices({})}>
members={[{ sender: "test", deviceId: "123" }] as CallMembership[]} <MatrixAudioRenderer
/>, members={[{ sender: "test", deviceId: "123" }] as CallMembership[]}
/>
</MediaDevicesProvider>,
); );
const audioTrack = tracks[0].publication.track! as RemoteAudioTrack; const audioTrack = tracks[0].publication.track! as RemoteAudioTrack;
@@ -84,15 +94,18 @@ it("should not setup audioContext gain and pan if there is no need to.", () => {
expect(testAudioContext.gain.gain.value).toEqual(1); expect(testAudioContext.gain.gain.value).toEqual(1);
expect(testAudioContext.pan.pan.value).toEqual(0); expect(testAudioContext.pan.pan.value).toEqual(0);
}); });
it("should setup audioContext gain and pan", () => { it("should setup audioContext gain and pan", () => {
vi.spyOn(MediaDevicesContext, "useEarpieceAudioConfig").mockReturnValue({ vi.spyOn(MediaDevicesContext, "useEarpieceAudioConfig").mockReturnValue({
pan: 1, pan: 1,
volume: 0.1, volume: 0.1,
}); });
render( render(
<MatrixAudioRenderer <MediaDevicesProvider value={mockMediaDevices({})}>
members={[{ sender: "test", deviceId: "123" }] as CallMembership[]} <MatrixAudioRenderer
/>, members={[{ sender: "test", deviceId: "123" }] as CallMembership[]}
/>
</MediaDevicesProvider>,
); );
const audioTrack = tracks[0].publication.track! as RemoteAudioTrack; const audioTrack = tracks[0].publication.track! as RemoteAudioTrack;
+14 -2
View File
@@ -14,11 +14,13 @@ import {
type AudioTrackProps, type AudioTrackProps,
} from "@livekit/components-react"; } from "@livekit/components-react";
import { type CallMembership } from "matrix-js-sdk/lib/matrixrtc"; import { type CallMembership } from "matrix-js-sdk/lib/matrixrtc";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger as rootLogger } from "matrix-js-sdk/lib/logger";
import { useEarpieceAudioConfig } from "./MediaDevicesContext"; import { useEarpieceAudioConfig } from "../MediaDevicesContext";
import { useReactiveState } from "../useReactiveState"; import { useReactiveState } from "../useReactiveState";
import * as controls from "../controls";
const logger = rootLogger.getChild("[MatrixAudioRenderer]");
export interface MatrixAudioRendererProps { export interface MatrixAudioRendererProps {
/** /**
* The list of participants to render audio for. * The list of participants to render audio for.
@@ -59,6 +61,7 @@ export function MatrixAudioRenderer({
); );
const loggedInvalidIdentities = useRef(new Set<string>()); const loggedInvalidIdentities = useRef(new Set<string>());
/** /**
* Log an invalid livekit track identity. * Log an invalid livekit track identity.
* A invalid identity is one that does not match any of the matrix rtc members. * A invalid identity is one that does not match any of the matrix rtc members.
@@ -96,6 +99,14 @@ export function MatrixAudioRenderer({
isValid isValid
); );
}); });
useEffect(() => {
if (!tracks.some((t) => !validIdentities.has(t.participant.identity))) {
logger.debug(
`All audio tracks have a matching matrix call member identity.`,
);
loggedInvalidIdentities.current.clear();
}
}, [tracks, validIdentities]);
// This component is also (in addition to the "only play audio for connected members" logic above) // This component is also (in addition to the "only play audio for connected members" logic above)
// responsible for mimicking earpiece audio on iPhones. // responsible for mimicking earpiece audio on iPhones.
@@ -204,6 +215,7 @@ function AudioTrackWithAudioNodes({
useContext ? [audioNodes.gain!, audioNodes.pan!] : [], useContext ? [audioNodes.gain!, audioNodes.pan!] : [],
); );
setTrackReady(true); setTrackReady(true);
controls.setPlaybackStarted();
}, [audioContext, audioNodes, setTrackReady, trackReady, trackRef]); }, [audioContext, audioNodes, setTrackReady, trackReady, trackRef]);
return ( return (
-321
View File
@@ -1,321 +0,0 @@
/*
Copyright 2023, 2024 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import {
type FC,
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
useState,
type JSX,
} from "react";
import { createMediaDeviceObserver } from "@livekit/components-core";
import { map, startWith } from "rxjs";
import { useObservableEagerState } from "observable-hooks";
import { logger } from "matrix-js-sdk/lib/logger";
import {
useSetting,
audioInput as audioInputSetting,
audioOutput as audioOutputSetting,
videoInput as videoInputSetting,
alwaysShowIphoneEarpiece as alwaysShowIphoneEarpieceSetting,
type Setting,
} from "../settings/settings";
export const EARPIECE_CONFIG_ID = "earpiece-id";
export type DeviceLabel =
| { type: "name"; name: string }
| { type: "number"; number: number }
| { type: "earpiece" }
| { type: "default"; name: string | null };
export interface MediaDevice {
/**
* A map from available device IDs to labels.
*/
available: Map<string, DeviceLabel>;
selectedId: string | undefined;
/**
* An additional device configuration that makes us use only one channel of the
* output device and a reduced volume.
*/
useAsEarpiece: boolean | undefined;
/**
* The group ID of the selected device.
*/
// This is exposed sort of ad-hoc because it's only needed for knowing when to
// restart the tracks of default input devices, and ideally this behavior
// would be encapsulated somehow…
selectedGroupId: string | undefined;
select: (deviceId: string) => void;
}
export interface MediaDevices {
audioInput: MediaDevice;
audioOutput: MediaDevice;
videoInput: MediaDevice;
startUsingDeviceNames: () => void;
stopUsingDeviceNames: () => void;
}
function useMediaDevice(
kind: MediaDeviceKind,
setting: Setting<string | undefined>,
usingNames: boolean,
): MediaDevice {
// Make sure we don't needlessly reset to a device observer without names,
// once permissions are already given
const [alwaysShowIphoneEarpice] = useSetting(alwaysShowIphoneEarpieceSetting);
const hasRequestedPermissions = useRef(false);
const requestPermissions = usingNames || hasRequestedPermissions.current;
hasRequestedPermissions.current ||= usingNames;
// We use a bare device observer here rather than one of the fancy device
// selection hooks from @livekit/components-react, because
// useMediaDeviceSelect expects a room or track, which we don't have here, and
// useMediaDevices provides no way to request device names.
// Tragically, the only way to get device names out of LiveKit is to specify a
// kind, which then results in multiple permissions requests.
const deviceObserver$ = useMemo(
() =>
createMediaDeviceObserver(
kind,
() => logger.error("Error creating MediaDeviceObserver"),
requestPermissions,
).pipe(startWith([])),
[kind, requestPermissions],
);
const available = useObservableEagerState(
useMemo(
() =>
deviceObserver$.pipe(
map((availableRaw) => {
// Sometimes browsers (particularly Firefox) can return multiple device
// entries for the exact same device ID; using a map deduplicates them
let available = new Map<string, DeviceLabel>(
availableRaw.map((d, i) => [
d.deviceId,
d.label
? { type: "name", name: d.label }
: { type: "number", number: i + 1 },
]),
);
// Create a virtual default audio output for browsers that don't have one.
// Its device ID must be the empty string because that's what setSinkId
// recognizes.
// We also create this if we do not have any available devices, so that
// we can use the default or the earpiece.
const showEarpiece =
navigator.userAgent.match("iPhone") || alwaysShowIphoneEarpice;
if (
kind === "audiooutput" &&
!available.has("") &&
!available.has("default") &&
(available.size || showEarpiece)
)
available = new Map([
["", { type: "default", name: availableRaw[0]?.label || null }],
...available,
]);
if (kind === "audiooutput" && showEarpiece)
// On IPhones we have to create a virtual earpiece device, because
// the earpiece is not available as a device ID.
available = new Map([
...available,
[EARPIECE_CONFIG_ID, { type: "earpiece" }],
]);
// Note: creating virtual default input devices would be another problem
// entirely, because requesting a media stream from deviceId "" won't
// automatically track the default device.
return available;
}),
),
[alwaysShowIphoneEarpice, deviceObserver$, kind],
),
);
const [preferredId, setPreferredId] = useSetting(setting);
const [asEarpice, setAsEarpiece] = useState(false);
const selectedId = useMemo(() => {
if (available.size) {
// If the preferred device is available, use it. Or if every available
// device ID is falsy, the browser is probably just being paranoid about
// fingerprinting and we should still try using the preferred device.
// Worst case it is not available and the browser will gracefully fall
// back to some other device for us when requesting the media stream.
// Otherwise, select the first available device.
return (preferredId !== undefined && available.has(preferredId)) ||
(available.size === 1 && available.has(""))
? preferredId
: available.keys().next().value;
}
return undefined;
}, [available, preferredId]);
const selectedGroupId = useObservableEagerState(
useMemo(
() =>
deviceObserver$.pipe(
map(
(availableRaw) =>
availableRaw.find((d) => d.deviceId === selectedId)?.groupId,
),
),
[deviceObserver$, selectedId],
),
);
const select = useCallback(
(id: string) => {
if (id === EARPIECE_CONFIG_ID) {
setAsEarpiece(true);
} else {
setAsEarpiece(false);
setPreferredId(id);
}
},
[setPreferredId],
);
return useMemo(
() => ({
available,
selectedId,
useAsEarpiece: asEarpice,
selectedGroupId,
select,
}),
[available, selectedId, asEarpice, selectedGroupId, select],
);
}
export const deviceStub: MediaDevice = {
available: new Map(),
selectedId: undefined,
selectedGroupId: undefined,
select: () => {},
useAsEarpiece: false,
};
export const devicesStub: MediaDevices = {
audioInput: deviceStub,
audioOutput: deviceStub,
videoInput: deviceStub,
startUsingDeviceNames: () => {},
stopUsingDeviceNames: () => {},
};
export const MediaDevicesContext = createContext<MediaDevices>(devicesStub);
interface Props {
children: JSX.Element;
}
export const MediaDevicesProvider: FC<Props> = ({ children }) => {
// Counts the number of callers currently using device names.
const [numCallersUsingNames, setNumCallersUsingNames] = useState(0);
const usingNames = numCallersUsingNames > 0;
const audioInput = useMediaDevice(
"audioinput",
audioInputSetting,
usingNames,
);
const audioOutput = useMediaDevice(
"audiooutput",
audioOutputSetting,
usingNames,
);
const videoInput = useMediaDevice(
"videoinput",
videoInputSetting,
usingNames,
);
const startUsingDeviceNames = useCallback(
() => setNumCallersUsingNames((n) => n + 1),
[setNumCallersUsingNames],
);
const stopUsingDeviceNames = useCallback(
() => setNumCallersUsingNames((n) => n - 1),
[setNumCallersUsingNames],
);
const context: MediaDevices = useMemo(
() => ({
audioInput,
audioOutput,
videoInput,
startUsingDeviceNames,
stopUsingDeviceNames,
}),
[
audioInput,
audioOutput,
videoInput,
startUsingDeviceNames,
stopUsingDeviceNames,
],
);
return (
<MediaDevicesContext.Provider value={context}>
{children}
</MediaDevicesContext.Provider>
);
};
export const useMediaDevices = (): MediaDevices =>
useContext(MediaDevicesContext);
/**
* React hook that requests for the media devices context to be populated with
* real device names while this component is mounted. This is not done by
* default because it may involve requesting additional permissions from the
* user.
*/
export const useMediaDeviceNames = (
context: MediaDevices,
enabled = true,
): void =>
useEffect(() => {
if (enabled) {
context.startUsingDeviceNames();
return context.stopUsingDeviceNames;
}
}, [context, enabled]);
/**
* A convenience hook to get the audio node configuration for the earpiece.
* It will check the `useAsEarpiece` of the `audioOutput` device and return
* the appropriate pan and volume values.
*
* @returns pan and volume values for the earpiece audio node configuration.
*/
export const useEarpieceAudioConfig = (): {
pan: number;
volume: number;
} => {
const { audioOutput } = useMediaDevices();
// We use only the right speaker (pan = 1) for the earpiece.
// This mimics the behavior of the native earpiece speaker (only the top speaker on an iPhone)
const pan = useMemo(
() => (audioOutput.useAsEarpiece ? 1 : 0),
[audioOutput.useAsEarpiece],
);
// We also do lower the volume by a factor of 10 to optimize for the usecase where
// a user is holding the phone to their ear.
const volume = useMemo(
() => (audioOutput.useAsEarpiece ? 0.1 : 1),
[audioOutput.useAsEarpiece],
);
return { pan, volume };
};
+10 -7
View File
@@ -10,7 +10,14 @@ import {
supportsBackgroundProcessors, supportsBackgroundProcessors,
type BackgroundOptions, type BackgroundOptions,
} from "@livekit/track-processors"; } from "@livekit/track-processors";
import { createContext, type FC, useContext, useEffect, useMemo } from "react"; import {
createContext,
type FC,
type JSX,
use,
useEffect,
useMemo,
} from "react";
import { type LocalVideoTrack } from "livekit-client"; import { type LocalVideoTrack } from "livekit-client";
import { import {
@@ -27,7 +34,7 @@ type ProcessorState = {
const ProcessorContext = createContext<ProcessorState | undefined>(undefined); const ProcessorContext = createContext<ProcessorState | undefined>(undefined);
export function useTrackProcessor(): ProcessorState { export function useTrackProcessor(): ProcessorState {
const state = useContext(ProcessorContext); const state = use(ProcessorContext);
if (state === undefined) if (state === undefined)
throw new Error( throw new Error(
"useTrackProcessor must be used within a ProcessorProvider", "useTrackProcessor must be used within a ProcessorProvider",
@@ -76,9 +83,5 @@ export const ProcessorProvider: FC<Props> = ({ children }) => {
[supported, blurActivated, blur], [supported, blurActivated, blur],
); );
return ( return <ProcessorContext value={processorState}>{children}</ProcessorContext>;
<ProcessorContext.Provider value={processorState}>
{children}
</ProcessorContext.Provider>
);
}; };
+152 -118
View File
@@ -14,21 +14,23 @@ import {
type RoomOptions, type RoomOptions,
Track, Track,
} from "livekit-client"; } from "livekit-client";
import { useEffect, useMemo, useRef } from "react"; import { useEffect, useRef } from "react";
import E2EEWorker from "livekit-client/e2ee-worker?worker"; import E2EEWorker from "livekit-client/e2ee-worker?worker";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
import { useObservable, useObservableEagerState } from "observable-hooks"; import { useObservable, useObservableEagerState } from "observable-hooks";
import { map } from "rxjs"; import {
map,
NEVER,
type Observable,
type Subscription,
switchMap,
} from "rxjs";
import { defaultLiveKitOptions } from "./options"; import { defaultLiveKitOptions } from "./options";
import { type SFUConfig } from "./openIDSFU"; import { type SFUConfig } from "./openIDSFU";
import { type MuteStates } from "../room/MuteStates"; import { type MuteStates } from "../room/MuteStates";
import { import { useMediaDevices } from "../MediaDevicesContext";
type MediaDevice,
type MediaDevices,
useMediaDevices,
} from "./MediaDevicesContext";
import { import {
type ECConnectionState, type ECConnectionState,
useECConnectionState, useECConnectionState,
@@ -40,8 +42,11 @@ import {
useTrackProcessor, useTrackProcessor,
useTrackProcessorSync, useTrackProcessorSync,
} from "./TrackProcessorContext"; } from "./TrackProcessorContext";
import { useInitial } from "../useInitial";
import { observeTrackReference$ } from "../state/MediaViewModel"; import { observeTrackReference$ } from "../state/MediaViewModel";
import { useUrlParams } from "../UrlParams";
import { useInitial } from "../useInitial";
import { getValue } from "../utils/observable";
import { type SelectedDevice } from "../state/MediaDevices";
interface UseLivekitResult { interface UseLivekitResult {
livekitRoom?: Room; livekitRoom?: Room;
@@ -54,27 +59,87 @@ export function useLivekit(
sfuConfig: SFUConfig | undefined, sfuConfig: SFUConfig | undefined,
e2eeSystem: EncryptionSystem, e2eeSystem: EncryptionSystem,
): UseLivekitResult { ): UseLivekitResult {
const e2eeOptions = useMemo((): E2EEManagerOptions | undefined => { const { controlledAudioDevices } = useUrlParams();
if (e2eeSystem.kind === E2eeType.NONE) return undefined;
const initialMuteStates = useInitial(() => muteStates);
const devices = useMediaDevices();
const initialAudioInputId = useInitial(
() => getValue(devices.audioInput.selected$)?.id,
);
// Store if audio/video are currently updating. If to prohibit unnecessary calls
// to setMicrophoneEnabled/setCameraEnabled
const audioMuteUpdating = useRef(false);
const videoMuteUpdating = useRef(false);
// Store the current button mute state that gets passed to this hook via props.
// We need to store it for awaited code that relies on the current value.
const buttonEnabled = useRef({
audio: initialMuteStates.audio.enabled,
video: initialMuteStates.video.enabled,
});
const { processor } = useTrackProcessor();
// Only ever create the room once via useInitial.
const room = useInitial(() => {
logger.info("[LivekitRoom] Create LiveKit room");
let e2ee: E2EEManagerOptions | undefined;
if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) { if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) {
logger.info("Created MatrixKeyProvider (per participant)"); logger.info("Created MatrixKeyProvider (per participant)");
return { e2ee = {
keyProvider: new MatrixKeyProvider(), keyProvider: new MatrixKeyProvider(),
worker: new E2EEWorker(), worker: new E2EEWorker(),
}; };
} else if (e2eeSystem.kind === E2eeType.SHARED_KEY && e2eeSystem.secret) { } else if (e2eeSystem.kind === E2eeType.SHARED_KEY && e2eeSystem.secret) {
logger.info("Created ExternalE2EEKeyProvider (shared key)"); logger.info("Created ExternalE2EEKeyProvider (shared key)");
e2ee = {
return {
keyProvider: new ExternalE2EEKeyProvider(), keyProvider: new ExternalE2EEKeyProvider(),
worker: new E2EEWorker(), worker: new E2EEWorker(),
}; };
} }
}, [e2eeSystem]);
const roomOptions: RoomOptions = {
...defaultLiveKitOptions,
videoCaptureDefaults: {
...defaultLiveKitOptions.videoCaptureDefaults,
deviceId: getValue(devices.videoInput.selected$)?.id,
processor,
},
audioCaptureDefaults: {
...defaultLiveKitOptions.audioCaptureDefaults,
deviceId: initialAudioInputId,
},
audioOutput: {
// When using controlled audio devices, we don't want to set the
// deviceId here, because it will be set by the native app.
// (also the id does not need to match a browser device id)
deviceId: controlledAudioDevices
? undefined
: getValue(devices.audioOutput.selected$)?.id,
},
e2ee,
};
// We have to create the room manually here due to a bug inside
// @livekit/components-react. JSON.stringify() is used in deps of a
// useEffect() with an argument that references itself, if E2EE is enabled
const room = new Room(roomOptions);
room.setE2EEEnabled(e2eeSystem.kind !== E2eeType.NONE).catch((e) => {
logger.error("Failed to set E2EE enabled on room", e);
});
return room;
});
// Setup and update the keyProvider which was create by `createRoom`
useEffect(() => { useEffect(() => {
if (e2eeSystem.kind === E2eeType.NONE || !e2eeOptions) return; const e2eeOptions = room.options.e2ee;
if (
e2eeSystem.kind === E2eeType.NONE ||
!(e2eeOptions && "keyProvider" in e2eeOptions)
)
return;
if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) { if (e2eeSystem.kind === E2eeType.PER_PARTICIPANT) {
(e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession); (e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession);
@@ -85,65 +150,20 @@ export function useLivekit(
logger.error("Failed to set shared key for E2EE", e); logger.error("Failed to set shared key for E2EE", e);
}); });
} }
}, [e2eeOptions, e2eeSystem, rtcSession]); }, [room.options.e2ee, e2eeSystem, rtcSession]);
const initialMuteStates = useRef<MuteStates>(muteStates);
const devices = useMediaDevices();
const initialDevices = useRef<MediaDevices>(devices);
const { processor } = useTrackProcessor();
const initialProcessor = useInitial(() => processor);
const roomOptions = useMemo(
(): RoomOptions => ({
...defaultLiveKitOptions,
videoCaptureDefaults: {
...defaultLiveKitOptions.videoCaptureDefaults,
deviceId: initialDevices.current.videoInput.selectedId,
processor: initialProcessor,
},
audioCaptureDefaults: {
...defaultLiveKitOptions.audioCaptureDefaults,
deviceId: initialDevices.current.audioInput.selectedId,
},
audioOutput: {
deviceId: initialDevices.current.audioOutput.selectedId,
},
e2ee: e2eeOptions,
}),
[e2eeOptions, initialProcessor],
);
// Store if audio/video are currently updating. If to prohibit unnecessary calls
// to setMicrophoneEnabled/setCameraEnabled
const audioMuteUpdating = useRef(false);
const videoMuteUpdating = useRef(false);
// Store the current button mute state that gets passed to this hook via props.
// We need to store it for awaited code that relies on the current value.
const buttonEnabled = useRef({
audio: initialMuteStates.current.audio.enabled,
video: initialMuteStates.current.video.enabled,
});
// We have to create the room manually here due to a bug inside
// @livekit/components-react. JSON.stringify() is used in deps of a
// useEffect() with an argument that references itself, if E2EE is enabled
const room = useMemo(() => {
const r = new Room(roomOptions);
r.setE2EEEnabled(e2eeSystem.kind !== E2eeType.NONE).catch((e) => {
logger.error("Failed to set E2EE enabled on room", e);
});
return r;
}, [roomOptions, e2eeSystem]);
// Sync the requested track processors with LiveKit // Sync the requested track processors with LiveKit
useTrackProcessorSync( useTrackProcessorSync(
useObservableEagerState( useObservableEagerState(
useObservable( useObservable(
(room$) => (room$) =>
observeTrackReference$( room$.pipe(
room$.pipe(map(([room]) => room.localParticipant)), switchMap(([room]) =>
Track.Source.Camera, observeTrackReference$(
).pipe( room.localParticipant,
Track.Source.Camera,
),
),
map((trackRef) => { map((trackRef) => {
const track = trackRef?.publication?.track; const track = trackRef?.publication?.track;
return track instanceof LocalVideoTrack ? track : null; return track instanceof LocalVideoTrack ? track : null;
@@ -155,8 +175,8 @@ export function useLivekit(
); );
const connectionState = useECConnectionState( const connectionState = useECConnectionState(
initialDevices.current.audioInput.selectedId, initialAudioInputId,
initialMuteStates.current.audio.enabled, initialMuteStates.audio.enabled,
room, room,
sfuConfig, sfuConfig,
); );
@@ -304,63 +324,77 @@ export function useLivekit(
useEffect(() => { useEffect(() => {
// Sync the requested devices with LiveKit's devices // Sync the requested devices with LiveKit's devices
if (room !== undefined && connectionState === ConnectionState.Connected) { if (room !== undefined && connectionState === ConnectionState.Connected) {
const syncDevice = (kind: MediaDeviceKind, device: MediaDevice): void => { const syncDevice = (
const id = device.selectedId; kind: MediaDeviceKind,
selected$: Observable<SelectedDevice | undefined>,
// Detect if we're trying to use chrome's default device, in which case ): Subscription =>
// we need to to see if the default device has changed to a different device selected$.subscribe((device) => {
// by comparing the group ID of the device we're using against the group ID logger.info(
// of what the default device is *now*. "[LivekitRoom] syncDevice room.getActiveDevice(kind) !== d.id :",
// This is special-cased for only audio inputs because we need to dig around room.getActiveDevice(kind),
// in the LocalParticipant object for the track object and there's not a nice " !== ",
// way to do that generically. There is usually no OS-level default video capture device?.id,
// device anyway, and audio outputs work differently. );
if (
id === "default" &&
kind === "audioinput" &&
room.options.audioCaptureDefaults?.deviceId === "default"
) {
const activeMicTrack = Array.from(
room.localParticipant.audioTrackPublications.values(),
).find((d) => d.source === Track.Source.Microphone)?.track;
if ( if (
activeMicTrack && device !== undefined &&
// only restart if the stream is still running: LiveKit will detect room.getActiveDevice(kind) !== device.id
// when a track stops & restart appropriately, so this is not our job.
// Plus, we need to avoid restarting again if the track is already in
// the process of being restarted.
activeMicTrack.mediaStreamTrack.readyState !== "ended" &&
device.selectedGroupId !==
activeMicTrack.mediaStreamTrack.getSettings().groupId
) { ) {
// It's different, so restart the track, ie. cause Livekit to do another
// getUserMedia() call with deviceId: default to get the *new* default device.
// Note that room.switchActiveDevice() won't work: Livekit will ignore it because
// the deviceId hasn't changed (was & still is default).
room.localParticipant
.getTrackPublication(Track.Source.Microphone)
?.audioTrack?.restartTrack()
.catch((e) => {
logger.error(`Failed to restart audio device track`, e);
});
}
} else {
if (id !== undefined && room.getActiveDevice(kind) !== id) {
room room
.switchActiveDevice(kind, id) .switchActiveDevice(kind, device.id)
.catch((e) => .catch((e) =>
logger.error(`Failed to sync ${kind} device with LiveKit`, e), logger.error(`Failed to sync ${kind} device with LiveKit`, e),
); );
} }
} });
};
syncDevice("audioinput", devices.audioInput); const subscriptions = [
syncDevice("audiooutput", devices.audioOutput); syncDevice("audioinput", devices.audioInput.selected$),
syncDevice("videoinput", devices.videoInput); !controlledAudioDevices
? syncDevice("audiooutput", devices.audioOutput.selected$)
: undefined,
syncDevice("videoinput", devices.videoInput.selected$),
// Restart the audio input track whenever we detect that the active media
// device has changed to refer to a different hardware device. We do this
// for the sake of Chrome, which provides a "default" device that is meant
// to match the system's default audio input, whatever that may be.
// This is special-cased for only audio inputs because we need to dig around
// in the LocalParticipant object for the track object and there's not a nice
// way to do that generically. There is usually no OS-level default video capture
// device anyway, and audio outputs work differently.
devices.audioInput.selected$
.pipe(switchMap((device) => device?.hardwareDeviceChange$ ?? NEVER))
.subscribe(() => {
const activeMicTrack = Array.from(
room.localParticipant.audioTrackPublications.values(),
).find((d) => d.source === Track.Source.Microphone)?.track;
if (
activeMicTrack &&
// only restart if the stream is still running: LiveKit will detect
// when a track stops & restart appropriately, so this is not our job.
// Plus, we need to avoid restarting again if the track is already in
// the process of being restarted.
activeMicTrack.mediaStreamTrack.readyState !== "ended"
) {
// Restart the track, which will cause Livekit to do another
// getUserMedia() call with deviceId: default to get the *new* default device.
// Note that room.switchActiveDevice() won't work: Livekit will ignore it because
// the deviceId hasn't changed (was & still is default).
room.localParticipant
.getTrackPublication(Track.Source.Microphone)
?.audioTrack?.restartTrack()
.catch((e) => {
logger.error(`Failed to restart audio device track`, e);
});
}
}),
];
return (): void => {
for (const s of subscriptions) s?.unsubscribe();
};
} }
}, [room, devices, connectionState]); }, [room, devices, connectionState, controlledAudioDevices]);
return { return {
connState: connectionState, connState: connectionState,
+3 -2
View File
@@ -23,13 +23,14 @@ import {
import { App } from "./App"; import { App } from "./App";
import { init as initRageshake } from "./settings/rageshake"; import { init as initRageshake } from "./settings/rageshake";
import { Initializer } from "./initializer"; import { Initializer } from "./initializer";
import { AppViewModel } from "./state/AppViewModel";
window.setLKLogLevel = setLKLogLevel; window.setLKLogLevel = setLKLogLevel;
initRageshake().catch((e) => { initRageshake().catch((e) => {
logger.error("Failed to initialize rageshake", e); logger.error("Failed to initialize rageshake", e);
}); });
setLKLogLevel("warn"); setLKLogLevel("info");
setLKLogExtension((level, msg, context) => { setLKLogExtension((level, msg, context) => {
// we pass a synthetic logger name of "livekit" to the rageshake to make it easier to read // we pass a synthetic logger name of "livekit" to the rageshake to make it easier to read
global.mx_rage_logger.log(level, "livekit", msg, context); global.mx_rage_logger.log(level, "livekit", msg, context);
@@ -60,7 +61,7 @@ Initializer.initBeforeReact()
.then(() => { .then(() => {
root.render( root.render(
<StrictMode> <StrictMode>
<App /> <App vm={new AppViewModel()} />
</StrictMode>, </StrictMode>,
); );
}) })
+19 -16
View File
@@ -5,12 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base"; import {
SimpleSpanProcessor,
type SpanProcessor,
} from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { WebTracerProvider } from "@opentelemetry/sdk-trace-web"; import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
import opentelemetry, { type Tracer } from "@opentelemetry/api"; import opentelemetry, { type Tracer } from "@opentelemetry/api";
import { Resource } from "@opentelemetry/resources"; import { resourceFromAttributes } from "@opentelemetry/resources";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions"; import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { PosthogSpanProcessor } from "../analytics/PosthogSpanProcessor"; import { PosthogSpanProcessor } from "../analytics/PosthogSpanProcessor";
@@ -59,34 +62,34 @@ export class ElementCallOpenTelemetry {
collectorUrl: string | undefined, collectorUrl: string | undefined,
rageshakeUrl: string | undefined, rageshakeUrl: string | undefined,
) { ) {
// This is how we can make Jaeger show a reasonable service in the dropdown on the left. const spanProcessors: SpanProcessor[] = [];
const providerConfig = {
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: SERVICE_NAME,
}),
};
this._provider = new WebTracerProvider(providerConfig);
if (collectorUrl) { if (collectorUrl) {
logger.info("Enabling OTLP collector with URL " + collectorUrl); logger.info("Enabling OTLP collector with URL " + collectorUrl);
this.otlpExporter = new OTLPTraceExporter({ this.otlpExporter = new OTLPTraceExporter({
url: collectorUrl, url: collectorUrl,
}); });
this._provider.addSpanProcessor( spanProcessors.push(new SimpleSpanProcessor(this.otlpExporter));
new SimpleSpanProcessor(this.otlpExporter),
);
} else { } else {
logger.info("OTLP collector disabled"); logger.info("OTLP collector disabled");
} }
if (rageshakeUrl) { if (rageshakeUrl) {
this.rageshakeProcessor = new RageshakeSpanProcessor(); this.rageshakeProcessor = new RageshakeSpanProcessor();
this._provider.addSpanProcessor(this.rageshakeProcessor); spanProcessors.push(this.rageshakeProcessor);
} }
this._provider.addSpanProcessor(new PosthogSpanProcessor()); spanProcessors.push(new PosthogSpanProcessor());
opentelemetry.trace.setGlobalTracerProvider(this._provider);
this._provider = new WebTracerProvider({
resource: resourceFromAttributes({
// This is how we can make Jaeger show a reasonable service in the dropdown on the left.
[ATTR_SERVICE_NAME]: SERVICE_NAME,
}),
spanProcessors,
});
opentelemetry.trace.setGlobalTracerProvider(this._provider);
this._tracer = opentelemetry.trace.getTracer( this._tracer = opentelemetry.trace.getTracer(
// This is not the serviceName shown in jaeger // This is not the serviceName shown in jaeger
"my-element-call-otl-tracer", "my-element-call-otl-tracer",
+7 -7
View File
@@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details.
import { EventType, RelationType } from "matrix-js-sdk"; import { EventType, RelationType } from "matrix-js-sdk";
import { import {
createContext, createContext,
useContext, use,
type ReactNode, type ReactNode,
useCallback, useCallback,
useMemo, useMemo,
@@ -16,12 +16,12 @@ import {
} from "react"; } from "react";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { useObservableEagerState } from "observable-hooks";
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships";
import { useClientState } from "../ClientContext"; import { useClientState } from "../ClientContext";
import { ElementCallReactionEventType, type ReactionOption } from "."; import { ElementCallReactionEventType, type ReactionOption } from ".";
import { type CallViewModel } from "../state/CallViewModel"; import { type CallViewModel } from "../state/CallViewModel";
import { useBehavior } from "../useBehavior";
interface ReactionsSenderContextType { interface ReactionsSenderContextType {
supportsReactions: boolean; supportsReactions: boolean;
@@ -34,7 +34,7 @@ const ReactionsSenderContext = createContext<
>(undefined); >(undefined);
export const useReactionsSender = (): ReactionsSenderContextType => { export const useReactionsSender = (): ReactionsSenderContextType => {
const context = useContext(ReactionsSenderContext); const context = use(ReactionsSenderContext);
if (!context) { if (!context) {
throw new Error("useReactions must be used within a ReactionsProvider"); throw new Error("useReactions must be used within a ReactionsProvider");
} }
@@ -70,7 +70,7 @@ export const ReactionsSenderProvider = ({
[memberships, myUserId, myDeviceId], [memberships, myUserId, myDeviceId],
); );
const reactions = useObservableEagerState(vm.reactions$); const reactions = useBehavior(vm.reactions$);
const myReaction = useMemo( const myReaction = useMemo(
() => () =>
myMembershipIdentifier !== undefined myMembershipIdentifier !== undefined
@@ -79,7 +79,7 @@ export const ReactionsSenderProvider = ({
[myMembershipIdentifier, reactions], [myMembershipIdentifier, reactions],
); );
const handsRaised = useObservableEagerState(vm.handsRaised$); const handsRaised = useBehavior(vm.handsRaised$);
const myRaisedHand = useMemo( const myRaisedHand = useMemo(
() => () =>
myMembershipIdentifier !== undefined myMembershipIdentifier !== undefined
@@ -157,7 +157,7 @@ export const ReactionsSenderProvider = ({
); );
return ( return (
<ReactionsSenderContext.Provider <ReactionsSenderContext
value={{ value={{
supportsReactions, supportsReactions,
toggleRaisedHand, toggleRaisedHand,
@@ -165,6 +165,6 @@ export const ReactionsSenderProvider = ({
}} }}
> >
{children} {children}
</ReactionsSenderContext.Provider> </ReactionsSenderContext>
); );
}; };
+8 -4
View File
@@ -25,6 +25,7 @@ import { LinkButton } from "../button";
interface Props { interface Props {
client: MatrixClient; client: MatrixClient;
isPasswordlessUser: boolean; isPasswordlessUser: boolean;
hideHeader: boolean;
confineToRoom: boolean; confineToRoom: boolean;
endedCallId: string; endedCallId: string;
} }
@@ -32,6 +33,7 @@ interface Props {
export const CallEndedView: FC<Props> = ({ export const CallEndedView: FC<Props> = ({
client, client,
isPasswordlessUser, isPasswordlessUser,
hideHeader,
confineToRoom, confineToRoom,
endedCallId, endedCallId,
}) => { }) => {
@@ -133,10 +135,12 @@ export const CallEndedView: FC<Props> = ({
return ( return (
<> <>
<Header> {!hideHeader && (
<LeftNav>{!confineToRoom && <HeaderLogo />}</LeftNav> <Header>
<RightNav /> <LeftNav>{!confineToRoom && <HeaderLogo />}</LeftNav>
</Header> <RightNav />
</Header>
)}
<div className={styles.container}> <div className={styles.container}>
<main className={styles.main}> <main className={styles.main}>
<Heading size="xl" weight="semibold" className={styles.headline}> <Heading size="xl" weight="semibold" className={styles.headline}>
+67
View File
@@ -0,0 +1,67 @@
.overlay {
position: fixed;
z-index: var(--call-view-overlay-layer);
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: var(--cpd-space-2x);
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.overlay[data-show="true"] {
animation: fade-in 200ms;
}
@keyframes fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
display: none;
}
}
.overlay[data-show="false"] {
animation: fade-out 130ms forwards;
content-visibility: hidden;
pointer-events: none;
}
.overlay::before {
content: "";
position: absolute;
z-index: -1;
inset: 0;
background: var(--cpd-color-bg-canvas-default);
opacity: 0.94;
}
.icon {
margin-block-end: var(--cpd-space-4x);
background: var(--cpd-color-alpha-gray-600);
color: var(--cpd-color-icon-primary);
}
.overlay > h2 {
text-align: center;
margin: 0;
}
.overlay > p {
text-align: center;
}
.spacer {
min-height: var(--cpd-space-32x);
}
+44
View File
@@ -0,0 +1,44 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { type FC } from "react";
import { BigIcon, Button, Heading, Text } from "@vector-im/compound-web";
import { VoiceCallIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import { useTranslation } from "react-i18next";
import styles from "./EarpieceOverlay.module.css";
interface Props {
show: boolean;
onBackToVideoPressed?: (() => void) | null;
}
export const EarpieceOverlay: FC<Props> = ({ show, onBackToVideoPressed }) => {
const { t } = useTranslation();
return (
<div className={styles.overlay} data-show={show}>
<BigIcon className={styles.icon}>
<VoiceCallIcon aria-hidden />
</BigIcon>
<Heading as="h2" weight="semibold" size="md">
{t("handset.overlay_title")}
</Heading>
<Text>{t("handset.overlay_description")}</Text>
<Button
kind="primary"
size="sm"
onClick={() => {
onBackToVideoPressed?.();
}}
>
{t("handset.overlay_back_button")}
</Button>
{/* This spacer is used to give the overlay an offset to the top. */}
<div className={styles.spacer} />
</div>
);
};
+9 -4
View File
@@ -16,11 +16,12 @@ import {
} from "react"; } from "react";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { import {
ErrorIcon, ErrorSolidIcon,
HostIcon, HostIcon,
OfflineIcon, OfflineIcon,
WebBrowserIcon, WebBrowserIcon,
} from "@vector-im/compound-design-tokens/assets/web/icons"; } from "@vector-im/compound-design-tokens/assets/web/icons";
import { Button } from "@vector-im/compound-web";
import { import {
ConnectionLostError, ConnectionLostError,
@@ -63,7 +64,7 @@ const ErrorPage: FC<ErrorPageProps> = ({
icon = WebBrowserIcon; icon = WebBrowserIcon;
break; break;
default: default:
icon = ErrorIcon; icon = ErrorSolidIcon;
} }
const actions: { label: string; onClick: () => void }[] = []; const actions: { label: string; onClick: () => void }[] = [];
@@ -93,9 +94,13 @@ const ErrorPage: FC<ErrorPageProps> = ({
</p> </p>
{actions && {actions &&
actions.map((action, index) => ( actions.map((action, index) => (
<button onClick={action.onClick} key={`action${index}`}> <Button
kind="secondary"
onClick={action.onClick}
key={`action${index}`}
>
{action.label} {action.label}
</button> </Button>
))} ))}
</ErrorView> </ErrorView>
</FullScreenView> </FullScreenView>
+23 -16
View File
@@ -16,7 +16,6 @@ import {
import { render, waitFor, screen } from "@testing-library/react"; import { render, waitFor, screen } from "@testing-library/react";
import { type MatrixClient, JoinRule, type RoomState } from "matrix-js-sdk"; import { type MatrixClient, JoinRule, type RoomState } from "matrix-js-sdk";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
import { of } from "rxjs";
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import { type RelationsContainer } from "matrix-js-sdk/lib/models/relations-container"; import { type RelationsContainer } from "matrix-js-sdk/lib/models/relations-container";
@@ -29,8 +28,10 @@ import { useAudioContext } from "../useAudioContext";
import { ActiveCall } from "./InCallView"; import { ActiveCall } from "./InCallView";
import { import {
flushPromises, flushPromises,
mockEmitter,
mockMatrixRoom, mockMatrixRoom,
mockMatrixRoomMember, mockMatrixRoomMember,
mockMediaDevices,
mockRtcMembership, mockRtcMembership,
MockRTCSession, MockRTCSession,
} from "../utils/test"; } from "../utils/test";
@@ -39,6 +40,9 @@ import { type WidgetHelpers } from "../widget";
import { LazyEventEmitter } from "../LazyEventEmitter"; import { LazyEventEmitter } from "../LazyEventEmitter";
import { MatrixRTCFocusMissingError } from "../utils/errors"; import { MatrixRTCFocusMissingError } from "../utils/errors";
import { ProcessorProvider } from "../livekit/TrackProcessorContext"; import { ProcessorProvider } from "../livekit/TrackProcessorContext";
import { MediaDevicesContext } from "../MediaDevicesContext";
import { HeaderStyle } from "../UrlParams";
import { constant } from "../state/Behavior";
vi.mock("../soundUtils"); vi.mock("../soundUtils");
vi.mock("../useAudioContext"); vi.mock("../useAudioContext");
@@ -129,6 +133,7 @@ function createGroupCallView(
getMxcAvatarUrl: () => null, getMxcAvatarUrl: () => null,
getCanonicalAlias: () => null, getCanonicalAlias: () => null,
currentState: { currentState: {
...mockEmitter(),
getJoinRule: () => JoinRule.Invite, getJoinRule: () => JoinRule.Invite,
} as Partial<RoomState> as RoomState, } as Partial<RoomState> as RoomState,
}); });
@@ -136,7 +141,7 @@ function createGroupCallView(
room, room,
localRtcMember, localRtcMember,
[], [],
).withMemberships(of([])); ).withMemberships(constant([]));
rtcSession.joined = joined; rtcSession.joined = joined;
const muteState = { const muteState = {
audio: { enabled: false }, audio: { enabled: false },
@@ -145,20 +150,22 @@ function createGroupCallView(
const { getByText } = render( const { getByText } = render(
<BrowserRouter> <BrowserRouter>
<TooltipProvider> <TooltipProvider>
<ProcessorProvider> <MediaDevicesContext value={mockMediaDevices({})}>
<GroupCallView <ProcessorProvider>
client={client} <GroupCallView
isPasswordlessUser={false} client={client}
confineToRoom={false} isPasswordlessUser={false}
preload={false} confineToRoom={false}
skipLobby={false} preload={false}
hideHeader={true} skipLobby={false}
rtcSession={rtcSession as unknown as MatrixRTCSession} header={HeaderStyle.Standard}
isJoined={joined} rtcSession={rtcSession as unknown as MatrixRTCSession}
muteStates={muteState} isJoined={joined}
widget={widget} muteStates={muteState}
/> widget={widget}
</ProcessorProvider> />
</ProcessorProvider>
</MediaDevicesContext>
</TooltipProvider> </TooltipProvider>
</BrowserRouter>, </BrowserRouter>,
); );
+39 -25
View File
@@ -39,35 +39,39 @@ import { useProfile } from "../profile/useProfile";
import { findDeviceByName } from "../utils/media"; import { findDeviceByName } from "../utils/media";
import { ActiveCall } from "./InCallView"; import { ActiveCall } from "./InCallView";
import { MUTE_PARTICIPANT_COUNT, type MuteStates } from "./MuteStates"; import { MUTE_PARTICIPANT_COUNT, type MuteStates } from "./MuteStates";
import { useMediaDevices } from "../livekit/MediaDevicesContext"; import { useMediaDevices } from "../MediaDevicesContext";
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships"; import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships";
import { enterRTCSession, leaveRTCSession } from "../rtcSessionHelpers"; import { enterRTCSession, leaveRTCSession } from "../rtcSessionHelpers";
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement"; import {
saveKeyForRoom,
useRoomEncryptionSystem,
} from "../e2ee/sharedKeyManagement";
import { useRoomAvatar } from "./useRoomAvatar"; import { useRoomAvatar } from "./useRoomAvatar";
import { useRoomName } from "./useRoomName"; import { useRoomName } from "./useRoomName";
import { useJoinRule } from "./useJoinRule"; import { useJoinRule } from "./useJoinRule";
import { InviteModal } from "./InviteModal"; import { InviteModal } from "./InviteModal";
import { useUrlParams } from "../UrlParams"; import { HeaderStyle, useUrlParams } from "../UrlParams";
import { E2eeType } from "../e2ee/e2eeType"; import { E2eeType } from "../e2ee/e2eeType";
import { useAudioContext } from "../useAudioContext"; import { useAudioContext } from "../useAudioContext";
import { callEventAudioSounds } from "./CallEventAudioRenderer"; import { callEventAudioSounds } from "./CallEventAudioRenderer";
import { useLatest } from "../useLatest"; import { useLatest } from "../useLatest";
import { usePageTitle } from "../usePageTitle"; import { usePageTitle } from "../usePageTitle";
import { import {
ConnectionLostError,
E2EENotSupportedError, E2EENotSupportedError,
ElementCallError, ElementCallError,
ErrorCode,
RTCSessionError,
UnknownCallError, UnknownCallError,
} from "../utils/errors.ts"; } from "../utils/errors.ts";
import { GroupCallErrorBoundary } from "./GroupCallErrorBoundary.tsx"; import { GroupCallErrorBoundary } from "./GroupCallErrorBoundary.tsx";
import { import {
useNewMembershipManager as useNewMembershipManagerSetting, useNewMembershipManager as useNewMembershipManagerSetting,
useExperimentalToDeviceTransport as useExperimentalToDeviceTransportSetting, useExperimentalToDeviceTransport as useExperimentalToDeviceTransportSetting,
muteAllAudio as muteAllAudioSetting,
useSetting, useSetting,
} from "../settings/settings"; } from "../settings/settings";
import { useTypedEventEmitter } from "../useEvents"; import { useTypedEventEmitter } from "../useEvents";
import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts";
import { useAppBarTitle } from "../AppBar.tsx";
import { useBehavior } from "../useBehavior.ts";
declare global { declare global {
interface Window { interface Window {
@@ -81,7 +85,7 @@ interface Props {
confineToRoom: boolean; confineToRoom: boolean;
preload: boolean; preload: boolean;
skipLobby: boolean; skipLobby: boolean;
hideHeader: boolean; header: HeaderStyle;
rtcSession: MatrixRTCSession; rtcSession: MatrixRTCSession;
isJoined: boolean; isJoined: boolean;
muteStates: MuteStates; muteStates: MuteStates;
@@ -94,7 +98,7 @@ export const GroupCallView: FC<Props> = ({
confineToRoom, confineToRoom,
preload, preload,
skipLobby, skipLobby,
hideHeader, header,
rtcSession, rtcSession,
isJoined, isJoined,
muteStates, muteStates,
@@ -104,9 +108,9 @@ export const GroupCallView: FC<Props> = ({
const [externalError, setExternalError] = useState<ElementCallError | null>( const [externalError, setExternalError] = useState<ElementCallError | null>(
null, null,
); );
const [muteAllAudio] = useSetting(muteAllAudioSetting);
const memberships = useMatrixRTCSessionMemberships(rtcSession); const memberships = useMatrixRTCSessionMemberships(rtcSession);
const muteAllAudio = useBehavior(muteAllAudio$);
const leaveSoundContext = useLatest( const leaveSoundContext = useLatest(
useAudioContext({ useAudioContext({
sounds: callEventAudioSounds, sounds: callEventAudioSounds,
@@ -128,6 +132,16 @@ export const GroupCallView: FC<Props> = ({
}; };
}, []); }, []);
// This CSS is the only way we could find to not make element call scroll for
// viewport sizes smaller than 122px width. (It is actually this exact number: 122px
// tested on different devices...)
useEffect(() => {
document.body.classList.add("no-scroll-body");
return (): void => {
document.body.classList.remove("no-scroll-body");
};
}, []);
useEffect(() => { useEffect(() => {
window.rtcSession = rtcSession; window.rtcSession = rtcSession;
return (): void => { return (): void => {
@@ -138,14 +152,7 @@ export const GroupCallView: FC<Props> = ({
useTypedEventEmitter( useTypedEventEmitter(
rtcSession, rtcSession,
MatrixRTCSessionEvent.MembershipManagerError, MatrixRTCSessionEvent.MembershipManagerError,
(error) => { (error) => setExternalError(new ConnectionLostError()),
setExternalError(
new RTCSessionError(
ErrorCode.MEMBERSHIP_MANAGER_UNRECOVERABLE,
error.message ?? error,
),
);
},
); );
useEffect(() => { useEffect(() => {
// Sanity check the room object // Sanity check the room object
@@ -166,7 +173,14 @@ export const GroupCallView: FC<Props> = ({
useExperimentalToDeviceTransportSetting, useExperimentalToDeviceTransportSetting,
); );
// Save the password once we start the groupCallView
const { password: passwordFromUrl } = useUrlParams();
useEffect(() => {
if (passwordFromUrl) saveKeyForRoom(room.roomId, passwordFromUrl);
}, [passwordFromUrl, room.roomId]);
usePageTitle(roomName); usePageTitle(roomName);
useAppBarTitle(roomName);
const matrixInfo = useMemo((): MatrixInfo => { const matrixInfo = useMemo((): MatrixInfo => {
return { return {
@@ -187,8 +201,7 @@ export const GroupCallView: FC<Props> = ({
[memberships], [memberships],
); );
const deviceContext = useMediaDevices(); const mediaDevices = useMediaDevices();
const latestDevices = useLatest(deviceContext);
const latestMuteStates = useLatest(muteStates); const latestMuteStates = useLatest(muteStates);
const enterRTCSessionOrError = useCallback( const enterRTCSessionOrError = useCallback(
@@ -240,7 +253,7 @@ export const GroupCallView: FC<Props> = ({
logger.debug( logger.debug(
`Found audio input ID ${deviceId} for name ${audioInput}`, `Found audio input ID ${deviceId} for name ${audioInput}`,
); );
latestDevices.current!.audioInput.select(deviceId); mediaDevices.audioInput.select(deviceId);
} }
} }
@@ -254,7 +267,7 @@ export const GroupCallView: FC<Props> = ({
logger.debug( logger.debug(
`Found video input ID ${deviceId} for name ${videoInput}`, `Found video input ID ${deviceId} for name ${videoInput}`,
); );
latestDevices.current!.videoInput.select(deviceId); mediaDevices.videoInput.select(deviceId);
} }
} }
}; };
@@ -296,7 +309,7 @@ export const GroupCallView: FC<Props> = ({
preload, preload,
skipLobby, skipLobby,
perParticipantE2EE, perParticipantE2EE,
latestDevices, mediaDevices,
latestMuteStates, latestMuteStates,
enterRTCSessionOrError, enterRTCSessionOrError,
useNewMembershipManager, useNewMembershipManager,
@@ -412,7 +425,7 @@ export const GroupCallView: FC<Props> = ({
muteStates={muteStates} muteStates={muteStates}
onEnter={() => void enterRTCSessionOrError(rtcSession)} onEnter={() => void enterRTCSessionOrError(rtcSession)}
confineToRoom={confineToRoom} confineToRoom={confineToRoom}
hideHeader={hideHeader} hideHeader={header === HeaderStyle.None}
participantCount={participantCount} participantCount={participantCount}
onShareClick={onShareClick} onShareClick={onShareClick}
/> />
@@ -438,7 +451,7 @@ export const GroupCallView: FC<Props> = ({
rtcSession={rtcSession as MatrixRTCSession} rtcSession={rtcSession as MatrixRTCSession}
participantCount={participantCount} participantCount={participantCount}
onLeave={onLeave} onLeave={onLeave}
hideHeader={hideHeader} header={header}
muteStates={muteStates} muteStates={muteStates}
e2eeSystem={e2eeSystem} e2eeSystem={e2eeSystem}
//otelGroupCallMembership={otelGroupCallMembership} //otelGroupCallMembership={otelGroupCallMembership}
@@ -464,6 +477,7 @@ export const GroupCallView: FC<Props> = ({
endedCallId={rtcSession.room.roomId} endedCallId={rtcSession.room.roomId}
client={client} client={client}
isPasswordlessUser={isPasswordlessUser} isPasswordlessUser={isPasswordlessUser}
hideHeader={header === HeaderStyle.None}
confineToRoom={confineToRoom} confineToRoom={confineToRoom}
/> />
); );
+2 -2
View File
@@ -18,7 +18,7 @@ Please see LICENSE in the repository root for full details.
position: sticky; position: sticky;
flex-shrink: 0; flex-shrink: 0;
inset-block-start: 0; inset-block-start: 0;
z-index: 1; z-index: var(--call-view-header-footer-layer);
background: linear-gradient( background: linear-gradient(
0deg, 0deg,
rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0) 0%,
@@ -34,7 +34,7 @@ Please see LICENSE in the repository root for full details.
.footer { .footer {
position: sticky; position: sticky;
inset-block-end: 0; inset-block-end: 0;
z-index: 1; z-index: var(--call-view-header-footer-layer);
display: grid; display: grid;
grid-template-columns: grid-template-columns:
minmax(0, var(--inline-content-inset)) minmax(0, var(--inline-content-inset))
+42 -35
View File
@@ -31,6 +31,7 @@ import {
mockLocalParticipant, mockLocalParticipant,
mockMatrixRoom, mockMatrixRoom,
mockMatrixRoomMember, mockMatrixRoomMember,
mockMediaDevices,
mockRemoteParticipant, mockRemoteParticipant,
mockRtcMembership, mockRtcMembership,
type MockRTCSession, type MockRTCSession,
@@ -45,6 +46,8 @@ import {
import { ReactionsSenderProvider } from "../reactions/useReactionsSender"; import { ReactionsSenderProvider } from "../reactions/useReactionsSender";
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement"; import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
import { MatrixAudioRenderer } from "../livekit/MatrixAudioRenderer"; import { MatrixAudioRenderer } from "../livekit/MatrixAudioRenderer";
import { MediaDevicesContext } from "../MediaDevicesContext";
import { HeaderStyle } from "../UrlParams";
// vi.hoisted(() => { // vi.hoisted(() => {
// localStorage = {} as unknown as Storage; // localStorage = {} as unknown as Storage;
@@ -147,41 +150,43 @@ function createInCallView(): RenderResult & {
rtcSession.joined = true; rtcSession.joined = true;
const renderResult = render( const renderResult = render(
<BrowserRouter> <BrowserRouter>
<ReactionsSenderProvider <MediaDevicesContext value={mockMediaDevices({})}>
vm={vm} <ReactionsSenderProvider
rtcSession={rtcSession as unknown as MatrixRTCSession} vm={vm}
> rtcSession={rtcSession as unknown as MatrixRTCSession}
<TooltipProvider> >
<RoomContext.Provider value={livekitRoom}> <TooltipProvider>
<InCallView <RoomContext value={livekitRoom}>
client={client} <InCallView
hideHeader={true} client={client}
rtcSession={rtcSession as unknown as MatrixRTCSession} header={HeaderStyle.Standard}
muteStates={muteState} rtcSession={rtcSession as unknown as MatrixRTCSession}
vm={vm} muteStates={muteState}
matrixInfo={{ vm={vm}
userId: "", matrixInfo={{
displayName: "", userId: "",
avatarUrl: "", displayName: "",
roomId: "", avatarUrl: "",
roomName: "", roomId: "",
roomAlias: null, roomName: "",
roomAvatar: null, roomAlias: null,
e2eeSystem: { roomAvatar: null,
kind: E2eeType.NONE, e2eeSystem: {
}, kind: E2eeType.NONE,
}} },
livekitRoom={livekitRoom} }}
participantCount={0} livekitRoom={livekitRoom}
onLeave={function (): void { participantCount={0}
throw new Error("Function not implemented."); onLeave={function (): void {
}} throw new Error("Function not implemented.");
connState={ConnectionState.Connected} }}
onShareClick={null} connState={ConnectionState.Connected}
/> onShareClick={null}
</RoomContext.Provider> />
</TooltipProvider> </RoomContext>
</ReactionsSenderProvider> </TooltipProvider>
</ReactionsSenderProvider>
</MediaDevicesContext>
</BrowserRouter>, </BrowserRouter>,
); );
return { return {
@@ -239,6 +244,7 @@ describe("InCallView", () => {
queryByText("using to Device key transport"), queryByText("using to Device key transport"),
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
}); });
it("is not shown if setting is disabled", () => { it("is not shown if setting is disabled", () => {
useExperimentalToDeviceTransportSetting.setValue(false); useExperimentalToDeviceTransportSetting.setValue(false);
developerModeSetting.setValue(true); developerModeSetting.setValue(true);
@@ -250,6 +256,7 @@ describe("InCallView", () => {
queryByText("using to Device key transport"), queryByText("using to Device key transport"),
).not.toBeInTheDocument(); ).not.toBeInTheDocument();
}); });
it("is not shown if developer mode is disabled", () => { it("is not shown if developer mode is disabled", () => {
useExperimentalToDeviceTransportSetting.setValue(true); useExperimentalToDeviceTransportSetting.setValue(true);
developerModeSetting.setValue(false); developerModeSetting.setValue(false);
+127 -71
View File
@@ -6,29 +6,33 @@ Please see LICENSE in the repository root for full details.
*/ */
import { RoomContext, useLocalParticipant } from "@livekit/components-react"; import { RoomContext, useLocalParticipant } from "@livekit/components-react";
import { Text } from "@vector-im/compound-web"; import { IconButton, Text, Tooltip } from "@vector-im/compound-web";
import { ConnectionState, type Room } from "livekit-client"; import { ConnectionState, type Room } from "livekit-client";
import { type MatrixClient } from "matrix-js-sdk"; import { type MatrixClient } from "matrix-js-sdk";
import { import {
type FC, type FC,
type PointerEvent, type PointerEvent,
type PropsWithoutRef,
type TouchEvent, type TouchEvent,
forwardRef,
useCallback, useCallback,
useEffect, useEffect,
useMemo, useMemo,
useRef, useRef,
useState, useState,
type JSX, type JSX,
type ReactNode,
} from "react"; } from "react";
import useMeasure from "react-use-measure"; import useMeasure from "react-use-measure";
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc"; import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
import classNames from "classnames"; import classNames from "classnames";
import { BehaviorSubject, map } from "rxjs"; import { BehaviorSubject, map } from "rxjs";
import { useObservable, useObservableEagerState } from "observable-hooks"; import { useObservable } from "observable-hooks";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { RoomAndToDeviceEvents } from "matrix-js-sdk/lib/matrixrtc/RoomAndToDeviceKeyTransport"; import { RoomAndToDeviceEvents } from "matrix-js-sdk/lib/matrixrtc/RoomAndToDeviceKeyTransport";
import {
VoiceCallSolidIcon,
VolumeOnSolidIcon,
} from "@vector-im/compound-design-tokens/assets/web/icons";
import { useTranslation } from "react-i18next";
import LogoMark from "../icons/LogoMark.svg?react"; import LogoMark from "../icons/LogoMark.svg?react";
import LogoType from "../icons/LogoType.svg?react"; import LogoType from "../icons/LogoType.svg?react";
@@ -43,7 +47,7 @@ import {
SwitchCameraButton, SwitchCameraButton,
} from "../button"; } from "../button";
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header"; import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
import { useUrlParams } from "../UrlParams"; import { type HeaderStyle, useUrlParams } from "../UrlParams";
import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts"; import { useCallViewKeyboardShortcuts } from "../useCallViewKeyboardShortcuts";
import { ElementWidgetActions, widget } from "../widget"; import { ElementWidgetActions, widget } from "../widget";
import styles from "./InCallView.module.css"; import styles from "./InCallView.module.css";
@@ -96,7 +100,6 @@ import { CallEventAudioRenderer } from "./CallEventAudioRenderer";
import { import {
debugTileLayout as debugTileLayoutSetting, debugTileLayout as debugTileLayoutSetting,
useExperimentalToDeviceTransport as useExperimentalToDeviceTransportSetting, useExperimentalToDeviceTransport as useExperimentalToDeviceTransportSetting,
muteAllAudio as muteAllAudioSetting,
developerMode as developerModeSetting, developerMode as developerModeSetting,
useSetting, useSetting,
} from "../settings/settings"; } from "../settings/settings";
@@ -104,6 +107,12 @@ import { ReactionsReader } from "../reactions/ReactionsReader";
import { ConnectionLostError } from "../utils/errors.ts"; import { ConnectionLostError } from "../utils/errors.ts";
import { useTypedEventEmitter } from "../useEvents.ts"; import { useTypedEventEmitter } from "../useEvents.ts";
import { MatrixAudioRenderer } from "../livekit/MatrixAudioRenderer.tsx"; import { MatrixAudioRenderer } from "../livekit/MatrixAudioRenderer.tsx";
import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts";
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships.ts";
import { useMediaDevices } from "../MediaDevicesContext.ts";
import { EarpieceOverlay } from "./EarpieceOverlay.tsx";
import { useAppBarHidden, useAppBarSecondaryButton } from "../AppBar.tsx";
import { useBehavior } from "../useBehavior.ts";
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
@@ -115,6 +124,7 @@ export interface ActiveCallProps
} }
export const ActiveCall: FC<ActiveCallProps> = (props) => { export const ActiveCall: FC<ActiveCallProps> = (props) => {
const mediaDevices = useMediaDevices();
const sfuConfig = useOpenIDSFU(props.client, props.rtcSession); const sfuConfig = useOpenIDSFU(props.client, props.rtcSession);
const { livekitRoom, connState } = useLivekit( const { livekitRoom, connState } = useLivekit(
props.rtcSession, props.rtcSession,
@@ -147,8 +157,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
logger.error("[Lifecycle] Failed to disconnect from livekit room", e); logger.error("[Lifecycle] Failed to disconnect from livekit room", e);
}); });
}; };
// eslint-disable-next-line react-hooks/exhaustive-deps }, [livekitRoom]);
}, []);
useEffect(() => { useEffect(() => {
if (livekitRoom !== undefined) { if (livekitRoom !== undefined) {
@@ -156,6 +165,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
const vm = new CallViewModel( const vm = new CallViewModel(
props.rtcSession, props.rtcSession,
livekitRoom, livekitRoom,
mediaDevices,
props.e2eeSystem, props.e2eeSystem,
connStateObservable$, connStateObservable$,
reactionsReader.raisedHands$, reactionsReader.raisedHands$,
@@ -167,12 +177,18 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
reactionsReader.destroy(); reactionsReader.destroy();
}; };
} }
}, [props.rtcSession, livekitRoom, props.e2eeSystem, connStateObservable$]); }, [
props.rtcSession,
livekitRoom,
mediaDevices,
props.e2eeSystem,
connStateObservable$,
]);
if (livekitRoom === undefined || vm === null) return null; if (livekitRoom === undefined || vm === null) return null;
return ( return (
<RoomContext.Provider value={livekitRoom}> <RoomContext value={livekitRoom}>
<ReactionsSenderProvider vm={vm} rtcSession={props.rtcSession}> <ReactionsSenderProvider vm={vm} rtcSession={props.rtcSession}>
<InCallView <InCallView
{...props} {...props}
@@ -181,7 +197,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
connState={connState} connState={connState}
/> />
</ReactionsSenderProvider> </ReactionsSenderProvider>
</RoomContext.Provider> </RoomContext>
); );
}; };
@@ -195,7 +211,7 @@ export interface InCallViewProps {
participantCount: number; participantCount: number;
/** Function to call when the user explicitly ends the call */ /** Function to call when the user explicitly ends the call */
onLeave: () => void; onLeave: () => void;
hideHeader: boolean; header: HeaderStyle;
otelGroupCallMembership?: OTelGroupCallMembership; otelGroupCallMembership?: OTelGroupCallMembership;
connState: ECConnectionState; connState: ECConnectionState;
onShareClick: (() => void) | null; onShareClick: (() => void) | null;
@@ -210,10 +226,11 @@ export const InCallView: FC<InCallViewProps> = ({
muteStates, muteStates,
participantCount, participantCount,
onLeave, onLeave,
hideHeader, header: headerStyle,
connState, connState,
onShareClick, onShareClick,
}) => { }) => {
const { t } = useTranslation();
const { supportsReactions, sendReaction, toggleRaisedHand } = const { supportsReactions, sendReaction, toggleRaisedHand } =
useReactionsSender(); useReactionsSender();
@@ -235,7 +252,7 @@ export const InCallView: FC<InCallViewProps> = ({
room: livekitRoom, room: livekitRoom,
}); });
const [muteAllAudio] = useSetting(muteAllAudioSetting); const muteAllAudio = useBehavior(muteAllAudio$);
// This seems like it might be enough logic to use move it into the call view model? // This seems like it might be enough logic to use move it into the call view model?
const [didFallbackToRoomKey, setDidFallbackToRoomKey] = useState(false); const [didFallbackToRoomKey, setDidFallbackToRoomKey] = useState(false);
@@ -250,6 +267,7 @@ export const InCallView: FC<InCallViewProps> = ({
useExperimentalToDeviceTransportSetting, useExperimentalToDeviceTransportSetting,
); );
const encryptionSystem = useRoomEncryptionSystem(rtcSession.room.roomId); const encryptionSystem = useRoomEncryptionSystem(rtcSession.room.roomId);
const memberships = useMatrixRTCSessionMemberships(rtcSession);
const showToDeviceEncryption = useMemo( const showToDeviceEncryption = useMemo(
() => () =>
@@ -285,13 +303,15 @@ export const InCallView: FC<InCallViewProps> = ({
() => void toggleRaisedHand(), () => void toggleRaisedHand(),
); );
const windowMode = useObservableEagerState(vm.windowMode$); const windowMode = useBehavior(vm.windowMode$);
const layout = useObservableEagerState(vm.layout$); const layout = useBehavior(vm.layout$);
const tileStoreGeneration = useObservableEagerState(vm.tileStoreGeneration$); const tileStoreGeneration = useBehavior(vm.tileStoreGeneration$);
const [debugTileLayout] = useSetting(debugTileLayoutSetting); const [debugTileLayout] = useSetting(debugTileLayoutSetting);
const gridMode = useObservableEagerState(vm.gridMode$); const gridMode = useBehavior(vm.gridMode$);
const showHeader = useObservableEagerState(vm.showHeader$); const showHeader = useBehavior(vm.showHeader$);
const showFooter = useObservableEagerState(vm.showFooter$); const showFooter = useBehavior(vm.showFooter$);
const earpieceMode = useBehavior(vm.earpieceMode$);
const audioOutputSwitcher = useBehavior(vm.audioOutputSwitcher$);
const switchCamera = useSwitchCamera(vm.localVideo$); const switchCamera = useSwitchCamera(vm.localVideo$);
// Ideally we could detect taps by listening for click events and checking // Ideally we could detect taps by listening for click events and checking
@@ -434,25 +454,86 @@ export const InCallView: FC<InCallViewProps> = ({
} }
}, [setGridMode]); }, [setGridMode]);
useAppBarSecondaryButton(
useMemo(() => {
if (audioOutputSwitcher === null) return null;
const isEarpieceTarget = audioOutputSwitcher.targetOutput === "earpiece";
const Icon = isEarpieceTarget ? VoiceCallSolidIcon : VolumeOnSolidIcon;
const label = isEarpieceTarget
? t("settings.devices.handset")
: t("settings.devices.loudspeaker");
return (
<Tooltip label={label}>
<IconButton
onClick={(e) => {
e.preventDefault();
audioOutputSwitcher.switch();
}}
>
<Icon />
</IconButton>
</Tooltip>
);
}, [t, audioOutputSwitcher]),
);
useAppBarHidden(!showHeader);
let header: ReactNode = null;
if (showHeader) {
switch (headerStyle) {
case "none":
// Cosmetic header to fill out space while still affecting the bounds of
// the grid
header = (
<div
className={classNames(styles.header, styles.filler)}
ref={headerRef}
/>
);
break;
case "standard":
header = (
<Header className={styles.header} ref={headerRef}>
<LeftNav>
<RoomHeaderInfo
id={matrixInfo.roomId}
name={matrixInfo.roomName}
avatarUrl={matrixInfo.roomAvatar}
encrypted={matrixInfo.e2eeSystem.kind !== E2eeType.NONE}
participantCount={participantCount}
/>
</LeftNav>
<RightNav>
{showControls && onShareClick !== null && (
<InviteButton
className={styles.invite}
onClick={onShareClick}
/>
)}
</RightNav>
</Header>
);
}
}
const Tile = useMemo( const Tile = useMemo(
() => () =>
forwardRef< function Tile({
HTMLDivElement,
PropsWithoutRef<TileProps<TileViewModel, HTMLDivElement>>
>(function Tile(
{ className, style, targetWidth, targetHeight, model },
ref, ref,
) { className,
const spotlightExpanded = useObservableEagerState( style,
vm.spotlightExpanded$, targetWidth,
); targetHeight,
const onToggleExpanded = useObservableEagerState( model,
vm.toggleSpotlightExpanded$, }: TileProps<TileViewModel, HTMLDivElement>): ReactNode {
); const spotlightExpanded = useBehavior(vm.spotlightExpanded$);
const showSpeakingIndicatorsValue = useObservableEagerState( const onToggleExpanded = useBehavior(vm.toggleSpotlightExpanded$);
const showSpeakingIndicatorsValue = useBehavior(
vm.showSpeakingIndicators$, vm.showSpeakingIndicators$,
); );
const showSpotlightIndicatorsValue = useObservableEagerState( const showSpotlightIndicatorsValue = useBehavior(
vm.showSpotlightIndicators$, vm.showSpotlightIndicators$,
); );
@@ -480,7 +561,7 @@ export const InCallView: FC<InCallViewProps> = ({
style={style} style={style}
/> />
); );
}), },
[vm, openProfile], [vm, openProfile],
); );
@@ -520,7 +601,8 @@ export const InCallView: FC<InCallViewProps> = ({
key="fixed" key="fixed"
className={styles.fixedGrid} className={styles.fixedGrid}
style={{ style={{
insetBlockStart: headerBounds.bottom, insetBlockStart:
headerBounds.height > 0 ? headerBounds.bottom : bounds.top,
height: gridBounds.height, height: gridBounds.height,
}} }}
model={layout} model={layout}
@@ -643,10 +725,11 @@ export const InCallView: FC<InCallViewProps> = ({
ref={footerRef} ref={footerRef}
className={classNames(styles.footer, { className={classNames(styles.footer, {
[styles.overlay]: windowMode === "flat", [styles.overlay]: windowMode === "flat",
[styles.hidden]: !showFooter || (!showControls && hideHeader), [styles.hidden]:
!showFooter || (!showControls && headerStyle === "none"),
})} })}
> >
{!hideHeader && ( {headerStyle !== "none" && (
<div className={styles.logo}> <div className={styles.logo}>
<LogoMark width={24} height={24} aria-hidden /> <LogoMark width={24} height={24} aria-hidden />
<LogoType <LogoType
@@ -682,35 +765,7 @@ export const InCallView: FC<InCallViewProps> = ({
onPointerMove={onPointerMove} onPointerMove={onPointerMove}
onPointerOut={onPointerOut} onPointerOut={onPointerOut}
> >
{showHeader && {header}
(hideHeader ? (
// Cosmetic header to fill out space while still affecting the bounds
// of the grid
<div
className={classNames(styles.header, styles.filler)}
ref={headerRef}
/>
) : (
<Header className={styles.header} ref={headerRef}>
<LeftNav>
<RoomHeaderInfo
id={matrixInfo.roomId}
name={matrixInfo.roomName}
avatarUrl={matrixInfo.roomAvatar}
encrypted={matrixInfo.e2eeSystem.kind !== E2eeType.NONE}
participantCount={participantCount}
/>
</LeftNav>
<RightNav>
{showControls && onShareClick !== null && (
<InviteButton
className={styles.invite}
onClick={onShareClick}
/>
)}
</RightNav>
</Header>
))}
{ {
// TODO: remove this once we remove the developer flag gets removed and we have shipped to // TODO: remove this once we remove the developer flag gets removed and we have shipped to
// device transport as the default. // device transport as the default.
@@ -723,13 +778,14 @@ export const InCallView: FC<InCallViewProps> = ({
</Text> </Text>
) )
} }
<MatrixAudioRenderer <MatrixAudioRenderer members={memberships} muted={muteAllAudio} />
members={rtcSession.memberships}
muted={muteAllAudio}
/>
{renderContent()} {renderContent()}
<CallEventAudioRenderer vm={vm} muted={muteAllAudio} /> <CallEventAudioRenderer vm={vm} muted={muteAllAudio} />
<ReactionsAudioRenderer vm={vm} muted={muteAllAudio} /> <ReactionsAudioRenderer vm={vm} muted={muteAllAudio} />
<EarpieceOverlay
show={earpieceMode}
onBackToVideoPressed={audioOutputSwitcher?.switch}
/>
<ReactionsOverlay vm={vm} /> <ReactionsOverlay vm={vm} />
{footer} {footer}
{layout.type !== "pip" && ( {layout.type !== "pip" && (
+3 -4
View File
@@ -19,7 +19,7 @@ import {
LinkIcon, LinkIcon,
CheckIcon, CheckIcon,
} from "@vector-im/compound-design-tokens/assets/web/icons"; } from "@vector-im/compound-design-tokens/assets/web/icons";
import useClipboard from "react-use-clipboard"; import copy from "copy-to-clipboard";
import { Modal } from "../Modal"; import { Modal } from "../Modal";
import { getAbsoluteRoomUrl } from "../utils/matrix"; import { getAbsoluteRoomUrl } from "../utils/matrix";
@@ -42,18 +42,17 @@ export const InviteModal: FC<Props> = ({ room, open, onDismiss }) => {
() => getAbsoluteRoomUrl(room.roomId, e2eeSystem, room.name), () => getAbsoluteRoomUrl(room.roomId, e2eeSystem, room.name),
[e2eeSystem, room.name, room.roomId], [e2eeSystem, room.name, room.roomId],
); );
const [, setCopied] = useClipboard(url);
const [toastOpen, setToastOpen] = useState(false); const [toastOpen, setToastOpen] = useState(false);
const onToastDismiss = useCallback(() => setToastOpen(false), [setToastOpen]); const onToastDismiss = useCallback(() => setToastOpen(false), [setToastOpen]);
const onButtonClick = useCallback( const onButtonClick = useCallback(
(e: MouseEvent) => { (e: MouseEvent) => {
e.stopPropagation(); e.stopPropagation();
setCopied(); copy(url);
onDismiss(); onDismiss();
setToastOpen(true); setToastOpen(true);
}, },
[setCopied, onDismiss], [url, onDismiss],
); );
return ( return (
+26 -8
View File
@@ -24,7 +24,7 @@ import {
type LocalVideoTrack, type LocalVideoTrack,
Track, Track,
} from "livekit-client"; } from "livekit-client";
import { useObservable } from "observable-hooks"; import { useObservable, useObservableEagerState } from "observable-hooks";
import { map } from "rxjs"; import { map } from "rxjs";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@@ -45,7 +45,7 @@ import { SettingsModal, defaultSettingsTab } from "../settings/SettingsModal";
import { useMediaQuery } from "../useMediaQuery"; import { useMediaQuery } from "../useMediaQuery";
import { E2eeType } from "../e2ee/e2eeType"; import { E2eeType } from "../e2ee/e2eeType";
import { Link } from "../button/Link"; import { Link } from "../button/Link";
import { useMediaDevices } from "../livekit/MediaDevicesContext"; import { useMediaDevices } from "../MediaDevicesContext";
import { useInitial } from "../useInitial"; import { useInitial } from "../useInitial";
import { useSwitchCamera as useShowSwitchCamera } from "./useSwitchCamera"; import { useSwitchCamera as useShowSwitchCamera } from "./useSwitchCamera";
import { import {
@@ -53,6 +53,8 @@ import {
useTrackProcessorSync, useTrackProcessorSync,
} from "../livekit/TrackProcessorContext"; } from "../livekit/TrackProcessorContext";
import { usePageTitle } from "../usePageTitle"; import { usePageTitle } from "../usePageTitle";
import { useLatest } from "../useLatest";
import { getValue } from "../utils/observable";
interface Props { interface Props {
client: MatrixClient; client: MatrixClient;
@@ -125,13 +127,18 @@ export const LobbyView: FC<Props> = ({
); );
const devices = useMediaDevices(); const devices = useMediaDevices();
const videoInputId = useObservableEagerState(
devices.videoInput.selected$,
)?.id;
// Capture the audio options as they were when we first mounted, because // Capture the audio options as they were when we first mounted, because
// we're not doing anything with the audio anyway so we don't need to // we're not doing anything with the audio anyway so we don't need to
// re-open the devices when they change (see below). // re-open the devices when they change (see below).
const initialAudioOptions = useInitial( const initialAudioOptions = useInitial(
() => () =>
muteStates.audio.enabled && { deviceId: devices.audioInput.selectedId }, muteStates.audio.enabled && {
deviceId: getValue(devices.audioInput.selected$)?.id,
},
); );
const { processor } = useTrackProcessor(); const { processor } = useTrackProcessor();
@@ -147,25 +154,26 @@ export const LobbyView: FC<Props> = ({
// which would cause the devices to be re-opened on the next render. // which would cause the devices to be re-opened on the next render.
audio: Object.assign({}, initialAudioOptions), audio: Object.assign({}, initialAudioOptions),
video: muteStates.video.enabled && { video: muteStates.video.enabled && {
deviceId: devices.videoInput.selectedId, deviceId: videoInputId,
processor: initialProcessor, processor: initialProcessor,
}, },
}), }),
[ [
initialAudioOptions, initialAudioOptions,
muteStates.video.enabled, muteStates.video.enabled,
devices.videoInput.selectedId, videoInputId,
initialProcessor, initialProcessor,
], ],
); );
const latestMuteStates = useLatest(muteStates);
const onError = useCallback( const onError = useCallback(
(error: Error) => { (error: Error) => {
logger.error("Error while creating preview Tracks:", error); logger.error("Error while creating preview Tracks:", error);
muteStates.audio.setEnabled?.(false); latestMuteStates.current.audio.setEnabled?.(false);
muteStates.video.setEnabled?.(false); latestMuteStates.current.video.setEnabled?.(false);
}, },
[muteStates.audio, muteStates.video], [latestMuteStates],
); );
const tracks = usePreviewTracks(localTrackOptions, onError); const tracks = usePreviewTracks(localTrackOptions, onError);
@@ -176,6 +184,16 @@ export const LobbyView: FC<Props> = ({
null) as LocalVideoTrack | null, null) as LocalVideoTrack | null,
[tracks], [tracks],
); );
useEffect(() => {
if (videoTrack && videoInputId === undefined) {
// If we have a video track but no videoInputId,
// we have to update the available devices. So that we select the first
// available video input device as the default instead of the `""` id.
devices.requestDeviceNames();
}
}, [devices, videoInputId, videoTrack]);
useTrackProcessorSync(videoTrack); useTrackProcessorSync(videoTrack);
const showSwitchCamera = useShowSwitchCamera( const showSwitchCamera = useShowSwitchCamera(
useObservable( useObservable(
+53 -45
View File
@@ -5,20 +5,29 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { afterAll, afterEach, describe, expect, it, vi } from "vitest"; import {
afterAll,
afterEach,
describe,
expect,
it,
onTestFinished,
vi,
} from "vitest";
import { type FC, useCallback, useState } from "react"; import { type FC, useCallback, useState } from "react";
import { render, screen } from "@testing-library/react"; import { render, screen } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom"; import { MemoryRouter } from "react-router-dom";
import userEvent from "@testing-library/user-event"; import userEvent from "@testing-library/user-event";
import { createMediaDeviceObserver } from "@livekit/components-core";
import { of } from "rxjs";
import { useMuteStates } from "./MuteStates"; import { useMuteStates } from "./MuteStates";
import { import { MediaDevicesContext } from "../MediaDevicesContext";
type DeviceLabel,
type MediaDevice,
type MediaDevices,
MediaDevicesContext,
} from "../livekit/MediaDevicesContext";
import { mockConfig } from "../utils/test"; import { mockConfig } from "../utils/test";
import { MediaDevices } from "../state/MediaDevices";
import { ObservableScope } from "../state/ObservableScope";
vi.mock("@livekit/components-core");
interface TestComponentProps { interface TestComponentProps {
isJoined?: boolean; isJoined?: boolean;
@@ -73,16 +82,6 @@ const mockCamera: MediaDeviceInfo = {
}, },
}; };
function mockDevices(available: Map<string, DeviceLabel>): MediaDevice {
return {
available,
selectedId: "",
selectedGroupId: "",
select: (): void => {},
useAsEarpiece: false,
};
}
function mockMediaDevices( function mockMediaDevices(
{ {
microphone, microphone,
@@ -94,21 +93,21 @@ function mockMediaDevices(
camera?: boolean; camera?: boolean;
} = { microphone: true, speaker: true, camera: true }, } = { microphone: true, speaker: true, camera: true },
): MediaDevices { ): MediaDevices {
return { vi.mocked(createMediaDeviceObserver).mockImplementation((kind) => {
audioInput: mockDevices( switch (kind) {
microphone case "audioinput":
? new Map([[mockMicrophone.deviceId, mockMicrophone]]) return of(microphone ? [mockMicrophone] : []);
: new Map(), case "audiooutput":
), return of(speaker ? [mockSpeaker] : []);
audioOutput: mockDevices( case "videoinput":
speaker ? new Map([[mockSpeaker.deviceId, mockSpeaker]]) : new Map(), return of(camera ? [mockCamera] : []);
), case undefined:
videoInput: mockDevices( throw new Error("Unimplemented");
camera ? new Map([[mockCamera.deviceId, mockCamera]]) : new Map(), }
), });
startUsingDeviceNames: (): void => {}, const scope = new ObservableScope();
stopUsingDeviceNames: (): void => {}, onTestFinished(() => scope.end());
}; return new MediaDevices(scope);
} }
describe("useMuteStates", () => { describe("useMuteStates", () => {
@@ -125,14 +124,14 @@ describe("useMuteStates", () => {
render( render(
<MemoryRouter> <MemoryRouter>
<MediaDevicesContext.Provider <MediaDevicesContext
value={mockMediaDevices({ value={mockMediaDevices({
microphone: false, microphone: false,
camera: false, camera: false,
})} })}
> >
<TestComponent /> <TestComponent />
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter>, </MemoryRouter>,
); );
expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
@@ -144,9 +143,9 @@ describe("useMuteStates", () => {
render( render(
<MemoryRouter> <MemoryRouter>
<MediaDevicesContext.Provider value={mockMediaDevices()}> <MediaDevicesContext value={mockMediaDevices()}>
<TestComponent /> <TestComponent />
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter>, </MemoryRouter>,
); );
expect(screen.getByTestId("audio-enabled").textContent).toBe("true"); expect(screen.getByTestId("audio-enabled").textContent).toBe("true");
@@ -160,9 +159,9 @@ describe("useMuteStates", () => {
render( render(
<MemoryRouter> <MemoryRouter>
<MediaDevicesContext.Provider value={mockMediaDevices()}> <MediaDevicesContext value={mockMediaDevices()}>
<TestComponent isJoined /> <TestComponent isJoined />
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter>, </MemoryRouter>,
); );
expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
@@ -179,9 +178,9 @@ describe("useMuteStates", () => {
render( render(
<MemoryRouter> <MemoryRouter>
<MediaDevicesContext.Provider value={mockMediaDevices()}> <MediaDevicesContext value={mockMediaDevices()}>
<TestComponent /> <TestComponent />
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter>, </MemoryRouter>,
); );
expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
@@ -192,10 +191,14 @@ describe("useMuteStates", () => {
mockConfig(); mockConfig();
render( render(
<MemoryRouter initialEntries={["/room/?skipLobby=true"]}> <MemoryRouter
<MediaDevicesContext.Provider value={mockMediaDevices()}> initialEntries={[
"/room/?skipLobby=true&widgetId=1234&parentUrl=www.parent.org",
]}
>
<MediaDevicesContext value={mockMediaDevices()}>
<TestComponent /> <TestComponent />
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter>, </MemoryRouter>,
); );
expect(screen.getByTestId("audio-enabled").textContent).toBe("false"); expect(screen.getByTestId("audio-enabled").textContent).toBe("false");
@@ -206,7 +209,12 @@ describe("useMuteStates", () => {
const user = userEvent.setup(); const user = userEvent.setup();
mockConfig(); mockConfig();
const noDevices = mockMediaDevices({ microphone: false, camera: false }); const noDevices = mockMediaDevices({ microphone: false, camera: false });
// Warm up these Observables before making further changes to the
// createMediaDevicesObserver mock
noDevices.audioInput.available$.subscribe(() => {}).unsubscribe();
noDevices.videoInput.available$.subscribe(() => {}).unsubscribe();
const someDevices = mockMediaDevices(); const someDevices = mockMediaDevices();
const ReappearanceTest: FC = () => { const ReappearanceTest: FC = () => {
const [devices, setDevices] = useState(someDevices); const [devices, setDevices] = useState(someDevices);
const onConnectDevicesClick = useCallback( const onConnectDevicesClick = useCallback(
@@ -220,13 +228,13 @@ describe("useMuteStates", () => {
return ( return (
<MemoryRouter> <MemoryRouter>
<MediaDevicesContext.Provider value={devices}> <MediaDevicesContext value={devices}>
<TestComponent /> <TestComponent />
<button onClick={onConnectDevicesClick}>Connect devices</button> <button onClick={onConnectDevicesClick}>Connect devices</button>
<button onClick={onDisconnectDevicesClick}> <button onClick={onDisconnectDevicesClick}>
Disconnect devices Disconnect devices
</button> </button>
</MediaDevicesContext.Provider> </MediaDevicesContext>
</MemoryRouter> </MemoryRouter>
); );
}; };
+22 -8
View File
@@ -14,11 +14,14 @@ import {
} from "react"; } from "react";
import { type IWidgetApiRequest } from "matrix-widget-api"; import { type IWidgetApiRequest } from "matrix-widget-api";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { useObservableEagerState } from "observable-hooks";
import { import {
type DeviceLabel,
type SelectedDevice,
type MediaDevice, type MediaDevice,
useMediaDevices, } from "../state/MediaDevices";
} from "../livekit/MediaDevicesContext"; import { useIsEarpiece, useMediaDevices } from "../MediaDevicesContext";
import { useReactiveState } from "../useReactiveState"; import { useReactiveState } from "../useReactiveState";
import { ElementWidgetActions, widget } from "../widget"; import { ElementWidgetActions, widget } from "../widget";
import { Config } from "../config/Config"; import { Config } from "../config/Config";
@@ -53,24 +56,25 @@ export interface MuteStates {
} }
function useMuteState( function useMuteState(
device: MediaDevice, device: MediaDevice<DeviceLabel, SelectedDevice>,
enabledByDefault: () => boolean, enabledByDefault: () => boolean,
forceUnavailable: boolean = false,
): MuteState { ): MuteState {
const available = useObservableEagerState(device.available$);
const [enabled, setEnabled] = useReactiveState<boolean | undefined>( const [enabled, setEnabled] = useReactiveState<boolean | undefined>(
// Determine the default value once devices are actually connected // Determine the default value once devices are actually connected
(prev) => (prev) => prev ?? (available.size > 0 ? enabledByDefault() : undefined),
prev ?? (device.available.size > 0 ? enabledByDefault() : undefined), [available.size],
[device],
); );
return useMemo( return useMemo(
() => () =>
device.available.size === 0 available.size === 0 || forceUnavailable
? deviceUnavailable ? deviceUnavailable
: { : {
enabled: enabled ?? false, enabled: enabled ?? false,
setEnabled: setEnabled as Dispatch<SetStateAction<boolean>>, setEnabled: setEnabled as Dispatch<SetStateAction<boolean>>,
}, },
[device, enabled, setEnabled], [available.size, enabled, forceUnavailable, setEnabled],
); );
} }
@@ -82,9 +86,19 @@ export function useMuteStates(isJoined: boolean): MuteStates {
const audio = useMuteState(devices.audioInput, () => { const audio = useMuteState(devices.audioInput, () => {
return Config.get().media_devices.enable_audio && !skipLobby && !isJoined; return Config.get().media_devices.enable_audio && !skipLobby && !isJoined;
}); });
useEffect(() => {
// If audio is enabled, we need to request the device names again,
// because iOS will not be able to switch to the correct device after un-muting.
// This is one of the main changes that makes iOS work with bluetooth audio devices.
if (audio.enabled) {
devices.requestDeviceNames();
}
}, [audio.enabled, devices]);
const isEarpiece = useIsEarpiece();
const video = useMuteState( const video = useMuteState(
devices.videoInput, devices.videoInput,
() => Config.get().media_devices.enable_video && !skipLobby && !isJoined, () => Config.get().media_devices.enable_video && !skipLobby && !isJoined,
isEarpiece, // Force video to be unavailable if using earpiece
); );
useEffect(() => { useEffect(() => {
+3 -3
View File
@@ -6,16 +6,16 @@ Please see LICENSE in the repository root for full details.
*/ */
import { type ReactNode } from "react"; import { type ReactNode } from "react";
import { useObservableState } from "observable-hooks";
import styles from "./ReactionsOverlay.module.css"; import styles from "./ReactionsOverlay.module.css";
import { type CallViewModel } from "../state/CallViewModel"; import { type CallViewModel } from "../state/CallViewModel";
import { useBehavior } from "../useBehavior";
export function ReactionsOverlay({ vm }: { vm: CallViewModel }): ReactNode { export function ReactionsOverlay({ vm }: { vm: CallViewModel }): ReactNode {
const reactionsIcons = useObservableState(vm.visibleReactions$); const reactionsIcons = useBehavior(vm.visibleReactions$);
return ( return (
<div className={styles.container}> <div className={styles.container}>
{reactionsIcons?.map(({ sender, emoji, startX }) => ( {reactionsIcons.map(({ sender, emoji, startX }) => (
<span <span
// Reactions effects are considered presentation elements. The reaction // Reactions effects are considered presentation elements. The reaction
// is also present on the sender's tile, which assistive technology can // is also present on the sender's tile, which assistive technology can
+12 -8
View File
@@ -19,8 +19,10 @@ import { UserMenuContainer } from "../UserMenuContainer";
import { useRegisterPasswordlessUser } from "../auth/useRegisterPasswordlessUser"; import { useRegisterPasswordlessUser } from "../auth/useRegisterPasswordlessUser";
import { Config } from "../config/Config"; import { Config } from "../config/Config";
import { ExternalLink, Link } from "../button/Link"; import { ExternalLink, Link } from "../button/Link";
import { useUrlParams } from "../UrlParams";
export const RoomAuthView: FC = () => { export const RoomAuthView: FC = () => {
const { header } = useUrlParams();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error>(); const [error, setError] = useState<Error>();
@@ -53,14 +55,16 @@ export const RoomAuthView: FC = () => {
return ( return (
<> <>
<Header> {header === "standard" && (
<LeftNav> <Header>
<HeaderLogo /> <LeftNav>
</LeftNav> <HeaderLogo />
<RightNav> </LeftNav>
<UserMenuContainer preventNavigation /> <RightNav>
</RightNav> <UserMenuContainer preventNavigation />
</Header> </RightNav>
</Header>
)}
<div className={styles.container}> <div className={styles.container}>
<main className={styles.main}> <main className={styles.main}>
<Heading size="xl" weight="semibold" className={styles.headline}> <Heading size="xl" weight="semibold" className={styles.headline}>
+4 -10
View File
@@ -43,14 +43,8 @@ import { ErrorView } from "../ErrorView";
import { useMatrixRTCSessionJoinState } from "../useMatrixRTCSessionJoinState"; import { useMatrixRTCSessionJoinState } from "../useMatrixRTCSessionJoinState";
export const RoomPage: FC = () => { export const RoomPage: FC = () => {
const { const { confineToRoom, appPrompt, preload, header, displayName, skipLobby } =
confineToRoom, useUrlParams();
appPrompt,
preload,
hideHeader,
displayName,
skipLobby,
} = useUrlParams();
const { t } = useTranslation(); const { t } = useTranslation();
const { roomAlias, roomId, viaServers } = useRoomIdentifier(); const { roomAlias, roomId, viaServers } = useRoomIdentifier();
@@ -120,7 +114,7 @@ export const RoomPage: FC = () => {
confineToRoom={confineToRoom} confineToRoom={confineToRoom}
preload={preload} preload={preload}
skipLobby={skipLobby || wasInWaitForInviteState.current} skipLobby={skipLobby || wasInWaitForInviteState.current}
hideHeader={hideHeader} header={header}
muteStates={muteStates} muteStates={muteStates}
/> />
); );
@@ -161,7 +155,7 @@ export const RoomPage: FC = () => {
enterLabel={label} enterLabel={label}
waitingForInvite={groupCallState.kind === "waitForInvite"} waitingForInvite={groupCallState.kind === "waitForInvite"}
confineToRoom={confineToRoom} confineToRoom={confineToRoom}
hideHeader={hideHeader} hideHeader={header !== "standard"}
participantCount={null} participantCount={null}
muteStates={muteStates} muteStates={muteStates}
onShareClick={null} onShareClick={null}
@@ -108,10 +108,11 @@ exports[`ConnectionLostError: Action handling should reset error state 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -119,23 +120,29 @@ exports[`ConnectionLostError: Action handling should reset error state 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M3.5 3.5a1 1 0 1 0-1.414 1.414l4.113 4.114a5.484 5.484 0 0 0-.184 1.069A5.002 5.002 0 0 0 7 20h10.172l1.914 1.914A1 1 0 0 0 20.5 20.5l-.979-.979.004-.002L7.145 7.14l-.002.004L3.5 3.5Zm18.5 12a4.48 4.48 0 0 1-.928 2.738L8.637 5.803A5.474 5.474 0 0 1 11.5 5a5.49 5.49 0 0 1 4.25 2.008 4 4 0 0 1 4.187 4.708A4.497 4.497 0 0 1 22 15.5Z" d="M3.5 3.5a1 1 0 1 0-1.414 1.414l4.113 4.114a5.5 5.5 0 0 0-.184 1.07A5.002 5.002 0 0 0 7 20h10.172l1.914 1.914A1 1 0 1 0 20.5 20.5l-.979-.979.004-.001L7.145 7.14l-.002.003zm18.5 12a4.48 4.48 0 0 1-.928 2.738L8.637 5.803A5.47 5.47 0 0 1 11.5 5a5.49 5.49 0 0 1 4.25 2.008 4 4 0 0 1 4.187 4.708A4.5 4.5 0 0 1 22 15.5"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Connection lost Connection lost
</h1> </h1>
<p> <p>
You were disconnected from the call. You were disconnected from the call.
</p> </p>
<button> <button
class="_button_vczzf_8"
data-kind="secondary"
data-size="lg"
role="button"
tabindex="0"
>
Reconnect Reconnect
</button> </button>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -258,10 +265,11 @@ exports[`should have a close button in widget mode 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -269,17 +277,17 @@ exports[`should have a close button in widget mode 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M16.712 6.713A.968.968 0 0 1 16 7a.968.968 0 0 1-.713-.287A.967.967 0 0 1 15 6c0-.283.096-.52.287-.713A.968.968 0 0 1 16 5a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.713Z" d="M16.713 6.713A.97.97 0 0 1 16 7a.97.97 0 0 1-.713-.287A.97.97 0 0 1 15 6q0-.424.287-.713A.97.97 0 0 1 16 5q.424 0 .712.287Q17 5.576 17 6t-.288.713"
/> />
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H6Zm12 2H6v4h12V4ZM6 12v-2h12v2H6Zm0 2v2h12v-2H6Zm0 6v-2h12v2H6Z" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm12 2H6v4h12zM6 12v-2h12v2zm0 2v2h12v-2zm0 6v-2h12v2z"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Call is not supported Call is not supported
</h1> </h1>
@@ -287,7 +295,7 @@ exports[`should have a close button in widget mode 1`] = `
The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS). The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS).
</p> </p>
<button <button
class="_button_i91xf_17" class="_button_vczzf_8"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -410,10 +418,11 @@ exports[`should render the error page with link back to home 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -421,17 +430,17 @@ exports[`should render the error page with link back to home 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M16.712 6.713A.968.968 0 0 1 16 7a.968.968 0 0 1-.713-.287A.967.967 0 0 1 15 6c0-.283.096-.52.287-.713A.968.968 0 0 1 16 5a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.713Z" d="M16.713 6.713A.97.97 0 0 1 16 7a.97.97 0 0 1-.713-.287A.97.97 0 0 1 15 6q0-.424.287-.713A.97.97 0 0 1 16 5q.424 0 .712.287Q17 5.576 17 6t-.288.713"
/> />
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H6Zm12 2H6v4h12V4ZM6 12v-2h12v2H6Zm0 2v2h12v-2H6Zm0 6v-2h12v2H6Z" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm12 2H6v4h12zM6 12v-2h12v2zm0 2v2h12v-2zm0 6v-2h12v2z"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Call is not supported Call is not supported
</h1> </h1>
@@ -439,7 +448,7 @@ exports[`should render the error page with link back to home 1`] = `
The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS). The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS).
</p> </p>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -562,10 +571,11 @@ exports[`should report correct error for 'Call is not supported' 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -573,17 +583,17 @@ exports[`should report correct error for 'Call is not supported' 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M16.712 6.713A.968.968 0 0 1 16 7a.968.968 0 0 1-.713-.287A.967.967 0 0 1 15 6c0-.283.096-.52.287-.713A.968.968 0 0 1 16 5a.97.97 0 0 1 .712.287c.192.192.288.43.288.713s-.096.52-.288.713Z" d="M16.713 6.713A.97.97 0 0 1 16 7a.97.97 0 0 1-.713-.287A.97.97 0 0 1 15 6q0-.424.287-.713A.97.97 0 0 1 16 5q.424 0 .712.287Q17 5.576 17 6t-.288.713"
/> />
<path <path
clip-rule="evenodd" clip-rule="evenodd"
d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H6Zm12 2H6v4h12V4ZM6 12v-2h12v2H6Zm0 2v2h12v-2H6Zm0 6v-2h12v2H6Z" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2zm12 2H6v4h12zM6 12v-2h12v2zm0 2v2h12v-2zm0 6v-2h12v2z"
fill-rule="evenodd" fill-rule="evenodd"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Call is not supported Call is not supported
</h1> </h1>
@@ -591,7 +601,7 @@ exports[`should report correct error for 'Call is not supported' 1`] = `
The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS). The server is not configured to work with Element Call. Please contact your server admin (Domain: example.com, Error Code: MISSING_MATRIX_RTC_FOCUS).
</p> </p>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -714,10 +724,11 @@ exports[`should report correct error for 'Connection lost' 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -725,23 +736,29 @@ exports[`should report correct error for 'Connection lost' 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M3.5 3.5a1 1 0 1 0-1.414 1.414l4.113 4.114a5.484 5.484 0 0 0-.184 1.069A5.002 5.002 0 0 0 7 20h10.172l1.914 1.914A1 1 0 0 0 20.5 20.5l-.979-.979.004-.002L7.145 7.14l-.002.004L3.5 3.5Zm18.5 12a4.48 4.48 0 0 1-.928 2.738L8.637 5.803A5.474 5.474 0 0 1 11.5 5a5.49 5.49 0 0 1 4.25 2.008 4 4 0 0 1 4.187 4.708A4.497 4.497 0 0 1 22 15.5Z" d="M3.5 3.5a1 1 0 1 0-1.414 1.414l4.113 4.114a5.5 5.5 0 0 0-.184 1.07A5.002 5.002 0 0 0 7 20h10.172l1.914 1.914A1 1 0 1 0 20.5 20.5l-.979-.979.004-.001L7.145 7.14l-.002.003zm18.5 12a4.48 4.48 0 0 1-.928 2.738L8.637 5.803A5.47 5.47 0 0 1 11.5 5a5.49 5.49 0 0 1 4.25 2.008 4 4 0 0 1 4.187 4.708A4.5 4.5 0 0 1 22 15.5"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Connection lost Connection lost
</h1> </h1>
<p> <p>
You were disconnected from the call. You were disconnected from the call.
</p> </p>
<button> <button
class="_button_vczzf_8"
data-kind="secondary"
data-size="lg"
role="button"
tabindex="0"
>
Reconnect Reconnect
</button> </button>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -864,10 +881,11 @@ exports[`should report correct error for 'Incompatible browser' 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -875,12 +893,12 @@ exports[`should report correct error for 'Incompatible browser' 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M4 20c-.55 0-1.02-.196-1.413-.587A1.926 1.926 0 0 1 2 18V6c0-.55.196-1.02.587-1.412A1.926 1.926 0 0 1 4 4h16c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412v12c0 .55-.196 1.02-.587 1.413A1.926 1.926 0 0 1 20 20H4Zm0-2h16V8H4v10Z" d="M4 20q-.824 0-1.412-.587A1.93 1.93 0 0 1 2 18V6q0-.824.587-1.412A1.93 1.93 0 0 1 4 4h16q.824 0 1.413.588Q22 5.175 22 6v12q0 .824-.587 1.413A1.93 1.93 0 0 1 20 20zm0-2h16V8H4z"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Incompatible browser Incompatible browser
</h1> </h1>
@@ -888,7 +906,7 @@ exports[`should report correct error for 'Incompatible browser' 1`] = `
Your web browser does not support encrypted calls. Supported browsers include Chrome, Safari, and Firefox 117+. Your web browser does not support encrypted calls. Supported browsers include Chrome, Safari, and Firefox 117+.
</p> </p>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -1011,10 +1029,11 @@ exports[`should report correct error for 'Insufficient capacity' 1`] = `
class="error" class="error"
> >
<div <div
class="_content_md016_17 icon" class="_content_o77nw_8 icon"
data-size="large" data-size="large"
> >
<svg <svg
aria-hidden="true"
fill="currentColor" fill="currentColor"
height="1em" height="1em"
viewBox="0 0 24 24" viewBox="0 0 24 24"
@@ -1022,12 +1041,12 @@ exports[`should report correct error for 'Insufficient capacity' 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M12 17a.97.97 0 0 0 .713-.288A.968.968 0 0 0 13 16a.968.968 0 0 0-.287-.713A.968.968 0 0 0 12 15a.968.968 0 0 0-.713.287A.968.968 0 0 0 11 16c0 .283.096.52.287.712.192.192.43.288.713.288Zm0-4c.283 0 .52-.096.713-.287A.968.968 0 0 0 13 12V8a.967.967 0 0 0-.287-.713A.968.968 0 0 0 12 7a.968.968 0 0 0-.713.287A.967.967 0 0 0 11 8v4c0 .283.096.52.287.713.192.191.43.287.713.287Zm0 9a9.738 9.738 0 0 1-3.9-.788 10.099 10.099 0 0 1-3.175-2.137c-.9-.9-1.612-1.958-2.137-3.175A9.738 9.738 0 0 1 2 12a9.74 9.74 0 0 1 .788-3.9 10.099 10.099 0 0 1 2.137-3.175c.9-.9 1.958-1.612 3.175-2.137A9.738 9.738 0 0 1 12 2a9.74 9.74 0 0 1 3.9.788 10.098 10.098 0 0 1 3.175 2.137c.9.9 1.613 1.958 2.137 3.175A9.738 9.738 0 0 1 22 12a9.738 9.738 0 0 1-.788 3.9 10.098 10.098 0 0 1-2.137 3.175c-.9.9-1.958 1.613-3.175 2.137A9.738 9.738 0 0 1 12 22Z" d="M12 17q.424 0 .713-.288A.97.97 0 0 0 13 16a.97.97 0 0 0-.287-.713A.97.97 0 0 0 12 15a.97.97 0 0 0-.713.287A.97.97 0 0 0 11 16q0 .424.287.712.288.288.713.288m0-4q.424 0 .713-.287A.97.97 0 0 0 13 12V8a.97.97 0 0 0-.287-.713A.97.97 0 0 0 12 7a.97.97 0 0 0-.713.287A.97.97 0 0 0 11 8v4q0 .424.287.713.288.287.713.287m0 9a9.7 9.7 0 0 1-3.9-.788 10.1 10.1 0 0 1-3.175-2.137q-1.35-1.35-2.137-3.175A9.7 9.7 0 0 1 2 12q0-2.075.788-3.9a10.1 10.1 0 0 1 2.137-3.175q1.35-1.35 3.175-2.137A9.7 9.7 0 0 1 12 2q2.075 0 3.9.788a10.1 10.1 0 0 1 3.175 2.137q1.35 1.35 2.137 3.175A9.7 9.7 0 0 1 22 12a9.7 9.7 0 0 1-.788 3.9 10.1 10.1 0 0 1-2.137 3.175q-1.35 1.35-3.175 2.137A9.7 9.7 0 0 1 12 22"
/> />
</svg> </svg>
</div> </div>
<h1 <h1
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121" class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
> >
Insufficient capacity Insufficient capacity
</h1> </h1>
@@ -1035,7 +1054,7 @@ exports[`should report correct error for 'Insufficient capacity' 1`] = `
The server has reached its maximum capacity and you cannot join the call at this time. Try again later, or contact your server admin if the problem persists. The server has reached its maximum capacity and you cannot join the call at this time. Try again later, or contact your server admin if the problem persists.
</p> </p>
<button <button
class="_button_i91xf_17 homeLink" class="_button_vczzf_8 homeLink"
data-kind="tertiary" data-kind="tertiary"
data-size="lg" data-size="lg"
role="button" role="button"
+229 -19
View File
@@ -5,9 +5,56 @@ exports[`InCallView > rendering > renders 1`] = `
<div <div
class="inRoom" class="inRoom"
> >
<div <header
class="header filler" class="header header"
/> >
<div
class="nav leftNav"
>
<div
class="roomHeaderInfo"
data-size="lg"
>
<span
aria-label=""
class="_avatar_1qbcf_8 roomAvatar _avatar-imageless_1qbcf_52"
data-color="1"
data-type="round"
role="img"
style="--cpd-avatar-size: 56px;"
/>
<div
class="nameLine"
>
<h1
class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
data-testid="roomHeader_roomName"
/>
<span
tabindex="0"
>
<svg
aria-labelledby="«r0»"
class="lock"
data-encrypted="false"
fill="currentColor"
height="16"
viewBox="0 0 24 24"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6 22q-.825 0-1.412-.587A1.93 1.93 0 0 1 4 20V10q0-.825.588-1.412a2 2 0 0 1 .702-.463L1.333 4.167a1 1 0 0 1 1.414-1.414L7 7.006v-.012l13 13v.012l1.247 1.247a1 1 0 1 1-1.414 1.414l-.896-.896A1.94 1.94 0 0 1 18 22zm14-4.834V10q0-.825-.587-1.412A1.93 1.93 0 0 0 18 8h-1V6q0-2.075-1.463-3.537Q14.075 1 12 1T8.463 2.463a4.9 4.9 0 0 0-1.22 1.946L9 6.166V6q0-1.25.875-2.125A2.9 2.9 0 0 1 12 3q1.25 0 2.125.875T15 6v2h-4.166z"
/>
</svg>
</span>
</div>
</div>
</div>
<div
class="nav rightNav"
/>
</header>
<div> <div>
mocked: MatrixAudioRenderer mocked: MatrixAudioRenderer
</div> </div>
@@ -35,19 +82,182 @@ exports[`InCallView > rendering > renders 1`] = `
> >
<div /> <div />
</div> </div>
<div
class="overlay"
data-show="false"
>
<div
class="_content_o77nw_8 icon"
data-size="large"
>
<svg
aria-hidden="true"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<g
clip-path="url(#a)"
>
<path
clip-rule="evenodd"
d="M8.929 15.1a13.6 13.6 0 0 0 4.654 3.066q2.62 1.036 5.492.923h.008l.003-.004.003-.002-.034-3.124-3.52-.483-1.791 1.792-.645-.322a13.5 13.5 0 0 1-3.496-2.52 13.4 13.4 0 0 1-2.52-3.496l-.322-.644 1.792-1.792-.483-3.519-3.123-.034-.003.002-.003.004v.002a13.65 13.65 0 0 0 .932 5.492A13.4 13.4 0 0 0 8.93 15.1m3.92 4.926a15.6 15.6 0 0 1-5.334-3.511 15.4 15.4 0 0 1-3.505-5.346 15.6 15.6 0 0 1-1.069-6.274 1.93 1.93 0 0 1 .589-1.366c.366-.366.84-.589 1.386-.589h.01l3.163.035a1.96 1.96 0 0 1 1.958 1.694v.005l.487 3.545v.003c.043.297.025.605-.076.907a2 2 0 0 1-.485.773l-.762.762a11.4 11.4 0 0 0 3.206 3.54q.457.33.948.614l.762-.761a2 2 0 0 1 .774-.486c.302-.1.61-.118.907-.076l3.553.487a1.96 1.96 0 0 1 1.694 1.958l.034 3.174c0 .546-.223 1.02-.588 1.386-.361.36-.827.582-1.363.588a15.3 15.3 0 0 1-6.29-1.062"
fill-rule="evenodd"
/>
</g>
<defs>
<clippath
id="a"
>
<path
d="M0 0h24v24H0z"
/>
</clippath>
</defs>
</svg>
</div>
<h2
class="_typography_6v6n8_153 _font-heading-md-semibold_6v6n8_112"
>
Handset Mode
</h2>
<p
class="_typography_6v6n8_153 _font-body-md-regular_6v6n8_50"
>
Only works while using app
</p>
<button
class="_button_vczzf_8"
data-kind="primary"
data-size="sm"
role="button"
tabindex="0"
>
Back to Speaker Mode
</button>
<div
class="spacer"
/>
</div>
<div <div
class="container" class="container"
/> />
<div <div
class="footer" class="footer"
> >
<div
class="logo"
>
<svg
aria-hidden="true"
fill="none"
height="24"
viewBox="0 0 48 48"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<g
id="Logo Mark"
>
<rect
fill="#0DBD8B"
height="48"
rx="23.93"
width="47.86"
/>
<g
id="Union"
>
<path
d="M21.3075 9.42871C20.3396 9.42871 19.5549 10.214 19.5549 11.1828C19.5549 12.1516 20.3396 12.9369 21.3075 12.9369C25.9321 12.9369 29.6811 16.689 29.6811 21.3175C29.6811 22.2863 30.4657 23.0716 31.4337 23.0716C32.4016 23.0716 33.1863 22.2863 33.1863 21.3175C33.1863 14.7515 27.868 9.42871 21.3075 9.42871Z"
fill="white"
/>
<path
d="M38.4591 21.3174C38.4591 20.3486 37.6745 19.5633 36.7065 19.5633C35.7386 19.5633 34.9539 20.3486 34.9539 21.3174C34.9539 25.9459 31.2049 29.698 26.5804 29.698C25.6124 29.698 24.8277 30.4833 24.8277 31.4521C24.8277 32.4209 25.6124 33.2062 26.5804 33.2062C33.1408 33.2062 38.4591 27.8834 38.4591 21.3174Z"
fill="white"
/>
<path
d="M28.3329 36.8173C28.3329 37.786 27.5482 38.5714 26.5803 38.5714C20.0198 38.5714 14.7015 33.2486 14.7015 26.6826C14.7015 25.7138 15.4862 24.9285 16.4541 24.9285C17.4221 24.9285 18.2067 25.7138 18.2067 26.6826C18.2067 31.3111 21.9557 35.0632 26.5803 35.0632C27.5482 35.0632 28.3329 35.8485 28.3329 36.8173Z"
fill="white"
/>
<path
d="M9.40112 26.6827C9.40112 27.6514 10.1858 28.4368 11.1537 28.4368C12.1217 28.4368 12.9064 27.6514 12.9064 26.6827C12.9064 22.0542 16.6553 18.3021 21.2799 18.3021C22.2478 18.3021 23.0325 17.5167 23.0325 16.548C23.0325 15.5792 22.2478 14.7939 21.2799 14.7939C14.7194 14.7939 9.40112 20.1167 9.40112 26.6827Z"
fill="white"
/>
</g>
</g>
</svg>
<svg
aria-label="Element Call"
fill="none"
height="11"
viewBox="0 0 160 22"
width="80"
xmlns="http://www.w3.org/2000/svg"
>
<g
id="Logo Type"
>
<g
id="Vector"
>
<path
d="M14.8673 15.1575H3.39742C3.53293 16.3508 3.96849 17.3036 4.70411 18.0157C5.43974 18.7087 6.40766 19.0551 7.60789 19.0551C8.40159 19.0551 9.11785 18.8626 9.75668 18.4777C10.3955 18.0927 10.8504 17.5731 11.1215 16.9186H14.606C14.1414 18.4392 13.2702 19.671 11.9926 20.6142C10.7343 21.5381 9.24368 22 7.52078 22C5.27519 22 3.45549 21.259 2.06168 19.7769C0.687227 18.2948 0 16.4182 0 14.147C0 11.9335 0.696906 10.0761 2.09072 8.5748C3.48453 7.07349 5.28487 6.32283 7.49174 6.32283C9.69861 6.32283 11.4796 7.06387 12.8347 8.54593C14.2091 10.0087 14.8964 11.8565 14.8964 14.0892L14.8673 15.1575ZM7.49174 9.12336C6.40766 9.12336 5.50749 9.44095 4.79123 10.0761C4.07496 10.7113 3.62972 11.5582 3.45549 12.6168H11.4699C11.315 11.5582 10.8892 10.7113 10.1922 10.0761C9.49534 9.44095 8.59517 9.12336 7.49174 9.12336Z"
fill="currentColor"
/>
<path
d="M17.2743 17.1785V0H20.7298V17.2362C20.7298 18.0061 21.1557 18.3911 22.0074 18.3911L22.6172 18.3622V21.6247C22.2881 21.6824 21.9397 21.7113 21.5719 21.7113C20.0813 21.7113 18.9875 21.336 18.2906 20.5853C17.6131 19.8346 17.2743 18.699 17.2743 17.1785Z"
fill="currentColor"
/>
<path
d="M38.71 15.1575H27.2401C27.3756 16.3508 27.8112 17.3036 28.5468 18.0157C29.2824 18.7087 30.2504 19.0551 31.4506 19.0551C32.2443 19.0551 32.9606 18.8626 33.5994 18.4777C34.2382 18.0927 34.6931 17.5731 34.9642 16.9186H38.4487C37.9841 18.4392 37.113 19.671 35.8353 20.6142C34.577 21.5381 33.0864 22 31.3635 22C29.1179 22 27.2982 21.259 25.9044 19.7769C24.5299 18.2948 23.8427 16.4182 23.8427 14.147C23.8427 11.9335 24.5396 10.0761 25.9334 8.5748C27.3272 7.07349 29.1276 6.32283 31.3344 6.32283C33.5413 6.32283 35.3223 7.06387 36.6774 8.54593C38.0518 10.0087 38.7391 11.8565 38.7391 14.0892L38.71 15.1575ZM31.3344 9.12336C30.2504 9.12336 29.3502 9.44095 28.6339 10.0761C27.9177 10.7113 27.4724 11.5582 27.2982 12.6168H35.3126C35.1577 11.5582 34.7319 10.7113 34.035 10.0761C33.3381 9.44095 32.4379 9.12336 31.3344 9.12336Z"
fill="currentColor"
/>
<path
d="M54.3001 13.0499V21.6535H50.8446V12.6745C50.8446 10.4033 49.8961 9.26772 47.9989 9.26772C46.9729 9.26772 46.1502 9.59493 45.5307 10.2493C44.9306 10.9038 44.6306 11.7988 44.6306 12.9344V21.6535H41.1751V6.66929H44.3692V8.66142C44.737 7.98775 45.2984 7.42957 46.0534 6.98688C46.8084 6.54418 47.7473 6.32283 48.8701 6.32283C50.9608 6.32283 52.4707 7.11199 53.4 8.69029C54.6776 7.11199 56.3812 6.32283 58.5106 6.32283C60.2722 6.32283 61.6273 6.87139 62.5759 7.9685C63.5244 9.04637 63.9987 10.4707 63.9987 12.2415V21.6535H60.5432V12.6745C60.5432 10.4033 59.5947 9.26772 57.6975 9.26772C56.6522 9.26772 55.8198 9.60455 55.2003 10.2782C54.6002 10.9326 54.3001 11.8565 54.3001 13.0499Z"
fill="currentColor"
/>
<path
d="M81.1834 15.1575H69.7135C69.849 16.3508 70.2846 17.3036 71.0202 18.0157C71.7558 18.7087 72.7237 19.0551 73.924 19.0551C74.7177 19.0551 75.4339 18.8626 76.0728 18.4777C76.7116 18.0927 77.1665 17.5731 77.4375 16.9186H80.9221C80.4575 18.4392 79.5863 19.671 78.3087 20.6142C77.0504 21.5381 75.5598 22 73.8369 22C71.5913 22 69.7716 21.259 68.3778 19.7769C67.0033 18.2948 66.3161 16.4182 66.3161 14.147C66.3161 11.9335 67.013 10.0761 68.4068 8.5748C69.8006 7.07349 71.601 6.32283 73.8078 6.32283C76.0147 6.32283 77.7957 7.06387 79.1508 8.54593C80.5252 10.0087 81.2124 11.8565 81.2124 14.0892L81.1834 15.1575ZM73.8078 9.12336C72.7237 9.12336 71.8236 9.44095 71.1073 10.0761C70.391 10.7113 69.9458 11.5582 69.7716 12.6168H77.786C77.6311 11.5582 77.2052 10.7113 76.5083 10.0761C75.8114 9.44095 74.9113 9.12336 73.8078 9.12336Z"
fill="currentColor"
/>
<path
d="M86.8426 6.66929V8.66142C87.191 8.007 87.7621 7.45844 88.5558 7.01575C89.3689 6.55381 90.3465 6.32283 91.4886 6.32283C93.2696 6.32283 94.6441 6.86177 95.612 7.93963C96.5993 9.0175 97.0929 10.4514 97.0929 12.2415V21.6535H93.6374V12.6745C93.6374 11.6159 93.3858 10.7883 92.8824 10.1916C92.3985 9.57568 91.6532 9.26772 90.6465 9.26772C89.5431 9.26772 88.672 9.59493 88.0331 10.2493C87.4137 10.9038 87.1039 11.8084 87.1039 12.9633V21.6535H83.6484V6.66929H86.8426Z"
fill="currentColor"
/>
<path
d="M107.185 18.5932V21.5669C106.759 21.6824 106.159 21.7402 105.384 21.7402C102.442 21.7402 100.971 20.2677 100.971 17.3228V9.41208H98.6766V6.66929H100.971V2.77165H104.426V6.66929H107.243V9.41208H104.426V16.9764C104.426 18.1505 104.987 18.7375 106.11 18.7375L107.185 18.5932Z"
fill="currentColor"
/>
<path
d="M116.115 18.9881C114.474 17.2035 113.653 14.9429 113.653 12.2064C113.653 9.4699 114.474 7.21782 116.115 5.45015C117.773 3.66548 119.953 2.77314 122.654 2.77314C124.876 2.77314 126.756 3.38503 128.295 4.6088C129.833 5.83258 130.816 7.47277 131.244 9.52939H129.269C128.91 7.99967 128.132 6.7844 126.936 5.88357C125.739 4.98273 124.312 4.53232 122.654 4.53232C120.534 4.53232 118.824 5.23769 117.525 6.64842C116.243 8.05916 115.602 9.91182 115.602 12.2064C115.602 14.501 116.243 16.3536 117.525 17.7644C118.824 19.1751 120.534 19.8805 122.654 19.8805C124.312 19.8805 125.739 19.4301 126.936 18.5292C128.132 17.6284 128.91 16.4131 129.269 14.8834H131.244C130.816 16.94 129.833 18.5802 128.295 19.804C126.756 21.0278 124.876 21.6397 122.654 21.6397C119.953 21.6397 117.773 20.7558 116.115 18.9881Z"
fill="currentColor"
/>
<path
d="M143.174 15.0874C140.832 15.0874 139.233 15.1384 138.379 15.2403C137.541 15.3253 136.926 15.4698 136.532 15.6738C135.831 16.0647 135.481 16.6936 135.481 17.5604C135.481 19.2261 136.473 20.0589 138.456 20.0589C139.977 20.0589 141.139 19.719 141.943 19.0391C142.763 18.3593 143.174 17.4499 143.174 16.3111V15.0874ZM138.25 21.5632C136.763 21.5632 135.626 21.2062 134.84 20.4924C134.071 19.7615 133.686 18.8012 133.686 17.6114C133.686 16.8295 133.891 16.1327 134.301 15.5208C134.729 14.9089 135.31 14.4585 136.045 14.1695C136.661 13.9316 137.455 13.7786 138.43 13.7106C139.404 13.6256 140.986 13.5831 143.174 13.5831V12.7418C143.174 10.6002 141.943 9.52939 139.481 9.52939C137.361 9.52939 136.131 10.3877 135.789 12.1044H134.019C134.207 10.8466 134.746 9.84383 135.635 9.09597C136.541 8.34811 137.849 7.97418 139.558 7.97418C141.387 7.97418 142.746 8.3991 143.635 9.24894C144.541 10.0988 144.994 11.2716 144.994 12.7673V21.2572H143.251V19.3706C142.345 20.8323 140.678 21.5632 138.25 21.5632Z"
fill="currentColor"
/>
<path
d="M149.358 18.4018V2.13576H151.178V18.1978C151.178 18.7247 151.264 19.0901 151.435 19.2941C151.623 19.498 151.956 19.6 152.435 19.6L152.948 19.549V21.2062C152.657 21.2572 152.341 21.2827 151.999 21.2827C150.238 21.2827 149.358 20.3224 149.358 18.4018Z"
fill="currentColor"
/>
<path
d="M155.944 18.4018V2.13576H157.764V18.1978C157.764 18.7247 157.85 19.0901 158.021 19.2941C158.209 19.498 158.542 19.6 159.021 19.6L159.534 19.549V21.2062C159.243 21.2572 158.927 21.2827 158.585 21.2827C156.824 21.2827 155.944 20.3224 155.944 18.4018Z"
fill="currentColor"
/>
</g>
</g>
</svg>
</div>
<div <div
class="buttons" class="buttons"
> >
<button <button
aria-disabled="false" aria-disabled="false"
aria-labelledby=":r0:" aria-labelledby="«r5»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
data-testid="incall_mute" data-testid="incall_mute"
@@ -63,14 +273,14 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M8 8v-.006l6.831 6.832-.002.002 1.414 1.415.003-.003 1.414 1.414-.003.003L20.5 20.5a1 1 0 0 1-1.414 1.414l-3.022-3.022A7.949 7.949 0 0 1 13 19.938V21a1 1 0 0 1-2 0v-1.062A8.001 8.001 0 0 1 4 12a1 1 0 1 1 2 0 6 6 0 0 0 8.587 5.415l-1.55-1.55A4.005 4.005 0 0 1 8 12v-1.172L2.086 4.914A1 1 0 0 1 3.5 3.5L8 8Zm9.417 6.583 1.478 1.477A7.963 7.963 0 0 0 20 12a1 1 0 0 0-2 0c0 .925-.21 1.8-.583 2.583ZM8.073 5.238l7.793 7.793c.087-.329.134-.674.134-1.031V6a4 4 0 0 0-7.927-.762Z" d="M8 8v-.006l6.831 6.832-.002.002 1.414 1.415.003-.003 1.414 1.414-.003.003L20.5 20.5a1 1 0 0 1-1.414 1.414l-3.022-3.022A7.95 7.95 0 0 1 13 19.938V21a1 1 0 0 1-2 0v-1.062A8 8 0 0 1 4 12a1 1 0 1 1 2 0 6 6 0 0 0 8.587 5.415l-1.55-1.55A4.005 4.005 0 0 1 8 12v-1.172L2.086 4.914A1 1 0 0 1 3.5 3.5zm9.417 6.583 1.478 1.477A7.96 7.96 0 0 0 20 12a1 1 0 0 0-2 0c0 .925-.21 1.8-.583 2.583M8.073 5.238l7.793 7.793q.132-.495.134-1.031V6a4 4 0 0 0-7.927-.762"
/> />
</svg> </svg>
</button> </button>
<button <button
aria-disabled="false" aria-disabled="false"
aria-labelledby=":r5:" aria-labelledby="«ra»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
data-testid="incall_videomute" data-testid="incall_videomute"
@@ -86,13 +296,13 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M2.747 2.753 4.35 4.355l.007-.003L18 17.994v.012l3.247 3.247a1 1 0 0 1-1.414 1.414l-2.898-2.898A1.992 1.992 0 0 1 16 20H6a4 4 0 0 1-4-4V8c0-.892.292-1.715.785-2.38L1.333 4.166a1 1 0 0 1 1.414-1.414ZM18 15.166 6.834 4H16a2 2 0 0 1 2 2v4.286l3.35-2.871a1 1 0 0 1 1.65.76v7.65a1 1 0 0 1-1.65.76L18 13.715v1.45Z" d="M2.747 2.753 4.35 4.355l.007-.003L18 17.994v.012l3.247 3.247a1 1 0 0 1-1.414 1.414l-2.898-2.898A2 2 0 0 1 16 20H6a4 4 0 0 1-4-4V8c0-.892.292-1.715.785-2.38L1.333 4.166a1 1 0 0 1 1.414-1.414M18 15.166 6.834 4H16a2 2 0 0 1 2 2v4.286l3.35-2.871a1 1 0 0 1 1.65.76v7.65a1 1 0 0 1-1.65.76L18 13.715z"
/> />
</svg> </svg>
</button> </button>
<button <button
aria-labelledby=":ra:" aria-labelledby="«rf»"
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59" class="_button_vczzf_8 _has-icon_vczzf_57 _icon-only_vczzf_50"
data-kind="secondary" data-kind="secondary"
data-size="lg" data-size="lg"
role="button" role="button"
@@ -107,13 +317,13 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M12.731 2C13.432 2 14 2.568 14 3.269c0 .578.396 1.074.935 1.286.085.034.17.07.253.106.531.23 1.162.16 1.572-.25a1.269 1.269 0 0 1 1.794 0l1.034 1.035a1.269 1.269 0 0 1 0 1.794c-.41.41-.48 1.04-.248 1.572.036.084.07.168.105.253.212.539.708.935 1.286.935.701 0 1.269.568 1.269 1.269v1.462c0 .701-.568 1.269-1.269 1.269-.578 0-1.074.396-1.287.935-.033.085-.068.17-.104.253-.232.531-.161 1.162.248 1.572a1.269 1.269 0 0 1 0 1.794l-1.034 1.034a1.269 1.269 0 0 1-1.794 0c-.41-.41-1.04-.48-1.572-.248a7.935 7.935 0 0 1-.253.105c-.539.212-.935.708-.935 1.286 0 .701-.568 1.269-1.269 1.269H11.27c-.702 0-1.27-.568-1.27-1.269 0-.578-.396-1.074-.935-1.287a7.975 7.975 0 0 1-.253-.104c-.531-.232-1.162-.161-1.572.248a1.269 1.269 0 0 1-1.794 0l-1.034-1.034a1.269 1.269 0 0 1 0-1.794c.41-.41.48-1.04.249-1.572a7.89 7.89 0 0 1-.106-.253C4.343 14.396 3.847 14 3.27 14 2.568 14 2 13.432 2 12.731V11.27c0-.702.568-1.27 1.269-1.27.578 0 1.074-.396 1.286-.935.034-.085.07-.17.106-.253.23-.531.16-1.162-.25-1.572a1.269 1.269 0 0 1 0-1.794l1.035-1.034a1.269 1.269 0 0 1 1.794 0c.41.41 1.04.48 1.572.249a7.93 7.93 0 0 1 .253-.106c.539-.212.935-.708.935-1.286C10 2.568 10.568 2 11.269 2h1.462ZM12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8Z" d="M12.731 2C13.432 2 14 2.568 14 3.269c0 .578.396 1.074.935 1.286q.128.052.253.106c.531.23 1.162.16 1.572-.25a1.27 1.27 0 0 1 1.794 0l1.034 1.035a1.27 1.27 0 0 1 0 1.794c-.41.41-.48 1.04-.248 1.572l.105.253c.212.539.708.935 1.286.935.701 0 1.269.568 1.269 1.269v1.462c0 .701-.568 1.269-1.269 1.269-.578 0-1.074.396-1.287.935q-.05.128-.104.253c-.232.531-.161 1.162.248 1.572a1.27 1.27 0 0 1 0 1.794l-1.034 1.034a1.27 1.27 0 0 1-1.794 0c-.41-.41-1.04-.48-1.572-.248a8 8 0 0 1-.253.105c-.539.212-.935.708-.935 1.286 0 .701-.568 1.269-1.269 1.269H11.27c-.702 0-1.27-.568-1.27-1.269 0-.578-.396-1.074-.935-1.287a8 8 0 0 1-.253-.104c-.531-.232-1.162-.161-1.572.248a1.27 1.27 0 0 1-1.794 0l-1.034-1.034a1.27 1.27 0 0 1 0-1.794c.41-.41.48-1.04.249-1.572a8 8 0 0 1-.106-.253C4.343 14.396 3.847 14 3.27 14 2.568 14 2 13.432 2 12.731V11.27c0-.702.568-1.27 1.269-1.27.578 0 1.074-.396 1.286-.935q.052-.128.106-.253c.23-.531.16-1.162-.25-1.572a1.27 1.27 0 0 1 0-1.794l1.035-1.034a1.27 1.27 0 0 1 1.794 0c.41.41 1.04.48 1.572.249a8 8 0 0 1 .253-.106c.539-.212.935-.708.935-1.286C10 2.568 10.568 2 11.269 2zM12 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8"
/> />
</svg> </svg>
</button> </button>
<button <button
aria-labelledby=":rf:" aria-labelledby="«rk»"
class="_button_i91xf_17 endCall _has-icon_i91xf_66 _icon-only_i91xf_59 _destructive_i91xf_116" class="_button_vczzf_8 endCall _has-icon_vczzf_57 _icon-only_vczzf_50 _destructive_vczzf_107"
data-kind="primary" data-kind="primary"
data-size="lg" data-size="lg"
data-testid="incall_leave" data-testid="incall_leave"
@@ -129,7 +339,7 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="m2.765 16.02-2.47-2.416A1.018 1.018 0 0 1 0 12.852c0-.304.098-.555.295-.751a15.64 15.64 0 0 1 5.316-3.786A15.89 15.89 0 0 1 12 7c2.237 0 4.367.443 6.39 1.329a15.977 15.977 0 0 1 5.315 3.772c.197.196.295.447.295.751 0 .305-.098.555-.295.752l-2.47 2.416a1.047 1.047 0 0 1-1.396.108l-3.114-2.363a1.067 1.067 0 0 1-.322-.376 1.066 1.066 0 0 1-.108-.483v-2.27a13.593 13.593 0 0 0-2.12-.524C13.459 9.996 12 9.937 12 9.937s-1.459.059-2.175.175c-.715.116-1.422.29-2.12.523v2.271c0 .179-.036.34-.108.483a1.066 1.066 0 0 1-.322.376l-3.114 2.363a1.047 1.047 0 0 1-1.396-.107Z" d="m2.765 16.02-2.47-2.416A1.02 1.02 0 0 1 0 12.852q0-.456.295-.751a15.6 15.6 0 0 1 5.316-3.786A15.9 15.9 0 0 1 12 7q3.355 0 6.39 1.329a16 16 0 0 1 5.315 3.772q.295.294.295.751t-.295.752l-2.47 2.416a1.047 1.047 0 0 1-1.396.108l-3.114-2.363a1.1 1.1 0 0 1-.322-.376 1.1 1.1 0 0 1-.108-.483v-2.27a13.6 13.6 0 0 0-2.12-.524C13.459 9.996 12 9.937 12 9.937s-1.459.059-2.174.175q-1.074.174-2.121.523v2.271q0 .268-.108.483a1.1 1.1 0 0 1-.322.376l-3.114 2.363a1.047 1.047 0 0 1-1.396-.107"
/> />
</svg> </svg>
</button> </button>
@@ -138,7 +348,7 @@ exports[`InCallView > rendering > renders 1`] = `
class="toggle layout" class="toggle layout"
> >
<input <input
aria-labelledby=":rk:" aria-labelledby="«rp»"
name="layout" name="layout"
type="radio" type="radio"
value="spotlight" value="spotlight"
@@ -152,11 +362,11 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M5 5h14v8h-5a1 1 0 0 0-1 1v5H5V5Zm10 14v-4h4v4h-4ZM5 21h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2Z" d="M5 5h14v8h-5a1 1 0 0 0-1 1v5H5zm10 14v-4h4v4zM5 21h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2"
/> />
</svg> </svg>
<input <input
aria-labelledby=":rp:" aria-labelledby="«ru»"
checked="" checked=""
name="layout" name="layout"
type="radio" type="radio"
@@ -171,7 +381,7 @@ exports[`InCallView > rendering > renders 1`] = `
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
> >
<path <path
d="M4 11a.967.967 0 0 1-.712-.287A.968.968 0 0 1 3 10V4c0-.283.096-.52.288-.712A.968.968 0 0 1 4 3h6a.97.97 0 0 1 .713.288A.968.968 0 0 1 11 4v6c0 .283-.096.52-.287.713A.968.968 0 0 1 10 11H4Zm5-2V5H5v4h4Zm5 12a.968.968 0 0 1-.713-.288A.968.968 0 0 1 13 20v-6c0-.283.096-.52.287-.713A.968.968 0 0 1 14 13h6a.97.97 0 0 1 .712.287c.192.192.288.43.288.713v6c0 .283-.096.52-.288.712A.968.968 0 0 1 20 21h-6Zm5-2v-4h-4v4h4ZM4 21a.967.967 0 0 1-.712-.288A.968.968 0 0 1 3 20v-6a.97.97 0 0 1 .288-.713A.967.967 0 0 1 4 13h6c.283 0 .52.096.713.287.191.192.287.43.287.713v6a.97.97 0 0 1-.287.712A.968.968 0 0 1 10 21H4Zm5-2v-4H5v4h4Zm5-8a.968.968 0 0 1-.713-.287A.968.968 0 0 1 13 10V4a.97.97 0 0 1 .287-.712A.968.968 0 0 1 14 3h6c.283 0 .52.096.712.288A.965.965 0 0 1 21 4v6a.97.97 0 0 1-.288.713A.968.968 0 0 1 20 11h-6Zm5-2V5h-4v4h4Z" d="M4 11a.97.97 0 0 1-.712-.287A.97.97 0 0 1 3 10V4q0-.424.288-.712A.97.97 0 0 1 4 3h6q.424 0 .713.288Q11 3.575 11 4v6q0 .424-.287.713A.97.97 0 0 1 10 11zm5-2V5H5v4zm5 12a.97.97 0 0 1-.713-.288A.97.97 0 0 1 13 20v-6q0-.424.287-.713A.97.97 0 0 1 14 13h6q.424 0 .712.287.288.288.288.713v6q0 .424-.288.712A.97.97 0 0 1 20 21zm5-2v-4h-4v4zM4 21a.97.97 0 0 1-.712-.288A.97.97 0 0 1 3 20v-6q0-.424.288-.713A.97.97 0 0 1 4 13h6q.424 0 .713.287.287.288.287.713v6q0 .424-.287.712A.97.97 0 0 1 10 21zm5-2v-4H5v4zm5-8a.97.97 0 0 1-.713-.287A.97.97 0 0 1 13 10V4q0-.424.287-.712A.97.97 0 0 1 14 3h6q.424 0 .712.288Q21 3.575 21 4v6q0 .424-.288.713A.97.97 0 0 1 20 11zm5-2V5h-4v4z"
/> />
</svg> </svg>
</div> </div>
+21 -35
View File
@@ -9,11 +9,13 @@ import {
type MatrixRTCSession, type MatrixRTCSession,
MatrixRTCSessionEvent, MatrixRTCSessionEvent,
} from "matrix-js-sdk/lib/matrixrtc"; } from "matrix-js-sdk/lib/matrixrtc";
import { useCallback, useEffect, useState } from "react"; import { useCallback, useRef } from "react";
import { deepCompare } from "matrix-js-sdk/lib/utils"; import { deepCompare } from "matrix-js-sdk/lib/utils";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { type LivekitFocus, isLivekitFocus } from "matrix-js-sdk/lib/matrixrtc"; import { type LivekitFocus, isLivekitFocus } from "matrix-js-sdk/lib/matrixrtc";
import { useTypedEventEmitterState } from "../useEvents";
/** /**
* Gets the currently active (livekit) focus for a MatrixRTC session * Gets the currently active (livekit) focus for a MatrixRTC session
* This logic is specific to livekit foci where the whole call must use one * This logic is specific to livekit foci where the whole call must use one
@@ -22,38 +24,22 @@ import { type LivekitFocus, isLivekitFocus } from "matrix-js-sdk/lib/matrixrtc";
export function useActiveLivekitFocus( export function useActiveLivekitFocus(
rtcSession: MatrixRTCSession, rtcSession: MatrixRTCSession,
): LivekitFocus | undefined { ): LivekitFocus | undefined {
const [activeFocus, setActiveFocus] = useState(() => { const prevActiveFocus = useRef<LivekitFocus | undefined>(undefined);
const f = rtcSession.getActiveFocus(); return useTypedEventEmitterState(
// Only handle foci with type="livekit" for now. rtcSession,
return !!f && isLivekitFocus(f) ? f : undefined; MatrixRTCSessionEvent.MembershipsChanged,
}); useCallback(() => {
const f = rtcSession.getActiveFocus();
const onMembershipsChanged = useCallback(() => { // Only handle foci with type="livekit" for now.
const newActiveFocus = rtcSession.getActiveFocus(); if (f && isLivekitFocus(f) && !deepCompare(f, prevActiveFocus.current)) {
if (!!newActiveFocus && !isLivekitFocus(newActiveFocus)) return; const oldestMembership = rtcSession.getOldestMembership();
if (!deepCompare(activeFocus, newActiveFocus)) { logger.info(
const oldestMembership = rtcSession.getOldestMembership(); `Got new active focus from membership: ${oldestMembership?.sender}/${oldestMembership?.deviceId}.
logger.warn( Updated focus (focus switch) from ${JSON.stringify(prevActiveFocus.current)} to ${JSON.stringify(f)}`,
`Got new active focus from membership: ${oldestMembership?.sender}/${oldestMembership?.deviceId}. );
Updating focus (focus switch) from ${JSON.stringify(activeFocus)} to ${JSON.stringify(newActiveFocus)}`, prevActiveFocus.current = f;
); }
setActiveFocus(newActiveFocus); return prevActiveFocus.current;
} }, [rtcSession]),
}, [activeFocus, rtcSession]); );
useEffect(() => {
rtcSession.on(
MatrixRTCSessionEvent.MembershipsChanged,
onMembershipsChanged,
);
return (): void => {
rtcSession.off(
MatrixRTCSessionEvent.MembershipsChanged,
onMembershipsChanged,
);
};
});
return activeFocus;
} }
+8 -7
View File
@@ -1,18 +1,19 @@
/* /*
Copyright 2023, 2024 New Vector Ltd. Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type Room, RoomEvent } from "matrix-js-sdk"; import { type Room, RoomEvent } from "matrix-js-sdk";
import { useState } from "react"; import { useCallback } from "react";
import { useTypedEventEmitter } from "../useEvents"; import { useTypedEventEmitterState } from "../useEvents";
export function useRoomName(room: Room): string { export function useRoomName(room: Room): string {
const [, setNumUpdates] = useState(0); return useTypedEventEmitterState(
// Whenever the name changes, force an update room,
useTypedEventEmitter(room, RoomEvent.Name, () => setNumUpdates((n) => n + 1)); RoomEvent.Name,
return room.name; useCallback(() => room.name, [room]),
);
} }
+20 -12
View File
@@ -5,10 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { useCallback, useMemo, useState } from "react"; import { useCallback } from "react";
import { type RoomState, RoomStateEvent, type Room } from "matrix-js-sdk"; import {
type RoomState,
RoomStateEvent,
type Room,
RoomEvent,
} from "matrix-js-sdk";
import { useTypedEventEmitter } from "../useEvents"; import { useTypedEventEmitterState } from "../useEvents";
/** /**
* A React hook for values computed from room state. * A React hook for values computed from room state.
@@ -16,14 +21,17 @@ import { useTypedEventEmitter } from "../useEvents";
* @param f A mapping from the current room state to the computed value. * @param f A mapping from the current room state to the computed value.
* @returns The computed value. * @returns The computed value.
*/ */
export const useRoomState = <T>(room: Room, f: (state: RoomState) => T): T => { export function useRoomState<T>(room: Room, f: (state: RoomState) => T): T {
const [numUpdates, setNumUpdates] = useState(0); // TODO: matrix-js-sdk says that Room.currentState is deprecated, but it's not
useTypedEventEmitter( // clear how to reactively track the current state of the room without it
const currentState = useTypedEventEmitterState(
room, room,
RoomStateEvent.Update, RoomEvent.CurrentStateUpdated,
useCallback(() => setNumUpdates((n) => n + 1), [setNumUpdates]), useCallback(() => room.currentState, [room]),
); );
// We want any change to the update counter to trigger an update here return useTypedEventEmitterState(
// eslint-disable-next-line react-hooks/exhaustive-deps currentState,
return useMemo(() => f(room.currentState), [room, f, numUpdates]); RoomStateEvent.Update,
}; useCallback(() => f(currentState), [f, currentState]),
);
}
+1 -1
View File
@@ -22,7 +22,7 @@ import {
import { useObservable, useObservableEagerState } from "observable-hooks"; import { useObservable, useObservableEagerState } from "observable-hooks";
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { useMediaDevices } from "../livekit/MediaDevicesContext"; import { useMediaDevices } from "../MediaDevicesContext";
import { platform } from "../Platform"; import { platform } from "../Platform";
import { useLatest } from "../useLatest"; import { useLatest } from "../useLatest";
+15 -4
View File
@@ -18,8 +18,8 @@ import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery";
import { PosthogAnalytics } from "./analytics/PosthogAnalytics"; import { PosthogAnalytics } from "./analytics/PosthogAnalytics";
import { Config } from "./config/Config"; import { Config } from "./config/Config";
import { ElementWidgetActions, widget, type WidgetHelpers } from "./widget"; import { ElementWidgetActions, widget, type WidgetHelpers } from "./widget";
import { MatrixRTCFocusMissingError } from "./utils/errors.ts"; import { MatrixRTCFocusMissingError } from "./utils/errors";
import { getUrlParams } from "./UrlParams.ts"; import { getUrlParams } from "./UrlParams";
const FOCI_WK_KEY = "org.matrix.msc4143.rtc_foci"; const FOCI_WK_KEY = "org.matrix.msc4143.rtc_foci";
@@ -116,15 +116,26 @@ export async function enterRTCSession(
await makePreferredLivekitFoci(rtcSession, livekitAlias), await makePreferredLivekitFoci(rtcSession, livekitAlias),
makeActiveFocus(), makeActiveFocus(),
{ {
notificationType: getUrlParams().sendNotificationType,
useNewMembershipManager, useNewMembershipManager,
manageMediaKeys: encryptMedia, manageMediaKeys: encryptMedia,
...(useDeviceSessionMemberEvents !== undefined && { ...(useDeviceSessionMemberEvents !== undefined && {
useLegacyMemberEvents: !useDeviceSessionMemberEvents, useLegacyMemberEvents: !useDeviceSessionMemberEvents,
}), }),
delayedLeaveEventRestartMs:
matrixRtcSessionConfig?.delayed_leave_event_restart_ms ??
matrixRtcSessionConfig?.membership_keep_alive_period,
delayedLeaveEventDelayMs: delayedLeaveEventDelayMs:
matrixRtcSessionConfig?.delayed_leave_event_delay_ms ??
matrixRtcSessionConfig?.membership_server_side_expiry_timeout, matrixRtcSessionConfig?.membership_server_side_expiry_timeout,
networkErrorRetryMs: matrixRtcSessionConfig?.membership_keep_alive_period, delayedLeaveEventRestartLocalTimeoutMs:
makeKeyDelay: matrixRtcSessionConfig?.key_rotation_on_leave_delay, matrixRtcSessionConfig?.delayed_leave_event_restart_local_timeout_ms,
networkErrorRetryMs: matrixRtcSessionConfig?.network_error_retry_ms,
makeKeyDelay:
matrixRtcSessionConfig?.wait_for_key_rotation_ms ??
matrixRtcSessionConfig?.key_rotation_on_leave_delay,
membershipEventExpiryMs:
matrixRtcSessionConfig?.membership_event_expiry_ms,
useExperimentalToDeviceTransport, useExperimentalToDeviceTransport,
}, },
); );
+15 -14
View File
@@ -21,15 +21,18 @@ import {
Separator, Separator,
} from "@vector-im/compound-web"; } from "@vector-im/compound-web";
import { Trans, useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { useObservableEagerState } from "observable-hooks";
import { import {
EARPIECE_CONFIG_ID, type AudioOutputDeviceLabel,
type DeviceLabel,
type SelectedDevice,
type MediaDevice, type MediaDevice,
} from "../livekit/MediaDevicesContext"; } from "../state/MediaDevices";
import styles from "./DeviceSelection.module.css"; import styles from "./DeviceSelection.module.css";
interface Props { interface Props {
device: MediaDevice; device: MediaDevice<DeviceLabel | AudioOutputDeviceLabel, SelectedDevice>;
title: string; title: string;
numberedLabel: (number: number) => string; numberedLabel: (number: number) => string;
} }
@@ -41,6 +44,8 @@ export const DeviceSelection: FC<Props> = ({
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
const groupId = useId(); const groupId = useId();
const available = useObservableEagerState(device.available$);
const selectedId = useObservableEagerState(device.selected$)?.id;
const onChange = useCallback( const onChange = useCallback(
(e: ChangeEvent<HTMLInputElement>) => { (e: ChangeEvent<HTMLInputElement>) => {
device.select(e.target.value); device.select(e.target.value);
@@ -49,7 +54,7 @@ export const DeviceSelection: FC<Props> = ({
); );
// There is no need to show the menu if there is no choice that can be made. // There is no need to show the menu if there is no choice that can be made.
if (device.available.size <= 1) return null; if (available.size <= 1) return null;
return ( return (
<div className={styles.selection}> <div className={styles.selection}>
@@ -64,7 +69,7 @@ export const DeviceSelection: FC<Props> = ({
</Heading> </Heading>
<Separator className={styles.separator} /> <Separator className={styles.separator} />
<div className={styles.options}> <div className={styles.options}>
{[...device.available].map(([id, label]) => { {[...available].map(([id, label]) => {
let labelText: ReactNode; let labelText: ReactNode;
switch (label.type) { switch (label.type) {
case "name": case "name":
@@ -89,16 +94,12 @@ export const DeviceSelection: FC<Props> = ({
</Trans> </Trans>
); );
break; break;
case "speaker":
labelText = t("settings.devices.loudspeaker");
break;
case "earpiece": case "earpiece":
labelText = t("settings.devices.earpiece"); labelText = t("settings.devices.handset");
break; break;
}
let isSelected = false;
if (device.useAsEarpiece) {
isSelected = id === EARPIECE_CONFIG_ID;
} else {
isSelected = id === device.selectedId;
} }
return ( return (
@@ -107,7 +108,7 @@ export const DeviceSelection: FC<Props> = ({
name={groupId} name={groupId}
control={ control={
<RadioControl <RadioControl
checked={isSelected} checked={id === selectedId}
onChange={onChange} onChange={onChange}
value={id} value={id}
/> />
+1 -1
View File
@@ -57,7 +57,7 @@ export const FeedbackSettingsTab: FC<Props> = ({ roomId }) => {
const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics(); const [optInAnalytics, setOptInAnalytics] = useOptInAnalytics();
const optInDescription = ( const optInDescription = (
<Text size="sm"> <Text size="sm" as="span">
<Trans i18nKey="settings.opt_in_description"> <Trans i18nKey="settings.opt_in_description">
<AnalyticsNotice /> <AnalyticsNotice />
<br /> <br />
+40 -14
View File
@@ -5,10 +5,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details. Please see LICENSE in the repository root for full details.
*/ */
import { type FC, type ReactNode, useState } from "react"; import { type FC, type ReactNode, useEffect, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { type MatrixClient } from "matrix-js-sdk"; import { type MatrixClient } from "matrix-js-sdk";
import { Root as Form, Separator } from "@vector-im/compound-web"; import { Button, Root as Form, Separator } from "@vector-im/compound-web";
import { type Room as LivekitRoom } from "livekit-client"; import { type Room as LivekitRoom } from "livekit-client";
import { Modal } from "../Modal"; import { Modal } from "../Modal";
@@ -16,10 +16,8 @@ import styles from "./SettingsModal.module.css";
import { type Tab, TabContainer } from "../tabs/Tabs"; import { type Tab, TabContainer } from "../tabs/Tabs";
import { ProfileSettingsTab } from "./ProfileSettingsTab"; import { ProfileSettingsTab } from "./ProfileSettingsTab";
import { FeedbackSettingsTab } from "./FeedbackSettingsTab"; import { FeedbackSettingsTab } from "./FeedbackSettingsTab";
import { import { iosDeviceMenu$ } from "../state/MediaDevices";
useMediaDevices, import { useMediaDevices } from "../MediaDevicesContext";
useMediaDeviceNames,
} from "../livekit/MediaDevicesContext";
import { widget } from "../widget"; import { widget } from "../widget";
import { import {
useSetting, useSetting,
@@ -34,6 +32,8 @@ import { useTrackProcessor } from "../livekit/TrackProcessorContext";
import { DeveloperSettingsTab } from "./DeveloperSettingsTab"; import { DeveloperSettingsTab } from "./DeveloperSettingsTab";
import { FieldRow, InputField } from "../input/Input"; import { FieldRow, InputField } from "../input/Input";
import { useSubmitRageshake } from "./submit-rageshake"; import { useSubmitRageshake } from "./submit-rageshake";
import { useUrlParams } from "../UrlParams";
import { useBehavior } from "../useBehavior";
type SettingsTab = type SettingsTab =
| "audio" | "audio"
@@ -95,26 +95,52 @@ export const SettingsModal: FC<Props> = ({
}; };
const devices = useMediaDevices(); const devices = useMediaDevices();
useMediaDeviceNames(devices, open); useEffect(() => {
if (open) devices.requestDeviceNames();
}, [open, devices]);
const [soundVolume, setSoundVolume] = useSetting(soundEffectVolumeSetting); const [soundVolume, setSoundVolume] = useSetting(soundEffectVolumeSetting);
const [soundVolumeRaw, setSoundVolumeRaw] = useState(soundVolume); const [soundVolumeRaw, setSoundVolumeRaw] = useState(soundVolume);
const [showDeveloperSettingsTab] = useSetting(developerMode); const [showDeveloperSettingsTab] = useSetting(developerMode);
const { available: isRageshakeAvailable } = useSubmitRageshake(); const { available: isRageshakeAvailable } = useSubmitRageshake();
// For controlled devices, we will not show the input section:
// Controlled media devices are used on mobile platforms, where input and output are grouped into
// a single device. These are called "headset" or "speaker" (or similar) but contain both input and output.
// On EC, we decided that it is less confusing for the user if they see those options in the output section
// rather than the input section.
const { controlledAudioDevices } = useUrlParams();
// If we are on iOS we will show a button to open the native audio device picker.
const iosDeviceMenu = useBehavior(iosDeviceMenu$);
const audioTab: Tab<SettingsTab> = { const audioTab: Tab<SettingsTab> = {
key: "audio", key: "audio",
name: t("common.audio"), name: t("common.audio"),
content: ( content: (
<> <>
<Form> <Form>
<DeviceSelection {!controlledAudioDevices && (
device={devices.audioInput} <DeviceSelection
title={t("settings.devices.microphone")} device={devices.audioInput}
numberedLabel={(n) => title={t("settings.devices.microphone")}
t("settings.devices.microphone_numbered", { n }) numberedLabel={(n) =>
} t("settings.devices.microphone_numbered", { n })
/> }
/>
)}
{iosDeviceMenu && controlledAudioDevices && (
<Button
onClick={(e): void => {
e.preventDefault();
window.controls.showNativeAudioDevicePicker?.();
// call deprecated method for backwards compatibility.
window.controls.showNativeOutputDevicePicker?.();
}}
>
{t("settings.devices.change_device_button")}
</Button>
)}
<DeviceSelection <DeviceSelection
device={devices.audioOutput} device={devices.audioOutput}
title={t("settings.devices.speaker")} title={t("settings.devices.speaker")}
+6 -5
View File
@@ -6,10 +6,11 @@ Please see LICENSE in the repository root for full details.
*/ */
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { BehaviorSubject, type Observable } from "rxjs"; import { BehaviorSubject } from "rxjs";
import { useObservableEagerState } from "observable-hooks";
import { PosthogAnalytics } from "../analytics/PosthogAnalytics"; import { PosthogAnalytics } from "../analytics/PosthogAnalytics";
import { type Behavior } from "../state/Behavior";
import { useBehavior } from "../useBehavior";
export class Setting<T> { export class Setting<T> {
public constructor( public constructor(
@@ -38,7 +39,7 @@ export class Setting<T> {
private readonly key: string; private readonly key: string;
private readonly _value$: BehaviorSubject<T>; private readonly _value$: BehaviorSubject<T>;
public readonly value$: Observable<T>; public readonly value$: Behavior<T>;
public readonly setValue = (value: T): void => { public readonly setValue = (value: T): void => {
this._value$.next(value); this._value$.next(value);
@@ -53,7 +54,7 @@ export class Setting<T> {
* React hook that returns a settings's current value and a setter. * React hook that returns a settings's current value and a setter.
*/ */
export function useSetting<T>(setting: Setting<T>): [T, (value: T) => void] { export function useSetting<T>(setting: Setting<T>): [T, (value: T) => void] {
return [useObservableEagerState(setting.value$), setting.setValue]; return [useBehavior(setting.value$), setting.setValue];
} }
// null = undecided // null = undecided
@@ -133,6 +134,6 @@ export const muteAllAudio = new Setting<boolean>("mute-all-audio", false);
export const alwaysShowSelf = new Setting<boolean>("always-show-self", true); export const alwaysShowSelf = new Setting<boolean>("always-show-self", true);
export const alwaysShowIphoneEarpiece = new Setting<boolean>( export const alwaysShowIphoneEarpiece = new Setting<boolean>(
"always-show-iphone-earpice", "always-show-iphone-earpiece",
false, false,
); );
+19
View File
@@ -0,0 +1,19 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { MediaDevices } from "./MediaDevices";
import { ViewModel } from "./ViewModel";
/**
* The top-level state holder for the application.
*/
export class AppViewModel extends ViewModel {
public readonly mediaDevices = new MediaDevices(this.scope);
// TODO: Move more application logic here. The CallViewModel, at the very
// least, ought to be accessible from this object.
}
+26
View File
@@ -0,0 +1,26 @@
/*
Copyright 2025 New Vector Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
*/
import { BehaviorSubject } from "rxjs";
/**
* A stateful, read-only reactive value. As an Observable, it is "hot" and
* always replays the current value upon subscription.
*
* A Behavior is to BehaviorSubject what Observable is to Subject; it does not
* provide a way to imperatively set new values. For more info on the
* distinction between Behaviors and Observables, see
* https://monoid.dk/post/behaviors-and-streams-why-both/.
*/
export type Behavior<T> = Omit<BehaviorSubject<T>, "next" | "observers">;
/**
* Creates a Behavior which never changes in value.
*/
export function constant<T>(value: T): Behavior<T> {
return new BehaviorSubject(value);
}

Some files were not shown because too many files have changed in this diff Show More