Compare commits

...

265 Commits

Author SHA1 Message Date
Robin
cc813fd3cb Merge pull request #2610 from robintown/update-js-sdk
Update matrix-js-sdk
2024-09-03 16:28:21 -04:00
Robin
4157ad071a Merge pull request #2608 from robintown/fix-rageshakes
Fix rageshakes
2024-09-03 16:23:30 -04:00
Robin
bc157c6dc4 Update matrix-js-sdk
There's no particular change that we need to pull in, but I like to keep my linked copy of matrix-js-sdk up to date—a TypeScript config change is required by recent versions, so I'd like to update this now.
2024-09-03 16:18:34 -04:00
Robin
57e1434fec Merge pull request #2609 from robintown/coverage-barrier
Make the test coverage target non-blocking
2024-09-03 16:14:00 -04:00
ElementRobot
bfbc5980b7 Merge pull request #2439 from element-hq/actions/localazy-download
Localazy Download
2024-09-03 15:10:42 -05:00
Robin
27394f9710 Make the test coverage target non-blocking
Sadly Codecov doesn't give us a way to relax the coverage requirements for changes that touch very few lines of code, which has been an invaluable feature of SonarCloud. I suggest we make the check non-blocking.
2024-09-03 16:07:43 -04:00
Robin
0d007f49ec Fix rageshakes
We were relying on deprecated APIs that are not supported when using Rust crypto. Since this entire file was copied and pasted from matrix-react-sdk originally, I just copied and pasted some of its more recent code in.
2024-09-03 16:00:17 -04:00
Robin
8e72ad597b Merge pull request #2473 from robintown/resize-observer
Remove ResizeObserver polyfill
2024-09-03 15:37:54 -04:00
Robin
c8a2ef6a1d Merge branch 'livekit' into resize-observer 2024-09-03 15:35:10 -04:00
renovate[bot]
c2cc0937c1 Update typescript-eslint monorepo to v8 (major) (#2523)
* Update typescript-eslint monorepo to v8

* es lint fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Timo <toger5@hotmail.de>
2024-09-03 17:14:27 +02:00
Robin
1784cb284c Merge pull request #2598 from robintown/test-media-vm
Test MediaViewModel
2024-09-03 10:40:02 -04:00
Robin
55038065c7 Remove a test debug log (#2597) 2024-09-03 11:04:59 +02:00
fkwp
49ebb1cf4c Merge pull request #2601 from element-hq/renovate/matrix-widget-api
Update dependency matrix-widget-api to v1.9.0
2024-09-03 09:08:03 +02:00
fkwp
b973e7446d Merge pull request #2606 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.5.1
2024-09-03 09:07:35 +02:00
renovate[bot]
5ebbb7b711 Update dependency livekit-client to v2.5.1 2024-09-02 20:29:29 +00:00
Timo
922fe5bafd Fix (registration flow): logout old before creating new client as required by initClient. (#2604) 2024-09-02 21:42:50 +02:00
fkwp
5f8081bebb Merge pull request #2602 from Johennes/johannes/qr
Display QR code when sharing invite link
2024-09-02 18:56:42 +02:00
Johannes Marbach
12237c469f Update src/QrCode.module.css
Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
2024-09-02 17:52:01 +02:00
renovate[bot]
7ee3fbd832 Update all non-major dependencies (#2600)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-09-02 17:48:56 +02:00
Timo
040288790c Fix (rust crypto): Adjust login procedures to account for rust crypto behaviour. (#2603)
* Fix for missing client store (caused by: #2587)

* Fix interactive login with authenticated guest user.
Fix clearing storage before logging in a new account.
2024-09-02 17:48:15 +02:00
Johannes Marbach
cba5eb5c07 Run prettier 2024-09-02 16:30:37 +02:00
Johannes Marbach
6ae0c0988d Add simplistic rendering test 2024-09-02 16:28:53 +02:00
Johannes Marbach
088d4d93a0 Re-add types package 2024-09-02 09:10:42 +02:00
fkwp
ead5f63a02 Merge pull request #2599 from element-hq/renovate/github-actions
Update actions/upload-artifact action to v4.4.0
2024-09-02 09:07:57 +02:00
Johannes Marbach
8655b41c05 Run prettier 2024-09-02 08:44:33 +02:00
Johannes Marbach
5b09a5ebd8 Merge branch 'livekit' into johannes/qr 2024-09-02 08:40:15 +02:00
Johannes Marbach
354382d498 Display QR code when sharing invite link
Fixes: #2495
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-09-02 08:25:10 +02:00
renovate[bot]
353987ca12 Update dependency matrix-widget-api to v1.9.0 2024-09-02 01:59:12 +00:00
renovate[bot]
fa6b8b3f0b Update actions/upload-artifact action to v4.4.0 2024-09-01 00:30:19 +00:00
Robin
9d5145a7a6 Test MediaViewModel
This was the result of me playing around with RxJS marble testing to understand how to get things done with its TestScheduler. I discovered that it lacks a clear way to fire arbitrary actions during the test, so I built a small helper function called schedule which does this for us.
2024-08-30 19:09:42 -04:00
Timo
3e57a7692c Add back keyboard toast tests (#2582)
* Fix global-jsdom initialization

* add back toast tests

* fix keyboard input events.

* add jsdom types
2024-08-30 15:40:09 +02:00
Robin
e9fc5dadd9 Merge pull request #2594 from robintown/upgrade-compound
Upgrade Compound Web
2024-08-30 09:38:17 -04:00
Andrew Ferrazzutti
86bacd2b47 Depend on a tagged js-sdk release (#2593)
which is possible since:
- matrix-org/matrix-js-sdk@ee94e9335
- element-hq/element-call@b79a405e
2024-08-30 09:37:15 -04:00
Robin
cb28fa715a Upgrade Compound Web 2024-08-30 09:35:34 -04:00
Timo
172af1dce3 Add missing productName string (#2596) 2024-08-30 15:29:14 +02:00
Timo
270540f125 Update README.md (#2589) 2024-08-30 15:07:15 +02:00
Andrew Ferrazzutti
0974488c4e Make one more js-sdk import consistent (#2595)
Update an import that was missed in b79a405e
2024-08-30 08:57:15 -04:00
Timo
a2dd538237 Fix for missing client store (caused by: #2587) (#2591) 2024-08-30 11:28:00 +02:00
Richard van der Hoff
b79a405ed6 Make js-sdk imports consistent (#2590)
We need to be consistent about whether we import matrix-js-sdk from `src` or
`lib`, otherwise we get two copies of matrix-js-sdk, and everything explodes.
2024-08-29 12:37:52 -04:00
Timo
159ae603aa Remove shadow for layout switcher. (#2588) 2024-08-29 17:59:28 +02:00
Timo
559fc4851c Fix rust crypto: dont use legacy crypto store anymore. (#2587)
The logic for the legacy store was intercepting with the rustCrypto that handles all the cases itself.
2024-08-29 16:59:47 +02:00
Robin
0db51d9dfd Replace remaining React ARIA components with Compound components (#2576)
* Fix issues detected by Knip

Including cleaning up some unused code and dependencies, using a React hook that we unintentionally stopped using, and also adding some previously undeclared dependencies.

* Replace remaining React ARIA components with Compound components

* fix button position

* disable scrollbars to resolve overlapping button

---------

Co-authored-by: Timo <toger5@hotmail.de>
2024-08-28 14:44:39 +02:00
Robin
7bca541cb6 Perform dead code analysis with Knip (#2575)
* Install Knip

* Clarify an import that was confusing Knip

* Fix issues detected by Knip

Including cleaning up some unused code and dependencies, using a React hook that we unintentionally stopped using, and also adding some previously undeclared dependencies.

* Run dead code analysis in lint script and CI

---------

Co-authored-by: Timo <toger5@hotmail.de>
2024-08-28 02:06:57 +02:00
fkwp
51ae4c0a88 Merge pull request #2585 from element-hq/fkwp/fix_codecov
set codecov token from secrets
2024-08-27 21:26:19 +02:00
fkwp
6521c8055c set codecov token from secrets 2024-08-27 21:22:16 +02:00
Johannes Marbach
7e3e17a3e8 Link "Create an account" button to registration page (#2583)
Fixes: #2328

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
2024-08-27 15:55:38 +02:00
Robin
5eaabcf74d Clean up our tests in preparation for the testing sprint (#2466)
* Fix coverage reporting

Codecov hasn't been working recently because Vitest doesn't report coverage by default.

* Suppress some noisy log lines

Closes https://github.com/element-hq/element-call/issues/686

* Store test files alongside source files

This way we benefit from not having to maintain the same directory structure twice, and our linters etc. will actually lint test files by default.

* Stop using Vitest globals

Vitest provides globals primarily to make the transition from Jest more smooth. But importing its functions explicitly is considered a better pattern, and we have so few tests right now that it's trivial to migrate them all.

* Remove Storybook directory

We no longer use Storybook.

* Configure Codecov

Add a coverage gate for all new changes and disable its comments.

* upgrade vitest

---------

Co-authored-by: Timo <toger5@hotmail.de>
2024-08-27 15:45:39 +02:00
Robin
3a754479dc Add simple global controls to put the call in picture-in-picture mode (#2573)
* Stop sharing state observables when the view model is destroyed

By default, observables running with shareReplay will continue running forever even if there are no subscribers. We need to stop them when the view model is destroyed to avoid memory leaks and other unintuitive behavior.

* Hydrate the call view model in a less hacky way

This ensures that only a single view model is created per call, unlike the previous solution which would create extra view models in strict mode which it was unable to dispose of. The other way was invalid because React gives us no way to reliably dispose of a resource created in the render phase. This is essentially a memory leak fix.

* Add simple global controls to put the call in picture-in-picture mode

Our web and mobile apps (will) all support putting calls into a picture-in-picture mode. However, it'd be nice to have a way of doing this that's more explicit than a breakpoint, because PiP views could in theory get fairly large. Specifically, on mobile, we want a way to do this that can tell you whether the call is ongoing, and that works even without the widget API (because we support SPA calls in the Element X apps…)

To this end, I've created a simple global "controls" API on the window. Right now it only has methods for controlling the picture-in-picture state, but in theory we can expand it to also control mute states, which is current possible via the widget API only.

* Fix footer appearing in large PiP views

* Add a method for whether you can enter picture-in-picture mode

* Have the controls emit booleans directly
2024-08-27 13:47:20 +02:00
renovate[bot]
0e3113edcd Update dependency jsdom to v25 (#2580)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-26 14:44:15 +02:00
renovate[bot]
6432dca518 Update all non-major dependencies (#2581)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-26 10:44:15 +02:00
Robin
b5f6343a5e Remove ResizeObserver polyfill
All major browsers support it out of the box, nowadays.
2024-08-23 15:07:40 -04:00
Robin
995b4c8847 Merge pull request #2577 from element-hq/renovate/compound
Update dependency @vector-im/compound-web to v6.1.0
2024-08-23 13:03:51 -04:00
Robin
b8774ad682 Merge pull request #2578 from robintown/spotlight-buttons
Fix spotlight tile regressions
2024-08-23 12:38:38 -04:00
Robin
30a54f3795 Fix spotlight tile regressions
The buttons were scrolling with the view instead of always being visible in a fixed location on the tile, and the indicators were not adopting the correct width.
2024-08-23 12:31:16 -04:00
Robin
66b79f57bb Merge pull request #2571 from element-hq/hughns/rust-crypto
Use Rust crypto implementation
2024-08-23 11:18:43 -04:00
renovate[bot]
a6f6db9226 Update dependency @vector-im/compound-web to v6.1.0 2024-08-23 01:00:13 +00:00
Robin
61a24262de Merge pull request #2570 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2024-08-20 13:41:49 -04:00
renovate[bot]
0955d7bcc3 Update all non-major dependencies 2024-08-20 17:40:09 +00:00
Hugh Nimmo-Smith
36ce21d7ac Show crypto version in developer settings 2024-08-19 10:40:09 +01:00
Hugh Nimmo-Smith
eddc590235 Use rust crypto
Taken from d25cf28d00
2024-08-19 10:27:46 +01:00
Robin
61bc4dcc14 Merge pull request #2569 from robintown/horizontal-overflow
Fix long call names overflowing the interface
2024-08-16 16:41:15 -04:00
Robin
e2c4eae67b Make sure that the call interface can't scroll horizontally 2024-08-16 15:16:33 -04:00
Robin
1da3fe0731 Fix long call names overflowing the interface
They are now properly truncated with an ellipsis.
2024-08-16 15:15:51 -04:00
Hugh Nimmo-Smith
f562cc1e7f Show user's Matrix ID and device ID in developer settings tab (#2559) 2024-08-16 15:37:57 +01:00
Hugh Nimmo-Smith
69b762b9ed Bump js-sdk for sender key reliability improvements (#2567)
Diff from current version: 9176d3a671...467908703b
2024-08-15 11:49:19 +02:00
fkwp
ff55b1d189 Merge pull request #2564 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.5.0
2024-08-14 17:08:56 +02:00
fkwp
d796ebe3fa Merge pull request #2565 from element-hq/renovate/github-actions
Update docker/build-push-action action to v6.7.0
2024-08-14 17:08:16 +02:00
renovate[bot]
b4bc41ba02 Update docker/build-push-action action to v6.7.0 2024-08-14 15:07:05 +00:00
renovate[bot]
a072dfae9c Update dependency livekit-client to v2.5.0 2024-08-14 15:07:00 +00:00
fkwp
0eba3ef75f Merge pull request #2557 from element-hq/renovate/github-actions
Update GitHub Actions
2024-08-12 15:22:05 +02:00
renovate[bot]
2b9bf1fbe6 Update GitHub Actions 2024-08-12 13:18:51 +00:00
Doug
8769f8966d Clarify web server compatibility (#2555) 2024-08-12 08:06:05 -04:00
Robin
4e7b29e142 Merge pull request #2554 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2024-08-11 22:23:17 -04:00
renovate[bot]
977ba92dba Update all non-major dependencies 2024-08-12 02:12:14 +00:00
Robin
64e7047b12 Merge pull request #2552 from robintown/spotlight-left
Don't keep someone in the spotlight if they've left the call
2024-08-09 13:40:13 -04:00
Robin
ed99af0be6 Improve readability 2024-08-09 13:38:59 -04:00
Robin
52058716f6 Don't keep someone in the spotlight if they've left the call 2024-08-09 13:08:37 -04:00
Robin
29df87d22c Merge pull request #2548 from robintown/hide-controls
Show controls on tap/hover on small screens
2024-08-09 11:52:01 -04:00
Robin
6443e911dc Make the breakpoint a bit smaller 2024-08-09 11:09:45 -04:00
Robin
aa6b7056ae Show controls on tap/hover on small screens
This changes the mobile landscape view to automatically hide the controls, giving more visibility to the video underneath, and show them on tap/hover.
2024-08-09 11:09:45 -04:00
Robin
c20737ba4c Merge pull request #2546 from robintown/spotlight-duplication
Avoid duplicating the video of someone in the spotlight
2024-08-09 09:11:13 -04:00
Robin
6f03653532 Merge pull request #2545 from robintown/breakpoint
Consider any sufficiently short window 'flat'
2024-08-08 13:22:41 -04:00
Robin
2ec0aaa0de Merge pull request #2547 from robintown/t-grid
Avoid T-shaped layouts in 4 person calls
2024-08-08 13:22:20 -04:00
Robin
9b4ad24f10 Avoid T-shaped layouts in 4 person calls
The code path for when all tiles can fit on screen was failing to realize that it could sometimes get by with fewer columns. This resulted in wasted space for 4 person calls at some window sizes.
2024-08-08 12:46:38 -04:00
Robin
5069b008e2 Avoid duplicating the video of someone in the spotlight
We've gotten feedback that it's distracting whenever the same video is shown in two places on screen. This fixes the spotlight case by showing only the avatar of anyone who is already visible in the spotlight. It also makes sense to hide the speaking indicators in spotlight layouts, I think, because this information is redundant to the spotlight tile.
2024-08-08 12:16:32 -04:00
Robin
6d8e45aea8 Consider any sufficiently short window 'flat'
This is because our layouts for flat windows are good at adapting to both small width and small height, while our layouts for narrow windows aren't so good at adapting to a small height.
2024-08-08 11:30:57 -04:00
Andrew Ferrazzutti
f0f9b929a1 Update js-sdk to use non-legacy calls if found (#2540) 2024-08-07 13:00:19 -04:00
Robin
9b5072cc57 Merge pull request #2541 from robintown/local-on-local
Don't show local media on top of itself
2024-08-07 09:18:29 -04:00
Hugh Nimmo-Smith
b13fa85465 Add note on how to add a new translation key (#2536)
* Add note on how to add a new translation key

* Lint

* Nit
2024-08-07 10:40:44 +01:00
Robin
bf5128cfee Don't show local media on top of itself
If you were the only one in the call, you could get a broken-looking view in which the local tile is shown in the spotlight, and it's also shown in the PiP. This is redundant.
2024-08-06 17:12:13 -04:00
Robin
f928e63c7b Merge pull request #2539 from robintown/duplicate-tiles-crash
Fix a crash when the duplicate tiles option is empty
2024-08-06 16:24:58 -04:00
Robin
eef92249f7 Fix a crash when the duplicate tiles option is empty
We need to handle the case where the value is NaN because the field is empty.
2024-08-06 10:56:15 -04:00
Robin
04ad44f900 Merge pull request #2534 from element-hq/renovate/postcss-preset-env-10.x
Update dependency postcss-preset-env to v10
2024-08-06 10:11:20 -04:00
Robin
90072aa2bb Merge pull request #2538 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v1.8.0
2024-08-06 10:10:35 -04:00
Robin
ab42fe97cb Merge pull request #2514 from robintown/mobile-layouts
Improve the layouts on small mobile calls
2024-08-06 10:10:29 -04:00
Robin
f4cf3d8c62 Adjust the breakpoint 2024-08-06 10:08:56 -04:00
renovate[bot]
1782a0eaf3 Update dependency @vector-im/compound-design-tokens to v1.8.0 2024-08-06 01:14:19 +00:00
renovate[bot]
5bf46eb8f8 Update all non-major dependencies (#2535)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-05 12:30:45 +02:00
renovate[bot]
b4973bbc6b Update dependency postcss-preset-env to v10 2024-08-04 00:40:54 +00:00
Robin
eaf3fb13c1 Merge pull request #2448 from element-hq/renovate/major-compound
Update dependency @vector-im/compound-web to v6
2024-08-02 15:38:17 -04:00
Robin
b503056673 Adapt to breaking changes in Compound 2024-08-02 15:27:49 -04:00
renovate[bot]
86e3c346a4 Update dependency @vector-im/compound-web to v6 2024-08-02 19:23:22 +00:00
Andrew Ferrazzutti
7449e1f6e4 Don't refer to MSC3779 explicitly in comment (#2533)
because other MSCs (like 3757) may allow @-prefixed state keys
2024-08-02 15:15:54 +00:00
Robin
aadf6c05ac Merge pull request #2530 from robintown/no-you
Show your own name on your tile
2024-08-02 10:45:32 -04:00
Robin
39ee8d838e Merge pull request #2531 from robintown/iterate-margins
Add back some margins to the interface
2024-08-02 08:42:03 -04:00
Andrew Ferrazzutti
1f10245adc Bump matrix-widget-api (#2529) 2024-08-02 08:37:55 -04:00
Robin
c1de41106f Merge pull request #2532 from robintown/renovate-warning
Fix Renovate warning
2024-08-01 17:19:37 -04:00
Robin
e12bad952a Fix Renovate warning
Apparently Renovate doesn't really like it when you use a group: preset inside packageRules, instead of at the top level of the config. We do want to apply schedule:weekly only to the "all non-major dependencies" group though, so we need to write the group definition out by hand.
2024-08-01 16:41:19 -04:00
Robin
7abb56e406 Add back some margins to the interface
There were a couple of cases where the lack of margins after the new layout changes just looked odd. Specifically, when the header is hidden (as in embedded mode), there would be no margin at the top of the window. Also the floating tile would run directly up against the sides of the window.
2024-08-01 16:33:10 -04:00
Robin
00d8100dfe Show your own name on your tile
Instead of the word "You".
2024-08-01 15:48:22 -04:00
Robin
eb051ab318 Replace the mobile one-on-one layout with an edge-to-edge spotlight 2024-08-01 13:49:49 -04:00
Robin
942e28f3c2 Improve the layouts on small mobile calls
Due to an oversight of mine, 2440037639 actually removed the ability to see the one-on-one layout on mobile. This restores mobile one-on-one calls to working order and also avoids showing the spotlight tile unless there are more than a few participants.
2024-08-01 13:49:49 -04:00
Robin
0bfec65405 Refactor layout selection into smaller chunks 2024-08-01 13:49:49 -04:00
Robin
f89342713a Merge pull request #2528 from robintown/remote-spotlight
More strongly prefer putting a remote speaker in the spotlight
2024-08-01 13:24:57 -04:00
Robin
5a0b81b57f More strongly prefer putting a remote speaker in the spotlight
If no one had spoken yet, we were still showing the local user in the spotlight. We should instead eagerly switch to showing an arbitrary remote participant in this case.
2024-08-01 12:48:47 -04:00
Timo
f9323d8b2c Add future related widget capabilities (#2505)
* add future related widget capabilities

* Update js sdk
2024-08-01 11:41:47 -04:00
renovate[bot]
c68d536d80 Update LiveKit components (#2525)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-01 16:30:24 +02:00
renovate[bot]
fde7dbedaa Update dependency matrix-widget-api to v1.8.1 (#2527)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-01 16:29:50 +02:00
fkwp
7e240e96b7 Merge pull request #2526 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.4.2
2024-08-01 16:04:53 +02:00
renovate[bot]
f84800363f Update dependency livekit-client to v2.4.2 2024-08-01 13:26:05 +00:00
fkwp
f9e12c8ff3 Merge pull request #2524 from element-hq/renovate/github-actions
Update GitHub Actions
2024-08-01 09:28:05 +02:00
renovate[bot]
6abd1fbca1 Update GitHub Actions 2024-08-01 01:04:00 +00:00
Timo
599a4708cb Backport deviceSetup await (#2522) 2024-07-31 13:21:37 +02:00
Timo
f53ea75c94 Add DeviceMute widget action io.element.device_mute. (#2482)
* Add DeviceMute widget action `io.element.device_mute`.
This allows to send mute requests ("toWidget") and get the current mute state as a response.
And it will update the client about each change of mute states.

* review + better explanation

* review

* add comments

* use `useCallback`
2024-07-30 13:30:33 +02:00
Robin
2b67a9cfbe Merge pull request #2486 from robintown/delete-fullscreen
Delete the unused full screen code
2024-07-29 09:28:07 -04:00
fkwp
d582a7cc29 Merge pull request #2519 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.4.1
2024-07-29 11:35:26 +02:00
renovate[bot]
8757f07982 Update dependency livekit-client to v2.4.1 2024-07-29 09:32:35 +00:00
fkwp
5b8910d265 Merge pull request #2518 from element-hq/renovate/livekit-components
Update LiveKit components
2024-07-29 11:31:06 +02:00
renovate[bot]
a03ab6c9fa Update LiveKit components 2024-07-29 01:38:23 +00:00
Robin
a3ce333352 Only show the expand button in spotlight layout (#2510)
It has no effect in any layout other than spotlight, and we've decided to hide it rather than spending effort to make it do something.
2024-07-26 12:57:49 +02:00
Robin
d5faa5ea90 Don't show the speaker in the spotlight in large grids (#2511)
We've concluded that this behavior is actually more distracting than it is helpful, and we want to try out what it's like to just have the importance ordering and visual cues help you find who's speaking.
2024-07-26 12:51:34 +02:00
Robin
5becd2e175 Fix a crash when using the duplicate tiles option (#2512) 2024-07-26 12:51:09 +02:00
Robin
3b38a5322c Give tiles a minimum area rather than a minimum width and height (#2513)
This seems to result in more sensible cropping and allocation of space across the board, in my testing.
2024-07-26 12:50:44 +02:00
Robin
d062871f41 Don't consider microphone mute state in importance ordering (#2515)
We're finding that if we reorder participants based on whether their mic is muted, this just creates a lot of distracting layout shifts. People who speak are automatically promoted into the speaker category, so there's little value in additionally caring about mute state.
2024-07-26 11:27:22 +02:00
renovate[bot]
6b64bdfdb5 Update dependency @vector-im/compound-design-tokens to v1.7.0 (#2516)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-26 06:37:46 +02:00
Robin
2de4705fa7 Merge pull request #2509 from robintown/icon-imports
Import Compound icons in the new recommended way
2024-07-25 14:26:41 -04:00
Robin
12e233970c Import Compound icons in the new recommended way
The Compound design tokens package is now set up to generate React components for every icon, so we no longer need to use our more error-prone method of importing the SVGs.
2024-07-25 13:15:45 -04:00
Robin
10b915c707 Merge pull request #2501 from robintown/layout-reactivity
Make layout reactivity less brittle
2024-07-25 12:51:39 -04:00
Robin
5544695f21 Use clearer names 2024-07-25 12:50:28 -04:00
Timo
72de8e066c fix grammar (#2506) 2024-07-25 14:33:37 +02:00
Robin
63afda05bc Merge pull request #2502 from robintown/shortcut-a11y
Improve accessibility of keyboard shortcuts
2024-07-25 08:24:13 -04:00
Timo
b05c4234b7 Remove hide header condition (#2493) 2024-07-25 11:32:05 +02:00
renovate[bot]
80ddb7495d Update dependency eslint-plugin-unicorn to v55 (#2503)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-25 10:35:26 +02:00
Robin
380f49fccc Improve accessibility of keyboard shortcuts
Ensure that they don't interfere with say, using spacebar to press a button, and also ensure that they won't do surprising things like scroll the page at the same time.
2024-07-24 18:42:21 -04:00
Robin
447bac3280 Make layout reactivity less brittle
Follow-up to ea2d98179c

This took a couple of iterations to find something that works without creating update loops, but I think that by automatically informing Grid whenever a layout component is re-rendered, we'll have a much easier time ensuring that our layouts are fully reactive.
2024-07-24 17:03:27 -04:00
Robin
c74cebcc4b Merge pull request #2492 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2024-07-24 14:17:48 -04:00
renovate[bot]
cd0aa0ced6 Update all non-major dependencies 2024-07-24 18:13:38 +00:00
Robin
9cbd146e24 Merge pull request #2491 from element-hq/renovate/matrix-widget-api
Update dependency matrix-widget-api to v1.7.0
2024-07-24 11:14:46 -04:00
Robin
509bb4f1b0 Use LTS Node in CI 2024-07-24 11:12:36 -04:00
Robin
3be3a32f3d Update TypeScript target to match matrix-js-sdk
And work around https://github.com/microsoft/TypeScript/issues/55132
2024-07-24 11:07:46 -04:00
Robin
17adfc5777 Upgrade matrix-js-sdk 2024-07-24 10:17:47 -04:00
fkwp
4eb1be678d Merge pull request #2499 from element-hq/renovate/livekit-components
Update LiveKit components
2024-07-24 15:27:53 +02:00
renovate[bot]
b34e7d00e9 Update LiveKit components 2024-07-24 12:57:28 +00:00
fkwp
78f4c2a650 Merge pull request #2498 from element-hq/fkwp/cleanup_config
Fkwp/cleanup config
2024-07-24 13:04:11 +02:00
Timo
a3773c0a9a prettier 2024-07-24 13:00:13 +02:00
fkwp
2b92ce8af2 enable new m.call.member format 2024-07-24 12:19:36 +02:00
fkwp
5564e2fde6 cleanup config files 2024-07-24 10:18:16 +02:00
Robin
35e2d2c432 Merge pull request #2494 from robintown/spotlight-fix
Quick and dirty fix to spotlight reactivity
2024-07-22 10:55:20 -04:00
Robin
ea2d98179c Quick and dirty fix to spotlight reactivity 2024-07-22 10:52:20 -04:00
renovate[bot]
d83a104dda Update dependency matrix-widget-api to v1.7.0 2024-07-19 14:32:06 +00:00
fkwp
58f274eabf Merge pull request #2490 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.4.0
2024-07-19 16:30:31 +02:00
renovate[bot]
632ad07304 Update dependency livekit-client to v2.4.0 2024-07-19 14:28:43 +00:00
Robin
4173fd113b Merge pull request #2485 from element-hq/new-call-layouts
New call layouts
2024-07-19 09:08:51 -04:00
renovate[bot]
56b5f2845d Update dependency @vector-im/compound-design-tokens to v1.6.1 (#2487)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-19 13:33:24 +02:00
Timo
afee9eaa26 Don't update mute when reaching the user count threshold. (#2474)
* Dont update mute during call.
2024-07-18 18:14:29 +02:00
Robin
364b78abda Delete the unused full screen code
We no longer allow individual tiles to be put in full screen, because we're seeing what it's like to just stretch the spotlight tile edge-to-edge and keep the margins minimal.
2024-07-18 11:48:06 -04:00
Robin
507b1fc52d Merge branch 'livekit' into new-call-layouts 2024-07-18 11:38:35 -04:00
Robin
6812c35a40 Merge pull request #2463 from robintown/rest-of-the-layouts
Implement most of the remaining layout changes
2024-07-18 11:34:47 -04:00
Robin
377b7ff5de Explain each layout 2024-07-18 11:33:20 -04:00
Robin
4955535374 Use more consistent names for layout types 2024-07-18 11:24:18 -04:00
Robin
0664f978e3 Merge branch 'new-call-layouts' into rest-of-the-layouts 2024-07-18 11:21:56 -04:00
Robin
bcc06d86ff Merge pull request #2417 from robintown/one-on-one-layout
New one-on-one layout
2024-07-18 11:09:11 -04:00
Robin
7526826b0c Improve aspect ratios on mobile 2024-07-18 11:01:21 -04:00
Robin
b4e0df75c0 Merge branch 'new-call-layouts' into one-on-one-layout 2024-07-18 10:28:17 -04:00
Robin
d561a41666 Merge pull request #2416 from robintown/grid-spotlight-speaker
Show speaker in the spotlight in large grids
2024-07-18 10:17:31 -04:00
Timo
d53ad9a8f3 Update sample config with livekit (rebase on livekit) (#2483)
* Update sample cfg with livekit config

* matching ports in readme and example

---------

Co-authored-by: xmj <xmj@chaot.net>
2024-07-18 16:01:10 +02:00
Robin
e04affe93e Justify the use of a participant count threshold 2024-07-18 10:00:26 -04:00
Robin
24870deead Merge pull request #2382 from robintown/spotlight-layout
New spotlight layout
2024-07-18 08:50:31 -04:00
Robin
7fcd7125c1 Merge branch 'new-call-layouts' into spotlight-layout 2024-07-18 08:48:50 -04:00
Robin
1efa594430 Use Array.some where it's appropriate 2024-07-17 16:06:48 -04:00
Robin
caea4b250e Merge pull request #2381 from robintown/observable-hooks
Replace react-rxjs with observable-hooks
2024-07-17 15:56:31 -04:00
Robin
0a8c6c1454 Merge branch 'new-call-layouts' into observable-hooks 2024-07-17 15:55:50 -04:00
Robin
d4a2617f7b Merge pull request #2380 from robintown/pin-always-show
Add toggle to always show yourself
2024-07-17 15:45:29 -04:00
Robin
e05c6f1bdf Merge pull request #2369 from robintown/duplicate-tiles
Add a developer option to duplicate tiles
2024-07-17 15:41:53 -04:00
Robin
2bc56dbff2 Use fewer ML-style variable names 2024-07-17 15:40:02 -04:00
Robin
a59875dab5 Explain what each sorting bin means 2024-07-17 15:37:41 -04:00
Robin
8c21e8f277 Use a more descriptive string 2024-07-17 14:55:45 -04:00
Robin
d8634eed3d Merge pull request #2484 from element-hq/renovate/react-i18next-15.x
Update dependency react-i18next to v15
2024-07-17 13:14:11 -04:00
renovate[bot]
be4b70c1e1 Update dependency react-i18next to v15 2024-07-17 16:51:55 +00:00
renovate[bot]
e79cded57f Update all non-major dependencies (#2479)
* Update all non-major dependencies

* prettier fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Timo <toger5@hotmail.de>
2024-07-17 10:07:26 +02:00
Robin
2440037639 Implement most of the remaining layout changes
Includes the mobile UX optimizations and the tweaks we've made to cut down on wasted space, but does not yet include the change to embed the spotlight tile within the grid.
2024-07-12 15:50:17 -04:00
Robin
a16f235277 Fix crash in spotlight mode while connecting
Because we were hiding even the local participant during initial connection, there would be no participants, and therefore nothing to put in the spotlight. The designs don't really tell us what the connecting state should look like, so I've taken the liberty of restoring it to its former glory of showing the local participant immediately.
2024-07-12 15:49:45 -04:00
Robin
45c89a2298 Delete the legacy grid system 2024-07-12 15:49:43 -04:00
Robin
7979493371 Implement the new one-on-one layout 2024-07-12 15:47:56 -04:00
Robin
e0b10d89b5 Add model for one-on-one layout 2024-07-12 15:47:56 -04:00
Robin
183d2d9050 Show speaker in the spotlight in large grids 2024-07-12 15:47:35 -04:00
Robin
12b719da95 Make layout reactivity a little more fine-grained 2024-07-12 15:47:00 -04:00
Robin
dfda7539d6 Only switch to spotlight for remote screen shares 2024-07-12 15:47:00 -04:00
Robin
7f40ce8dde Fix advance buttons showing up for the spotlight speaker 2024-07-12 15:47:00 -04:00
Robin
ec1b020d4e Add indicators to spotlight tile and make spotlight layout responsive 2024-07-12 15:47:00 -04:00
Robin
54c22f4ab2 Clean up spotlight tile code 2024-07-12 15:47:00 -04:00
Robin
ffbbc74a96 Implement the new spotlight layout 2024-07-12 15:47:00 -04:00
Robin
34c45cb5e2 Get the right grid offset even when offsetParent is a layout element 2024-07-12 15:47:00 -04:00
Robin
af0bd795b5 Replace react-rxjs with observable-hooks
react-rxjs is the library we've been using to connect our React components to view models and consume observables. However, after spending some time with react-rxjs, I feel that it's a very heavy-handed solution. It requires us to sprinkle <Subscribe /> and <RemoveSubscribe /> components all throughout the code, and makes React go through an extra render cycle whenever we mount a component that binds to a view model. What I really want is a lightweight React hook that just gets the current value out of a plain observable, without any extra setup. Luckily the observable-hooks library with its useObservableEagerState hook seems to do just that—and it's more actively maintained, too!
2024-07-12 15:46:33 -04:00
Robin
0d485ef97f Use always show flag in importance ordering 2024-07-12 15:43:24 -04:00
Robin
5647619b36 Add always show toggle to the UI 2024-07-12 15:43:24 -04:00
Robin
8a414012a0 Add always show flag to view model 2024-07-12 15:43:24 -04:00
Robin
e33fbd77d1 Split local and remote user media into different classes 2024-07-12 15:43:24 -04:00
Robin
fdc6d4a1b6 Add a developer option to duplicate tiles
This is useful for testing how the UI behaves with different numbers of participants.
2024-07-12 14:55:29 -04:00
Robin
a534356dd9 Merge pull request #2368 from robintown/settings-refactor
Refactor settings to use observables
2024-07-12 14:50:46 -04:00
Robin
f847692953 Merge pull request #2325 from robintown/unified-grid
Unified grid layout
2024-07-12 14:50:35 -04:00
Robin
486430d1f0 Merge pull request #2478 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v1.6.0
2024-07-12 14:19:29 -04:00
Robin
599d6fd007 Address review feedback 2024-07-12 14:15:27 -04:00
Robin
14fc1481f3 Address some review feedback 2024-07-12 14:01:32 -04:00
renovate[bot]
e6ddf40b1b Update dependency @vector-im/compound-design-tokens to v1.6.0 2024-07-12 16:55:33 +00:00
fkwp
9f521a79f7 Merge pull request #2477 from element-hq/renovate/livekit-client
Update dependency livekit-client to v2.3.2
2024-07-11 10:22:54 +02:00
fkwp
83784a717a Merge pull request #2476 from element-hq/renovate/livekit-components
Update dependency @livekit/components-react to v2.3.6
2024-07-11 10:22:18 +02:00
renovate[bot]
0729deee79 Update dependency livekit-client to v2.3.2 2024-07-11 08:18:46 +00:00
renovate[bot]
77c3114cf8 Update dependency @livekit/components-react to v2.3.6 2024-07-11 08:18:27 +00:00
Robin
82a56c8204 Merge pull request #2471 from element-hq/renovate/major-vitest-monorepo
Update dependency vitest to v2
2024-07-09 10:42:23 -04:00
renovate[bot]
b39896d8c6 Update dependency @vector-im/compound-design-tokens to v1.4.0 (#2472)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-09 11:34:44 +02:00
renovate[bot]
79b3fdb645 Update dependency vitest to v2 2024-07-08 13:01:11 +00:00
renovate[bot]
0f877cd021 Update dependency tinyqueue to v3 (#2468)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-08 09:12:26 +02:00
renovate[bot]
db2acc75b2 Update LiveKit components (#2469)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-08 09:11:56 +02:00
renovate[bot]
a5dbfbf2c1 Update all non-major dependencies (#2470)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-08 09:11:25 +02:00
Andrew Ferrazzutti
34c7d02de2 Add config to send session membership state events (#2460)
If not set, legacy call membership state events are sent instead.
Even if set, legacy events are sent in rooms with active legacy calls.

---------

Co-authored-by: Timo <16718859+toger5@users.noreply.github.com>
2024-07-05 21:10:16 +09:00
Andrew Ferrazzutti
ca45067158 Let Element Call widget set session memberships (#2459)
Make Element Call widgets request permission to set device-specific
session membership state events.
2024-07-05 04:59:48 +09:00
Andrew Ferrazzutti
5a6eb7c573 Make widgets request the room creation event (#2457)
This allows the widget to check the room version, so it can know about
version-specific auth rules (namely MSC3779).
2024-07-05 04:57:45 +09:00
Robin
41083c0f9e Refactor settings to use observables
Also removing some unused settings along the way.
2024-07-03 15:29:32 -04:00
Robin
20602c122b Implement the new unified grid layout
Here I've implemented an MVP for the new unified grid layout, which scales smoothly up to arbitrarily many participants. It doesn't yet have a special 1:1 layout, so in spotlight mode and 1:1s, we will still fall back to the legacy grid systems.

Things that happened along the way:
- The part of VideoTile that is common to both spotlight and grid tiles, I refactored into MediaView
- VideoTile renamed to GridTile
- Added SpotlightTile for the new, glassy spotlight designs
- NewVideoGrid renamed to Grid, and refactored to be even more generic
- I extracted the media name logic into a custom React hook
- Deleted the BigGrid experiment
2024-07-03 15:29:08 -04:00
Robin
5ad2a27a92 Merge pull request #2462 from element-hq/renovate/github-actions
Update docker/build-push-action action to v6.3.0
2024-07-03 15:25:13 -04:00
renovate[bot]
68daaa45f9 Update docker/build-push-action action to v6.3.0 2024-07-03 11:29:17 +00:00
renovate[bot]
c40ea35937 Update all non-major dependencies (#2461)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-02 10:41:19 +02:00
Timo
d27f433175 Skip error screen for the issue, that the homeserver does not support the room summary endpoint. (#2453)
* Add try inner try block to the room summary fetching and only throw after fetching and a "blind join" fails.
(blind join: call room.join without knowing if the room is public)

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

---------

Co-authored-by: Robin <robin@robin.town>
2024-06-25 08:44:02 +00:00
Robin
8a6101cd14 Merge pull request #2456 from element-hq/renovate/all-minor-patch
Update all non-major dependencies
2024-06-24 10:37:18 -04:00
Robin
4db7c2bc68 Fix type errors 2024-06-24 10:31:50 -04:00
renovate[bot]
18740fc686 Update all non-major dependencies 2024-06-24 13:04:28 +00:00
Robin
0c39398493 Merge pull request #2447 from element-hq/renovate/compound
Update dependency @vector-im/compound-design-tokens to v1.3.0
2024-06-21 10:39:03 -04:00
Robin
949145f04b Merge pull request #2446 from element-hq/renovate/major-testing-library-monorepo
Update dependency @testing-library/react to v16
2024-06-21 10:32:30 -04:00
Robin
8578dcadf2 Add missing peer dependencies 2024-06-21 10:30:39 -04:00
renovate[bot]
959db44eca Update dependency @testing-library/react to v16 2024-06-21 10:30:28 -04:00
Robin
a031c0e128 Merge pull request #2445 from element-hq/renovate/major-sentry-javascript-monorepo
Update dependency @sentry/react to v8
2024-06-21 10:25:04 -04:00
Robin
591833505f Adapt to breaking changes 2024-06-21 10:23:30 -04:00
Robin
f7ad5074d8 Merge pull request #2452 from element-hq/renovate/i18next-parser-9.x
Update dependency i18next-parser to v9
2024-06-21 10:14:39 -04:00
Robin
e0aef74bf5 Merge pull request #2454 from element-hq/renovate/uuid-10.x
Update dependency uuid to v10
2024-06-21 10:13:01 -04:00
renovate[bot]
b2378bf899 Update dependency i18next-parser to v9 2024-06-21 14:12:34 +00:00
Robin
255f6b1814 Merge pull request #2451 from element-hq/renovate/i18next-browser-languagedetector-8.x
Update dependency i18next-browser-languagedetector to v8
2024-06-21 10:11:59 -04:00
Robin
4c491b5363 Merge pull request #2450 from element-hq/renovate/eslint-plugin-unicorn-54.x
Update dependency eslint-plugin-unicorn to v54
2024-06-21 10:11:23 -04:00
Robin
61c808d4cf Merge pull request #2455 from element-hq/renovate/github-actions
Pin dependencies
2024-06-21 10:00:40 -04:00
Robin
13ef3183e2 Tell Renovate that we're trying to pin actions to specific tags
It thought that we were just trying to follow the latest commit on these actions, when in reality we want to follow the latest tag and pin its commit hash.
2024-06-21 09:57:48 -04:00
renovate[bot]
afd4fdcea2 Pin dependencies 2024-06-21 13:21:08 +00:00
Robin
982181ccd4 Merge pull request #2444 from robintown/more-renovate
Refine Renovate config further
2024-06-21 09:10:16 -04:00
renovate[bot]
30629ebba2 Update dependency uuid to v10 2024-06-21 10:07:33 +00:00
renovate[bot]
7f6a32d21a Update dependency i18next-browser-languagedetector to v8 2024-06-21 08:46:24 +00:00
renovate[bot]
320ade0a50 Update dependency eslint-plugin-unicorn to v54 2024-06-21 04:03:53 +00:00
renovate[bot]
8c6fee3150 Update dependency @vector-im/compound-design-tokens to v1.3.0 2024-06-21 00:35:09 +00:00
renovate[bot]
5c6acaf915 Update dependency @sentry/react to v8 2024-06-20 21:46:07 +00:00
Robin
c46549b2b6 Refine Renovate config further
By getting it to pin GitHub Actions to specific commits, which hardens our workflows, and fixing a warning about matchPackageNames
2024-06-20 16:00:52 -04:00
fkwp
97a58f6db7 Merge pull request #2442 from element-hq/renovate/docker-build-push-action-digest
Update docker/build-push-action digest to 31159d4
2024-06-20 21:48:42 +02:00
fkwp
b6288579c9 Merge pull request #2443 from element-hq/renovate/docker-setup-buildx-action-digest
Update docker/setup-buildx-action digest to abe89fb
2024-06-20 21:48:25 +02:00
renovate[bot]
44bf987cdc Update docker/setup-buildx-action digest to abe89fb 2024-06-20 19:45:16 +00:00
renovate[bot]
a7d55824bb Update docker/build-push-action digest to 31159d4 2024-06-20 19:45:13 +00:00
Robin
8fa038c61f Merge pull request #2441 from robintown/renovate-noise
Reduce noise coming from Renovate updates
2024-06-20 15:44:38 -04:00
Robin
869d9b43cb Reduce noise coming from Renovate updates
What I've tried to do here is to group most dependency updates together and put them on a weekly schedule. Some of our more sensitive dependencies such as LiveKit and Compound have been put into separate groups, so we still receive frequent updates for them.
2024-06-20 15:43:21 -04:00
robintown
c3379f2d0f Translations updates 2024-06-20 18:32:56 +00:00
204 changed files with 9308 additions and 12088 deletions

View File

@@ -38,15 +38,6 @@ module.exports = {
"jsx-a11y/media-has-caption": "off",
// We should use the js-sdk logger, never console directly.
"no-console": ["error"],
"no-restricted-imports": [
"error",
{
name: "@react-rxjs/core",
importNames: ["Subscribe", "RemoveSubscribe"],
message:
"These components are easy to misuse, please use the 'subscribe' component wrapper instead",
},
],
"react/display-name": "error",
},
settings: {

View File

@@ -23,10 +23,10 @@ jobs:
packages: write
steps:
- name: Check it out
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: 📥 Download artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ inputs.artifact_run_id }}
@@ -34,7 +34,7 @@ jobs:
path: dist
- name: Log in to container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
@@ -42,16 +42,16 @@ jobs:
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@f7b4ed12385588c3f9bc252f0a2b520d83b52d48
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ inputs.docker_tags}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@5138f76647652447004da686b2411557eaf65f33
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
- name: Build and push Docker image
uses: docker/build-push-action@f6010ea70151369b06f0194be1051fbbdff851b2
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
with:
context: .
platforms: linux/amd64,linux/arm64

View File

@@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out test private repo
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
repository: element-hq/static-call-participant
ref: refs/heads/main

View File

@@ -21,11 +21,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Yarn cache
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
cache: "yarn"
node-version: "lts/*"
- name: Install dependencies
run: "yarn install"
- name: Build
@@ -38,7 +39,7 @@ jobs:
VITE_APP_VERSION: ${{ inputs.vite_app_version }}
NODE_OPTIONS: "--max-old-space-size=4096"
- name: Upload Artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4
with:
name: build-output
path: dist

View File

@@ -7,11 +7,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Yarn cache
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
cache: "yarn"
node-version: "lts/*"
- name: Install dependencies
run: "yarn install"
- name: Prettier
@@ -22,3 +23,5 @@ jobs:
run: "yarn run lint:eslint"
- name: Type check
run: "yarn run lint:types"
- name: Dead code analysis
run: "yarn run lint:knip"

View File

@@ -34,7 +34,7 @@ jobs:
environment: Netlify
steps:
- name: 📝 Create Deployment
uses: bobheadxi/deployments@v1
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1
id: deployment
with:
step: start
@@ -46,7 +46,7 @@ jobs:
Exercise caution. Use test accounts.
- name: 📥 Download artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
github-token: ${{ secrets.ELEMENT_BOT_TOKEN }}
run-id: ${{ inputs.artifact_run_id }}
@@ -58,11 +58,11 @@ jobs:
run: curl -s https://raw.githubusercontent.com/element-hq/element-call/main/config/netlify_redirects > webapp/_redirects
- name: Add config file
run: curl -s "https://raw.githubusercontent.com/${{ inputs.pr_head_full_name }}/${{ inputs.pr_head_ref }}/config/element_io_preview.json" > webapp/config.json
run: curl -s "https://raw.githubusercontent.com/${{ inputs.pr_head_full_name }}/${{ inputs.pr_head_ref }}/config/config_netlify_preview.json" > webapp/config.json
- name: ☁️ Deploy to Netlify
id: netlify
uses: nwtgck/actions-netlify@v3.0
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0
with:
publish-dir: webapp
deploy-message: "Deploy from GitHub Actions"
@@ -73,7 +73,7 @@ jobs:
timeout-minutes: 1
- name: 🚦 Update deployment status
uses: bobheadxi/deployments@v1
uses: bobheadxi/deployments@648679e8e4915b27893bd7dbc35cb504dc915bc8 # v1
if: always()
with:
step: finish

View File

@@ -14,7 +14,7 @@ jobs:
pr_data_json: ${{ steps.prdetails.outputs.data }}
steps:
- id: prdetails
uses: matrix-org/pr-details-action@v1.3
uses: matrix-org/pr-details-action@15bde5285d7850ba276cc3bd8a03733e3f24622a # v1.3
continue-on-error: true
with:
owner: ${{ github.event.workflow_run.head_repository.owner.login }}

View File

@@ -39,7 +39,7 @@ jobs:
id: current-time
run: echo "unix_time=$(date +'%s')" >> $GITHUB_OUTPUT
- name: 📥 Download artifact
uses: actions/download-artifact@v4
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id || github.run_id }}
@@ -51,7 +51,7 @@ jobs:
run: |
tar --numeric-owner --transform "s/dist/element-call-${TARBALL_VERSION}/" -cvzf element-call-${TARBALL_VERSION}.tar.gz dist
- name: Upload
uses: actions/upload-artifact@552bf3722c16e81001aea7db72d8cedf64eb5f68
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:

View File

@@ -9,16 +9,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Yarn cache
uses: actions/setup-node@v4
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
cache: "yarn"
node-version: "lts/*"
- name: Install dependencies
run: "yarn install"
- name: Vitest
run: "yarn run test"
run: "yarn run test:coverage"
- name: Upload to codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: unittests
fail_ci_if_error: true

View File

@@ -13,11 +13,12 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-node@v4
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4
with:
cache: "yarn"
node-version: "lts/*"
- name: Install Deps
run: "yarn install --frozen-lockfile"
@@ -26,7 +27,7 @@ jobs:
run: "rm -R public/locales"
- name: Download translation files
uses: localazy/download@v1.1.0
uses: localazy/download@0a79880fb66150601e3b43606fab69c88123c087 # v1.1.0
with:
groups: "-p includeSourceLang:true"
@@ -38,7 +39,7 @@ jobs:
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6.0.5
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0
with:
token: ${{ secrets.ELEMENT_BOT_TOKEN }}
branch: actions/localazy-download

View File

@@ -14,9 +14,9 @@ jobs:
steps:
- name: Checkout the code
uses: actions/checkout@v4
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Upload
uses: localazy/upload@v1
uses: localazy/upload@27e6b5c0fddf4551596b42226b1c24124335d24a # v1
with:
write_key: ${{ secrets.LOCALAZY_WRITE_KEY }}

View File

@@ -1,25 +0,0 @@
const svgrPlugin = require("vite-plugin-svgr");
const path = require("path");
module.exports = {
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],
framework: "@storybook/react",
core: {
builder: "storybook-builder-vite",
},
async viteFinal(config) {
config.plugins = config.plugins.filter(
(item) =>
!(
Array.isArray(item) &&
item.length > 0 &&
item[0].name === "vite-plugin-mdx"
),
);
config.plugins.push(svgrPlugin());
config.resolve = config.resolve || {};
config.resolve.dedupe = config.resolve.dedupe || [];
config.resolve.dedupe.push("react", "react-dom", "matrix-js-sdk");
return config;
},
};

View File

@@ -1,24 +0,0 @@
import { addDecorator } from "@storybook/react";
import { MemoryRouter } from "react-router-dom";
import { usePageFocusStyle } from "../src/usePageFocusStyle";
import { OverlayProvider } from "@react-aria/overlays";
import "../src/index.css";
export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
addDecorator((story) => {
usePageFocusStyle();
return (
<MemoryRouter initialEntries={["/"]}>
<OverlayProvider>{story()}</OverlayProvider>
</MemoryRouter>
);
});

View File

@@ -22,7 +22,7 @@ yarn
yarn build
```
If all went well, you can now find the build output under `dist` as a series of static files. These can be hosted using any web server of your choice.
If all went well, you can now find the build output under `dist` as a series of static files. These can be hosted using any web server that can be configured with custom routes (see below).
You may also wish to add a configuration file (Element Call uses the domain it's hosted on as a Homeserver URL by default,
but you can change this in the config file). This goes in `public/config.json` - you can use the sample as a starting point:
@@ -131,7 +131,7 @@ advertises one in the client well-known, this will not be used.)
```json
"livekit": {
"livekit_service_url": "http://localhost:8881"
"livekit_service_url": "http://localhost:7881"
},
```
@@ -141,6 +141,32 @@ Run backend components:
yarn backend
```
### Test Coverage
<img src="https://codecov.io/github/element-hq/element-call/graphs/tree.svg?token=O6CFVKK6I1"></img>
### Add a new translation key
To add a new translation key you can do these steps:
1. Add the new key entry to the code where the new key is used: `t("some_new_key")`
1. Run `yarn i18n` to extract the new key and update the translation files. This will add a skeleton entry to the `public/locales/en-GB/app.json` file:
```jsonc
{
...
"some_new_key": "",
...
}
```
1. Update the skeleton entry in the `public/locales/en-GB/app.json` file with the English translation:
```jsonc
{
...
"some_new_key": "Some new key",
...
}
```
## Documentation
Usage and other technical details about the project can be found here:

15
codecov.yaml Normal file
View File

@@ -0,0 +1,15 @@
# Don't post comments on PRs; they're noisy and the same information can be
# gotten through the checks section at the bottom of the PR anyways
comment: false
coverage:
status:
project:
default:
# Track the impact of changes on overall coverage without blocking PRs
informational: true
patch:
default:
# Encourage (but don't enforce) 80% coverage on all lines that a PR
# touches
target: 80%
informational: true

View File

@@ -5,5 +5,11 @@
"server_name": "call.ems.host"
}
},
"livekit": {
"livekit_service_url": "http://localhost:7881"
},
"features": {
"feature_use_device_session_member_events": true
},
"eula": "https://static.element.io/legal/online-EULA.pdf"
}

View File

@@ -8,6 +8,9 @@
"livekit": {
"livekit_service_url": "https://livekit-jwt.call.element.dev"
},
"features": {
"feature_use_device_session_member_events": true
},
"posthog": {
"api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU",
"api_host": "https://posthog-element-call.element.io"

View File

@@ -1,19 +0,0 @@
{
"default_server_config": {
"m.homeserver": {
"base_url": "https://call.ems.host",
"server_name": "call.ems.host"
}
},
"posthog": {
"api_key": "phc_rXGHx9vDmyEvyRxPziYtdVIv0ahEv8A9uLWFcCi1WcU",
"api_host": "https://posthog-element-call.element.io"
},
"sentry": {
"environment": "main-branch-cd",
"DSN": "https://b1e328d49be3402ba96101338989fb35@sentry.matrix.org/41"
},
"rageshake": {
"submit_url": "https://element.io/bugreports/submit"
}
}

View File

@@ -2,5 +2,6 @@
This folder contains documentation for Element Call setup and usage.
- [Url format and parameters](./url-params.md)
- [Embedded vs standalone mode](./embedded-standalone.md)
- [Url format and parameters](./url-params.md)
- [Global JS controls](./controls.md)

7
docs/controls.md Normal file
View File

@@ -0,0 +1,7 @@
# Global JS controls
A few aspects of Element Call's interface can be controlled through a global API on the `window`:
- `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.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.

30
knip.ts Normal file
View File

@@ -0,0 +1,30 @@
import { KnipConfig } from "knip";
export default {
entry: ["src/main.tsx", "i18next-parser.config.ts"],
ignoreBinaries: [
// This is deprecated, so Knip doesn't actually recognize it as a globally
// installed binary. TODO We should switch to Compose v2:
// https://docs.docker.com/compose/migrate/
"docker-compose",
],
ignoreDependencies: [
// Used in CSS
"normalize.css",
// Used for its global type declarations
"@types/grecaptcha",
// Because we use matrix-js-sdk as a Git dependency rather than consuming
// the proper release artifacts, and also import directly from src/, we're
// forced to re-install some of the types that it depends on even though
// these look unused to Knip
"@types/content-type",
"@types/sdp-transform",
"@types/uuid",
// We obviously use this, but if the package has been linked with yarn link,
// then Knip will flag it as a false positive
// https://github.com/webpro-nl/knip/issues/766
"@vector-im/compound-web",
"matrix-widget-api",
],
ignoreExportsUsedInFile: true,
} satisfies KnipConfig;

View File

@@ -8,103 +8,60 @@
"serve": "vite preview",
"prettier:check": "prettier -c .",
"prettier:format": "prettier -w .",
"lint": "yarn lint:types && yarn lint:eslint",
"lint": "yarn lint:types && yarn lint:eslint && yarn lint:knip",
"lint:eslint": "eslint --max-warnings 0 src",
"lint:eslint-fix": "eslint --max-warnings 0 src --fix",
"lint:knip": "knip",
"lint:types": "tsc",
"i18n": "node_modules/i18next-parser/bin/cli.js",
"i18n:check": "node_modules/i18next-parser/bin/cli.js --fail-on-warnings --fail-on-update",
"i18n": "i18next",
"i18n:check": "i18next --fail-on-warnings --fail-on-update",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"test:coverage": "vitest --coverage",
"backend": "docker-compose -f backend-docker-compose.yml up"
},
"dependencies": {
"@juggle/resize-observer": "^3.3.1",
"@livekit/components-core": "^0.10.0",
"@livekit/components-react": "^2.0.0",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/context-zone": "^1.9.1",
"@opentelemetry/exporter-jaeger": "^1.9.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.48.0",
"@opentelemetry/instrumentation-document-load": "^0.38.0",
"@opentelemetry/instrumentation-user-interaction": "^0.38.0",
"@opentelemetry/sdk-trace-web": "^1.9.1",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-visually-hidden": "^1.0.3",
"@react-aria/button": "^3.3.4",
"@react-aria/focus": "^3.5.0",
"@react-aria/menu": "^3.3.0",
"@react-aria/overlays": "^3.7.3",
"@react-aria/select": "^3.6.0",
"@react-aria/tabs": "^3.1.0",
"@react-aria/tooltip": "^3.1.3",
"@react-aria/utils": "^3.10.0",
"@react-rxjs/core": "^0.10.7",
"@react-spring/web": "^9.4.4",
"@react-stately/collections": "^3.3.4",
"@react-stately/select": "^3.1.3",
"@react-stately/tooltip": "^3.0.5",
"@react-stately/tree": "^3.2.0",
"@sentry/react": "^7.0.0",
"@sentry/tracing": "^7.0.0",
"@types/lodash": "^4.14.199",
"@use-gesture/react": "^10.2.11",
"@vector-im/compound-design-tokens": "^1.0.0",
"@vector-im/compound-web": "^3.0.0",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-react": "^4.0.1",
"buffer": "^6.0.3",
"classnames": "^2.3.1",
"events": "^3.3.0",
"i18next": "^23.0.0",
"i18next-browser-languagedetector": "^7.0.0",
"i18next-http-backend": "^2.0.0",
"livekit-client": "^2.0.2",
"lodash": "^4.17.21",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#238eea0ef5c82d0a11b8d5cc5c04104d6c94c4c1",
"matrix-widget-api": "^1.3.1",
"normalize.css": "^8.0.1",
"pako": "^2.0.4",
"postcss-preset-env": "^9.0.0",
"posthog-js": "^1.29.0",
"react": "18",
"react-dom": "18",
"react-i18next": "^14.0.0",
"react-router-dom": "^5.2.0",
"react-use-clipboard": "^1.0.7",
"react-use-measure": "^2.1.1",
"rxjs": "^7.8.1",
"sdp-transform": "^2.14.1",
"tinyqueue": "^2.0.3",
"unique-names-generator": "^4.6.0",
"uuid": "9",
"vaul": "^0.9.0"
},
"devDependencies": {
"@babel/core": "^7.16.5",
"@babel/preset-env": "^7.22.20",
"@babel/preset-react": "^7.22.15",
"@babel/preset-typescript": "^7.23.0",
"@react-spring/rafz": "^9.7.3",
"@react-types/dialog": "^3.5.5",
"@livekit/components-core": "^0.11.0",
"@livekit/components-react": "^2.0.0",
"@opentelemetry/api": "^1.4.0",
"@opentelemetry/core": "^1.25.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.53.0",
"@opentelemetry/resources": "^1.25.1",
"@opentelemetry/sdk-trace-base": "^1.25.1",
"@opentelemetry/sdk-trace-web": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.25.1",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-visually-hidden": "^1.0.3",
"@react-spring/web": "^9.4.4",
"@sentry/react": "^8.0.0",
"@sentry/vite-plugin": "^2.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/dom": "^10.1.0",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.1",
"@types/content-type": "^1.1.5",
"@types/dom-screen-wake-lock": "^1.0.1",
"@types/dompurify": "^3.0.2",
"@types/grecaptcha": "^3.0.4",
"@types/grecaptcha": "^3.0.9",
"@types/jsdom": "^21.1.7",
"@types/lodash": "^4.14.199",
"@types/node": "^20.0.0",
"@types/qrcode": "^1.5.5",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"@types/request": "^2.48.8",
"@types/sdp-transform": "^2.4.5",
"@types/uuid": "9",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"babel-loader": "^9.0.0",
"@types/uuid": "10",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@use-gesture/react": "^10.2.11",
"@vector-im/compound-design-tokens": "^1.0.0",
"@vector-im/compound-web": "^6.0.0",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-react": "^4.0.1",
"@vitest/coverage-v8": "^2.0.5",
"babel-plugin-transform-vite-meta-env": "^1.0.3",
"classnames": "^2.3.1",
"eslint": "^8.14.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^9.0.0",
@@ -114,16 +71,43 @@
"eslint-plugin-matrix-org": "^1.2.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0",
"eslint-plugin-unicorn": "^51.0.0",
"i18next-parser": "^8.0.0",
"jsdom": "^24.0.0",
"eslint-plugin-unicorn": "^55.0.0",
"global-jsdom": "^24.0.0",
"history": "^4.0.0",
"i18next": "^23.0.0",
"i18next-browser-languagedetector": "^8.0.0",
"i18next-http-backend": "^2.0.0",
"i18next-parser": "^9.0.0",
"jsdom": "^25.0.0",
"knip": "^5.27.2",
"livekit-client": "^2.0.2",
"lodash": "^4.17.21",
"loglevel": "^1.9.1",
"matrix-js-sdk": "matrix-org/matrix-js-sdk#169e8f86139111574a3738f8557c6fa4b2a199db",
"matrix-widget-api": "^1.8.2",
"normalize.css": "^8.0.1",
"observable-hooks": "^4.2.3",
"pako": "^2.0.4",
"postcss": "^8.4.41",
"postcss-preset-env": "^10.0.0",
"posthog-js": "^1.29.0",
"prettier": "^3.0.0",
"qrcode": "^1.5.4",
"react": "18",
"react-dom": "18",
"react-i18next": "^15.0.0",
"react-router-dom": "^5.2.0",
"react-use-clipboard": "^1.0.7",
"react-use-measure": "^2.1.1",
"rxjs": "^7.8.1",
"sass": "^1.42.1",
"typescript": "^5.1.6",
"typescript-eslint-language-service": "^5.0.5",
"unique-names-generator": "^4.6.0",
"vaul": "^0.9.0",
"vite": "^5.0.0",
"vite-plugin-html-template": "^1.1.0",
"vite-plugin-svgr": "^4.0.0",
"vitest": "^1.2.2"
"vitest": "^2.0.0"
}
}

View File

@@ -58,8 +58,6 @@
"disconnected_banner": "Die Verbindung zum Server wurde getrennt.",
"full_screen_view_description": "<0>Übermittelte Problemberichte helfen uns, Fehler zu beheben.</0>",
"full_screen_view_h1": "<0>Hoppla, etwas ist schiefgelaufen.</0>",
"group_call_loader_failed_heading": "Anruf nicht gefunden",
"group_call_loader_failed_text": "Anrufe sind nun Ende-zu-Ende-verschlüsselt und müssen auf der Startseite erstellt werden. Damit stellen wir sicher, dass alle denselben Schlüssel verwenden.",
"hangup_button_label": "Anruf beenden",
"header_label": "Element Call-Startseite",
"header_participants_label": "Teilnehmende",

View File

@@ -4,8 +4,8 @@
},
"action": {
"close": "Close",
"copy": "Copy",
"copy_link": "Copy link",
"edit": "Edit",
"go": "Go",
"invite": "Invite",
"no": "No",
@@ -13,7 +13,8 @@
"remove": "Remove",
"sign_in": "Sign in",
"sign_out": "Sign out",
"submit": "Submit"
"submit": "Submit",
"upload_file": "Upload file"
},
"analytics_notice": "By participating in this beta, you consent to the collection of anonymous data, which we use to improve the product. You can find more information about which data we track in our <2>Privacy Policy</2> and our <5>Cookie Policy</5>.",
"app_selection_modal": {
@@ -41,14 +42,15 @@
"analytics": "Analytics",
"audio": "Audio",
"avatar": "Avatar",
"back": "Back",
"camera": "Camera",
"copied": "Copied!",
"display_name": "Display name",
"encrypted": "Encrypted",
"error": "Error",
"home": "Home",
"loading": "Loading…",
"microphone": "Microphone",
"next": "Next",
"options": "Options",
"password": "Password",
"profile": "Profile",
@@ -57,6 +59,8 @@
"username": "Username",
"video": "Video"
},
"crypto_version": "Crypto version: {{version}}",
"device_id": "Device ID: {{id}}",
"disconnected_banner": "Connectivity to the server has been lost.",
"full_screen_view_description": "<0>Submitting debug logs will help us track down the problem.</0>",
"full_screen_view_h1": "<0>Oops, something's gone wrong.</0>",
@@ -97,11 +101,13 @@
"login_auth_links_prompt": "Not registered yet?",
"login_subheading": "To continue to Element",
"login_title": "Login",
"matrix_id": "Matrix ID: {{id}}",
"microphone_off": "Microphone off",
"microphone_on": "Microphone on",
"mute_microphone_button_label": "Mute microphone",
"participant_count_one": "{{count, number}}",
"participant_count_other": "{{count, number}}",
"qr_code": "QR Code",
"rageshake_button_error_caption": "Retry sending logs",
"rageshake_request_modal": {
"body": "Another user on this call is having an issue. In order to better diagnose these issues we'd like to collect a debug log.",
@@ -125,11 +131,11 @@
"room_auth_view_eula_caption": "By clicking \"Join call now\", you agree to our <2>End User Licensing Agreement (EULA)</2>",
"room_auth_view_join_button": "Join call now",
"screenshare_button_label": "Share screen",
"select_input_unset_button": "Select an option",
"settings": {
"developer_settings_label": "Developer Settings",
"developer_settings_label_description": "Expose developer settings in the settings window.",
"developer_tab_title": "Developer",
"duplicate_tiles_label": "Number of additional tile copies per participant",
"feedback_tab_body": "If you are experiencing issues or simply would like to provide some feedback, please send us a short description below.",
"feedback_tab_description_label": "Your feedback",
"feedback_tab_h4": "Submit feedback",
@@ -138,7 +144,6 @@
"feedback_tab_title": "Feedback",
"more_tab_title": "More",
"opt_in_description": "<0></0><1></1>You may withdraw consent by unchecking this box. If you are currently in a call, this setting will take effect at the end of the call.",
"show_connection_stats_label": "Show connection stats",
"speaker_device_selection_label": "Speaker"
},
"star_rating_input_label_one": "{{count}} stars",
@@ -152,14 +157,13 @@
"unauthenticated_view_eula_caption": "By clicking \"Go\", you agree to our <2>End User Licensing Agreement (EULA)</2>",
"unauthenticated_view_login_button": "Login to your account",
"unmute_microphone_button_label": "Unmute microphone",
"version": "Version: {{version}}",
"version": "{{productName}} version: {{version}}",
"video_tile": {
"always_show": "Always show",
"change_fit_contain": "Fit to frame",
"exit_full_screen": "Exit full screen",
"full_screen": "Full screen",
"mute_for_me": "Mute for me",
"sfu_participant_local": "You",
"volume": "Volume"
},
"waiting_for_participants": "Waiting for other participants…"
}
}

View File

@@ -54,8 +54,6 @@
"disconnected_banner": "Võrguühendus serveriga on katkenud.",
"full_screen_view_description": "<0>Kui saadad meile vealogid, siis on lihtsam vea põhjust otsida.</0>",
"full_screen_view_h1": "<0>Ohoo, midagi on nüüd katki.</0>",
"group_call_loader_failed_heading": "Kõnet ei leidu",
"group_call_loader_failed_text": "Kõned on nüüd läbivalt krüptitud ning need pead looma kodulehelt. Sellega tagad, et kõik kasutavad samu krüptovõtmeid.",
"hangup_button_label": "Lõpeta kõne",
"header_participants_label": "Osalejad",
"invite_modal": {

View File

@@ -52,8 +52,6 @@
"disconnected_banner": "La connexion avec le serveur a été perdue.",
"full_screen_view_description": "<0>Soumettre les journaux de débogage nous aidera à déterminer le problème.</0>",
"full_screen_view_h1": "<0>Oups, quelque chose sest mal passé.</0>",
"group_call_loader_failed_heading": "Appel non trouvé",
"group_call_loader_failed_text": "Les appels sont maintenant chiffrés de bout-en-bout et doivent être créés depuis la page daccueil. Cela permet dêtre sûr que tout le monde utilise la même clé de chiffrement.",
"hangup_button_label": "Terminer lappel",
"header_label": "Accueil Element Call",
"invite_modal": {

View File

@@ -52,8 +52,6 @@
"disconnected_banner": "Koneksi ke server telah hilang.",
"full_screen_view_description": "<0>Mengirim catatan pengawakutuan akan membantu kami melacak masalahnya.</0>",
"full_screen_view_h1": "<0>Aduh, ada yang salah.</0>",
"group_call_loader_failed_heading": "Panggilan tidak ditemukan",
"group_call_loader_failed_text": "Panggilan sekarang terenkripsi secara ujung ke ujung dan harus dibuat dari laman beranda. Ini memastikan bahwa semuanya menggunakan kunci enkripsi yang sama.",
"hangup_button_label": "Akhiri panggilan",
"header_label": "Beranda Element Call",
"header_participants_label": "Peserta",

View File

@@ -50,8 +50,6 @@
"disconnected_banner": "La connessione al server è stata persa.",
"full_screen_view_description": "<0>L'invio di registri di debug ci aiuterà ad individuare il problema.</0>",
"full_screen_view_h1": "<0>Ops, qualcosa è andato storto.</0>",
"group_call_loader_failed_heading": "Chiamata non trovata",
"group_call_loader_failed_text": "Le chiamate ora sono cifrate end-to-end e devono essere create dalla pagina principale. Ciò assicura che chiunque usi la stessa chiave di crittografia.",
"hangup_button_label": "Termina chiamata",
"header_label": "Inizio di Element Call",
"header_participants_label": "Partecipanti",

View File

@@ -55,8 +55,6 @@
"disconnected_banner": "Utracono połączenie z serwerem.",
"full_screen_view_description": "<0>Wysłanie dzienników debuggowania pomoże nam ustalić przyczynę problemu.</0>",
"full_screen_view_h1": "<0>Ojej, coś poszło nie tak.</0>",
"group_call_loader_failed_heading": "Nie znaleziono połączenia",
"group_call_loader_failed_text": "Połączenia są teraz szyfrowane end-to-end i muszą zostać utworzone ze strony głównej. Pomaga to upewnić się, że każdy korzysta z tego samego klucza szyfrującego.",
"hangup_button_label": "Zakończ połączenie",
"header_label": "Strona główna Element Call",
"header_participants_label": "Uczestnicy",

View File

@@ -53,8 +53,6 @@
"disconnected_banner": "Spojenie so serverom sa stratilo.",
"full_screen_view_description": "<0>Odoslanie záznamov ladenia nám pomôže nájsť problém.</0>",
"full_screen_view_h1": "<0>Hups, niečo sa pokazilo.</0>",
"group_call_loader_failed_heading": "Hovor nebol nájdený",
"group_call_loader_failed_text": "Hovory sú teraz end-to-end šifrované a je potrebné ich vytvoriť z domovskej stránky. To pomáha zabezpečiť, aby všetci používali rovnaký šifrovací kľúč.",
"hangup_button_label": "Ukončiť hovor",
"header_label": "Domov Element Call",
"header_participants_label": "Účastníci",

View File

@@ -55,8 +55,6 @@
"disconnected_banner": "Втрачено зв'язок з сервером.",
"full_screen_view_description": "<0>Надсилання журналів налагодження допоможе нам виявити проблему.</0>",
"full_screen_view_h1": "<0>Йой, щось пішло не за планом.</0>",
"group_call_loader_failed_heading": "Виклик не знайдено",
"group_call_loader_failed_text": "Відтепер виклики захищено наскрізним шифруванням, і їх потрібно створювати з домашньої сторінки. Це допомагає переконатися, що всі користувачі використовують один і той самий ключ шифрування.",
"hangup_button_label": "Завершити виклик",
"header_label": "Домівка Element Call",
"header_participants_label": "Учасники",

View File

@@ -53,8 +53,6 @@
"disconnected_banner": "与服务器的连接中断。",
"full_screen_view_description": "<0>提交日志以帮助我们修复问题。</0>",
"full_screen_view_h1": "<0>哎哟,出问题了。</0>",
"group_call_loader_failed_heading": "未找到通话",
"group_call_loader_failed_text": "现在,通话是端对端加密的,需要从主页创建。这有助于确保每个人都使用相同的加密密钥。",
"hangup_button_label": "通话结束",
"header_label": "Element Call主页",
"join_existing_call_modal": {

View File

@@ -55,8 +55,6 @@
"disconnected_banner": "到伺服器的連線已遺失。",
"full_screen_view_description": "<0>送出除錯紀錄,可幫助我們修正問題。</0>",
"full_screen_view_h1": "<0>喔喔,有些地方怪怪的。</0>",
"group_call_loader_failed_heading": "找不到通話",
"group_call_loader_failed_text": "通話現在是端對端加密的,必須從首頁建立。這有助於確保每個人都使用相同的加密金鑰。",
"hangup_button_label": "結束通話",
"header_label": "Element Call 首頁",
"header_participants_label": "參與者",

View File

@@ -3,25 +3,46 @@
"extends": ["config:base"],
"packageRules": [
{
"description": "Disable renoavte for packages we want to monitor ourselves",
"matchPackagePatterns": ["matrix-js-sdk"],
"groupName": "all non-major dependencies",
"groupSlug": "all-minor-patch",
"matchUpdateTypes": ["minor", "patch"],
"extends": ["schedule:weekly"]
},
{
"groupName": "GitHub Actions",
"matchDepTypes": ["action"],
"pinDigests": true,
"extends": ["schedule:monthly"]
},
{
"description": "Disable Renovate for packages we want to monitor ourselves",
"groupName": "manually updated packages",
"matchDepNames": ["matrix-js-sdk"],
"enabled": false
},
{
"groupName": "matrix-widget-api",
"matchDepNames": ["matrix-widget-api"]
},
{
"groupName": "Compound",
"matchPackagePrefixes": ["@vector-im/compound-"],
"schedule": "before 5am on Tuesday and Friday"
},
{
"groupName": "LiveKit client",
"matchDepNames": ["livekit-client"]
},
{
"groupName": "LiveKit components",
"matchPackagePrefixes": ["@livekit/components-"]
},
{
"groupName": "Vaul",
"matchDepNames": ["vaul"],
"extends": ["schedule:monthly"],
"prHeader": "Please review modals on mobile for visual regressions."
}
],
"semanticCommits": "disabled",
"ignoreDeps": [
"@react-aria/button",
"@react-aria/focus",
"@react-aria/menu",
"@react-aria/overlays",
"@react-aria/select",
"@react-aria/tabs",
"@react-aria/tooltip",
"@react-aria/utils",
"@react-stately/collections",
"@react-stately/select",
"@react-stately/tooltip",
"@react-stately/tree",
"@react-types/dialog"
]
"semanticCommits": "disabled"
}

View File

@@ -15,6 +15,7 @@ limitations under the License.
*/
import "matrix-js-sdk/src/@types/global";
import { Controls } from "../controls";
declare global {
interface Document {
@@ -24,14 +25,7 @@ declare global {
}
interface Window {
// TODO: https://gitlab.matrix.org/matrix-org/olm/-/issues/10
OLM_OPTIONS: Record<string, string>;
}
// TypeScript doesn't know about the experimental setSinkId method, so we
// declare it ourselves
interface MediaElement extends HTMLVideoElement {
setSinkId: (id: string) => void;
controls: Controls;
}
interface HTMLElement {

View File

@@ -22,7 +22,6 @@ import {
useLocation,
} from "react-router-dom";
import * as Sentry from "@sentry/react";
import { OverlayProvider } from "@react-aria/overlays";
import { History } from "history";
import { TooltipProvider } from "@vector-im/compound-web";
@@ -92,23 +91,21 @@ export const App: FC<AppProps> = ({ history }) => {
<ClientProvider>
<MediaDevicesProvider>
<Sentry.ErrorBoundary fallback={errorPage}>
<OverlayProvider>
<DisconnectedBanner />
<Switch>
<SentryRoute exact path="/">
<HomePage />
</SentryRoute>
<SentryRoute exact path="/login">
<LoginPage />
</SentryRoute>
<SentryRoute exact path="/register">
<RegisterPage />
</SentryRoute>
<SentryRoute path="*">
<RoomPage />
</SentryRoute>
</Switch>
</OverlayProvider>
<DisconnectedBanner />
<Switch>
<SentryRoute exact path="/">
<HomePage />
</SentryRoute>
<SentryRoute exact path="/login">
<LoginPage />
</SentryRoute>
<SentryRoute exact path="/register">
<RegisterPage />
</SentryRoute>
<SentryRoute path="*">
<RoomPage />
</SentryRoute>
</Switch>
</Sentry.ErrorBoundary>
</MediaDevicesProvider>
</ClientProvider>

View File

@@ -17,7 +17,7 @@ limitations under the License.
import { useMemo, FC } from "react";
import { Avatar as CompoundAvatar } from "@vector-im/compound-web";
import { getAvatarUrl } from "./matrix-utils";
import { getAvatarUrl } from "./utils/matrix";
import { useClient } from "./ClientContext";
export enum Size {

View File

@@ -1,27 +0,0 @@
/*
Copyright 2023 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { FC, ReactNode } from "react";
import styles from "./Banner.module.css";
interface Props {
children: ReactNode;
}
export const Banner: FC<Props> = ({ children }) => {
return <div className={styles.banner}>{children}</div>;
};

View File

@@ -33,13 +33,10 @@ import {
import { logger } from "matrix-js-sdk/src/logger";
import { useTranslation } from "react-i18next";
import { ISyncStateData, SyncState } from "matrix-js-sdk/src/sync";
import { MatrixError } from "matrix-js-sdk/src/matrix";
import { ErrorView } from "./FullScreenView";
import {
CryptoStoreIntegrityError,
fallbackICEServerAllowed,
initClient,
} from "./matrix-utils";
import { fallbackICEServerAllowed, initClient } from "./utils/matrix";
import { widget } from "./widget";
import {
PosthogAnalytics,
@@ -380,22 +377,17 @@ async function loadClient(): Promise<InitResult | null> {
passwordlessUser,
};
} catch (err) {
if (err instanceof CryptoStoreIntegrityError) {
if (err instanceof MatrixError && err.errcode === "M_UNKNOWN_TOKEN") {
// We can't use this session anymore, so let's log it out
try {
const client = await initClient(initClientParams, false); // Don't need the crypto store just to log out)
await client.logout(true);
} catch (err) {
logger.warn(
"The previous session was lost, and we couldn't log it out, " +
err +
"either",
);
}
logger.log(
"The session from local store is invalid; continuing without a client",
);
clearSession();
// returning null = "no client` pls register" (undefined = "loading" which is the current value when reaching this line)
return null;
}
throw err;
}
/* eslint-enable camelcase */
} catch (err) {
clearSession();
throw err;

View File

@@ -20,9 +20,10 @@ import classNames from "classnames";
import { Trans, useTranslation } from "react-i18next";
import * as Sentry from "@sentry/react";
import { logger } from "matrix-js-sdk/src/logger";
import { Button } from "@vector-im/compound-web";
import { Header, HeaderLogo, LeftNav, RightNav } from "./Header";
import { LinkButton, Button } from "./button";
import { LinkButton } from "./button";
import styles from "./FullScreenView.module.css";
import { TranslatedError } from "./TranslatedError";
import { Config } from "./config/Config";
@@ -81,21 +82,11 @@ export const ErrorView: FC<ErrorViewProps> = ({ error }) => {
<RageshakeButton description={`***Error View***: ${error.message}`} />
{!confineToRoom &&
(location.pathname === "/" ? (
<Button
size="lg"
variant="default"
className={styles.homeLink}
onPress={onReload}
>
<Button className={styles.homeLink} onClick={onReload}>
{t("return_home_button")}
</Button>
) : (
<LinkButton
size="lg"
variant="default"
className={styles.homeLink}
to="/"
>
<LinkButton className={styles.homeLink} to="/">
{t("return_home_button")}
</LinkButton>
))}
@@ -122,12 +113,7 @@ export const CrashView: FC = () => {
)}
<RageshakeButton description="***Soft Crash***" />
<Button
size="lg"
variant="default"
className={styles.wideButton}
onPress={onReload}
>
<Button className={styles.wideButton} onClick={onReload}>
{t("return_home_button")}
</Button>
</FullScreenView>

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2022-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -90,6 +90,7 @@ limitations under the License.
.nameLine {
grid-area: name;
flex-grow: 1;
min-width: 0;
display: flex;
align-items: center;
gap: var(--cpd-space-1x);
@@ -97,8 +98,6 @@ limitations under the License.
.nameLine > h1 {
margin: 0;
/* XXX I can't actually get this ellipsis overflow to trigger, because
constraint propagation in a nested flexbox layout is a massive pain */
overflow: hidden;
text-overflow: ellipsis;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2022-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -15,11 +15,11 @@ limitations under the License.
*/
import classNames from "classnames";
import { FC, HTMLAttributes, ReactNode } from "react";
import { FC, HTMLAttributes, ReactNode, forwardRef } from "react";
import { Link } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Heading, Text } from "@vector-im/compound-web";
import UserProfileIcon from "@vector-im/compound-design-tokens/icons/user-profile.svg?react";
import { UserProfileIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import styles from "./Header.module.css";
import Logo from "./icons/Logo.svg?react";
@@ -32,13 +32,21 @@ interface HeaderProps extends HTMLAttributes<HTMLElement> {
className?: string;
}
export const Header: FC<HeaderProps> = ({ children, className, ...rest }) => {
return (
<header className={classNames(styles.header, className)} {...rest}>
{children}
</header>
);
};
export const Header = forwardRef<HTMLElement, HeaderProps>(
({ children, className, ...rest }, ref) => {
return (
<header
ref={ref}
className={classNames(styles.header, className)}
{...rest}
>
{children}
</header>
);
},
);
Header.displayName = "Header";
interface LeftNavProps extends HTMLAttributes<HTMLElement> {
children: ReactNode;

View File

@@ -1,49 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.listBox {
margin: 0;
padding: 0;
max-height: 150px;
overflow-y: auto;
list-style: none;
background-color: transparent;
border: 1px solid var(--cpd-color-border-interactive-secondary);
background-color: var(--cpd-color-bg-canvas-default);
border-radius: 8px;
}
.option {
display: flex;
align-items: center;
justify-content: space-between;
background-color: transparent;
color: var(--cpd-color-text-primary);
padding: 8px 16px;
outline: none;
cursor: pointer;
font-size: var(--font-size-body);
min-height: 32px;
}
.option.focused {
background-color: rgba(111, 120, 130, 0.2);
}
.option.disabled {
color: var(--cpd-color-text-disabled);
background-color: var(--stopgap-bgColor3);
}

View File

@@ -1,116 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {
MutableRefObject,
PointerEvent,
ReactNode,
useCallback,
useRef,
} from "react";
import { useListBox, useOption, AriaListBoxOptions } from "@react-aria/listbox";
import { ListState } from "@react-stately/list";
import { Node } from "@react-types/shared";
import classNames from "classnames";
import styles from "./ListBox.module.css";
interface ListBoxProps<T> extends AriaListBoxOptions<T> {
optionClassName: string;
state: ListState<T>;
className?: string;
listBoxRef?: MutableRefObject<HTMLUListElement>;
}
export function ListBox<T>({
state,
optionClassName,
className,
listBoxRef,
...rest
}: ListBoxProps<T>): ReactNode {
const ref = useRef<HTMLUListElement>(null);
const listRef = listBoxRef ?? ref;
const { listBoxProps } = useListBox(rest, state, listRef);
return (
<ul
{...listBoxProps}
ref={listRef}
className={classNames(styles.listBox, className)}
>
{[...state.collection].map((item) => (
<Option
key={item.key}
item={item}
state={state}
className={optionClassName}
/>
))}
</ul>
);
}
interface OptionProps<T> {
className: string;
state: ListState<T>;
item: Node<T>;
}
function Option<T>({ item, state, className }: OptionProps<T>): ReactNode {
const ref = useRef(null);
const { optionProps, isSelected, isFocused, isDisabled } = useOption(
{ key: item.key },
state,
ref,
);
// Hack: remove the onPointerUp event handler and re-wire it to
// onClick. Chrome Android triggers a click event after the onpointerup
// event which leaks through to elements underneath the z-indexed select
// popover. preventDefault / stopPropagation don't have any effect, even
// adding just a dummy onClick handler still doesn't work, but it's fine
// if we handle just onClick.
// https://github.com/vector-im/element-call/issues/762
const origPointerUp = optionProps.onPointerUp;
delete optionProps.onPointerUp;
optionProps.onClick = useCallback(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
(e) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
origPointerUp(e as unknown as PointerEvent<HTMLElement>);
},
[origPointerUp],
);
return (
<li
{...optionProps}
ref={ref}
className={classNames(styles.option, className, {
[styles.selected]: isSelected,
[styles.focused]: isFocused,
[styles.disables]: isDisabled,
})}
>
{item.rendered}
</li>
);
}

View File

@@ -1,73 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.menu {
width: 100%;
padding: 0;
margin: 0;
list-style: none;
}
.menuItem {
cursor: pointer;
height: 48px;
display: flex;
align-items: center;
padding: 0 12px;
color: var(--cpd-color-text-primary);
font-size: var(--font-size-body);
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.menuItem > * {
margin: 0 10px 0 0;
}
.menuItem > :last-child {
margin-right: 0;
}
.menuItem.focused,
.menuItem:hover {
background-color: var(--cpd-color-bg-action-secondary-hovered);
}
.menuItem:active {
background-color: var(--cpd-color-bg-action-secondary-pressed);
}
.menuItem.focused:first-child,
.menuItem:hover:first-child {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
.menuItem.focused:last-child,
.menuItem:hover:last-child {
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}
.checkIcon {
position: absolute;
right: 16px;
}
.checkIcon * {
stroke: var(--cpd-color-text-primary);
}

View File

@@ -1,102 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Key, ReactNode, useRef, useState } from "react";
import { AriaMenuOptions, useMenu, useMenuItem } from "@react-aria/menu";
import { TreeState, useTreeState } from "@react-stately/tree";
import { mergeProps } from "@react-aria/utils";
import { useFocus } from "@react-aria/interactions";
import classNames from "classnames";
import { Node } from "@react-types/shared";
import styles from "./Menu.module.css";
interface MenuProps<T> extends AriaMenuOptions<T> {
className?: string;
onClose: () => void;
onAction: (value: Key) => void;
label?: string;
}
export function Menu<T extends object>({
className,
onAction,
onClose,
label,
...rest
}: MenuProps<T>): ReactNode {
const state = useTreeState<T>({ ...rest, selectionMode: "none" });
const menuRef = useRef(null);
const { menuProps } = useMenu<T>(rest, state, menuRef);
return (
<ul
{...mergeProps(menuProps, rest)}
ref={menuRef}
className={classNames(styles.menu, className)}
>
{[...state.collection].map((item) => (
<MenuItem
key={item.key}
item={item}
state={state}
onAction={onAction}
onClose={onClose}
/>
))}
</ul>
);
}
interface MenuItemProps<T> {
item: Node<T>;
state: TreeState<T>;
onAction: (value: Key) => void;
onClose: () => void;
}
function MenuItem<T>({
item,
state,
onAction,
onClose,
}: MenuItemProps<T>): ReactNode {
const ref = useRef(null);
const { menuItemProps } = useMenuItem(
{
key: item.key,
onAction,
onClose,
},
state,
ref,
);
const [isFocused, setFocused] = useState(false);
const { focusProps } = useFocus({ onFocusChange: setFocused });
return (
<li
{...mergeProps(menuItemProps, focusProps)}
ref={ref}
className={classNames(styles.menuItem, {
[styles.focused]: isFocused,
})}
>
{item.rendered}
</li>
);
}

View File

@@ -134,6 +134,10 @@ body[data-platform="ios"] .drawer {
padding-block: var(--cpd-space-9x) var(--cpd-space-10x);
}
.modal.tabbed .body {
padding-block-start: 0;
}
.handle {
content: "";
position: absolute;

View File

@@ -15,7 +15,6 @@ limitations under the License.
*/
import { FC, ReactNode, useCallback } from "react";
import { AriaDialogProps } from "@react-types/dialog";
import { useTranslation } from "react-i18next";
import {
Root as DialogRoot,
@@ -27,7 +26,7 @@ import {
} from "@radix-ui/react-dialog";
import { Drawer } from "vaul";
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import CloseIcon from "@vector-im/compound-design-tokens/icons/close.svg?react";
import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
import classNames from "classnames";
import { Heading, Glass } from "@vector-im/compound-web";
@@ -35,8 +34,7 @@ import styles from "./Modal.module.css";
import overlayStyles from "./Overlay.module.css";
import { useMediaQuery } from "./useMediaQuery";
// TODO: Support tabs
export interface Props extends AriaDialogProps {
export interface Props {
title: string;
children: ReactNode;
className?: string;
@@ -52,6 +50,11 @@ export interface Props extends AriaDialogProps {
* will be non-dismissable.
*/
onDismiss?: () => void;
/**
* Whether the modal content has tabs.
*/
// TODO: Better tabs support
tabbed?: boolean;
}
/**
@@ -64,6 +67,7 @@ export const Modal: FC<Props> = ({
className,
open,
onDismiss,
tabbed,
...rest
}) => {
const { t } = useTranslation();
@@ -92,6 +96,7 @@ export const Modal: FC<Props> = ({
overlayStyles.overlay,
styles.modal,
styles.drawer,
{ [styles.tabbed]: tabbed },
)}
{...rest}
>
@@ -123,6 +128,7 @@ export const Modal: FC<Props> = ({
overlayStyles.animate,
styles.modal,
styles.dialog,
{ [styles.tabbed]: tabbed },
)}
>
<div className={styles.content}>

View File

@@ -36,3 +36,8 @@ if (/android/i.test(navigator.userAgent)) {
} else {
platform = "desktop";
}
export const isFirefox = (): boolean => {
const { userAgent } = navigator;
return userAgent.includes("Firefox");
};

View File

@@ -1,5 +1,5 @@
/*
Copyright 2023 New Vector Ltd
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,9 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
.banner {
flex: 1;
border-radius: 8px;
padding: 16px;
background-color: var(--cpd-color-bg-subtle-primary);
.qrCode img {
max-width: 100%;
image-rendering: pixelated;
border-radius: var(--cpd-space-4x);
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,16 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import Olm from "@matrix-org/olm";
import olmWasmPath from "@matrix-org/olm/olm.wasm?url";
import { describe, expect, test } from "vitest";
import { render, configure } from "@testing-library/react";
// https://gitlab.matrix.org/matrix-org/olm/-/issues/10
window.OLM_OPTIONS = {};
import { QrCode } from "./QrCode";
let olmLoaded: Promise<void> | null = null;
configure({
defaultHidden: true,
});
/**
* Loads Olm, if not already loaded.
*/
export const loadOlm = (): Promise<void> =>
(olmLoaded ??= Olm.init({ locateFile: () => olmWasmPath }));
describe("QrCode", () => {
test("renders", async () => {
const { container, findByRole } = render(
<QrCode data="foo" className="bar" />,
);
(await findByRole("img")) as HTMLImageElement;
expect(container.firstChild).toMatchSnapshot();
});
});

57
src/QrCode.tsx Normal file
View File

@@ -0,0 +1,57 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { FC, useEffect, useState } from "react";
import { toDataURL } from "qrcode";
import classNames from "classnames";
import { t } from "i18next";
import styles from "./QrCode.module.css";
interface Props {
data: string;
className?: string;
}
export const QrCode: FC<Props> = ({ data, className }) => {
const [url, setUrl] = useState<string | null>(null);
useEffect(() => {
let isCancelled = false;
toDataURL(data, { errorCorrectionLevel: "L" })
.then((url) => {
if (!isCancelled) {
setUrl(url);
}
})
.catch((reason) => {
if (!isCancelled) {
setUrl(null);
}
});
return (): void => {
isCancelled = true;
};
}, [data]);
return (
<div className={classNames(styles.qrCode, className)}>
{url && <img src={url} alt={t("qr_code")} />}
</div>
);
};

85
src/Toast.test.tsx Normal file
View File

@@ -0,0 +1,85 @@
/*
Copyright 2023 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { describe, expect, test, vi } from "vitest";
import { render, configure } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Toast } from "../src/Toast";
import { withFakeTimers } from "./utils/test";
configure({
defaultHidden: true,
});
// Test Explanation:
// This test the toast. We need to use { document: window.document } because the toast listens
// for user input on `window`.
describe("Toast", () => {
test("renders", () => {
const { queryByRole } = render(
<Toast open={false} onDismiss={() => {}}>
Hello world!
</Toast>,
);
expect(queryByRole("dialog")).toBe(null);
const { getByRole } = render(
<Toast open={true} onDismiss={() => {}}>
Hello world!
</Toast>,
);
expect(getByRole("dialog")).toMatchSnapshot();
});
test("dismisses when Esc is pressed", async () => {
const user = userEvent.setup({ document: window.document });
const onDismiss = vi.fn();
render(
<Toast open={true} onDismiss={onDismiss}>
Hello world!
</Toast>,
);
await user.keyboard("[Escape]");
expect(onDismiss).toHaveBeenCalled();
});
test("dismisses when background is clicked", async () => {
const user = userEvent.setup();
const onDismiss = vi.fn();
const { getByRole, unmount } = render(
<Toast open={true} onDismiss={onDismiss}>
Hello world!
</Toast>,
);
const background = getByRole("dialog").previousSibling! as Element;
await user.click(background);
expect(onDismiss).toHaveBeenCalled();
unmount();
});
test("dismisses itself after the specified timeout", () => {
withFakeTimers(() => {
const onDismiss = vi.fn();
render(
<Toast open={true} onDismiss={onDismiss} autoDismiss={2000}>
Hello world!
</Toast>,
);
vi.advanceTimersByTime(2000);
expect(onDismiss).toHaveBeenCalled();
});
});
});

View File

@@ -86,7 +86,7 @@ export const Toast: FC<Props> = ({
<DialogOverlay
className={classNames(overlayStyles.bg, overlayStyles.animate)}
/>
<DialogContent asChild>
<DialogContent aria-describedby={undefined} asChild>
<DialogClose
className={classNames(
overlayStyles.overlay,

View File

@@ -1,30 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.tooltip {
background-color: var(--cpd-color-bg-subtle-secondary);
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10px;
color: var(--cpd-color-text-primary);
border-radius: 8px;
max-width: 135px;
width: max-content;
font-size: var(--font-size-caption);
font-weight: 500;
text-align: center;
}

View File

@@ -1,118 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {
ForwardedRef,
forwardRef,
ReactElement,
ReactNode,
useRef,
} from "react";
import {
TooltipTriggerState,
useTooltipTriggerState,
} from "@react-stately/tooltip";
import { FocusableProvider } from "@react-aria/focus";
import { useTooltipTrigger, useTooltip } from "@react-aria/tooltip";
import { mergeProps, useObjectRef } from "@react-aria/utils";
import classNames from "classnames";
import { OverlayContainer, useOverlayPosition } from "@react-aria/overlays";
import { Placement } from "@react-types/overlays";
import styles from "./Tooltip.module.css";
interface TooltipProps {
className?: string;
state: TooltipTriggerState;
children: ReactNode;
}
const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
(
{ state, className, children, ...rest }: TooltipProps,
ref: ForwardedRef<HTMLDivElement>,
) => {
const { tooltipProps } = useTooltip(rest, state);
return (
<div
className={classNames(styles.tooltip, className)}
{...mergeProps(rest, tooltipProps)}
ref={ref}
>
{children}
</div>
);
},
);
Tooltip.displayName = "Tooltip";
interface TooltipTriggerProps {
children: ReactElement;
placement?: Placement;
delay?: number;
tooltip: () => string;
}
export const TooltipTrigger = forwardRef<HTMLElement, TooltipTriggerProps>(
(
{ children, placement, tooltip, ...rest }: TooltipTriggerProps,
ref: ForwardedRef<HTMLElement>,
) => {
const tooltipTriggerProps = { delay: 250, ...rest };
const tooltipState = useTooltipTriggerState(tooltipTriggerProps);
const triggerRef = useObjectRef<HTMLElement>(ref);
const overlayRef = useRef<HTMLDivElement>(null);
const { triggerProps, tooltipProps } = useTooltipTrigger(
tooltipTriggerProps,
tooltipState,
triggerRef,
);
const { overlayProps } = useOverlayPosition({
placement: placement || "top",
targetRef: triggerRef,
overlayRef,
isOpen: tooltipState.isOpen,
offset: 12,
});
return (
<FocusableProvider ref={triggerRef} {...triggerProps}>
<children.type
{...mergeProps<typeof children.props | typeof rest>(
children.props,
rest,
)}
/>
{tooltipState.isOpen && (
<OverlayContainer>
<Tooltip
state={tooltipState}
ref={overlayRef}
{...mergeProps(tooltipProps, overlayProps)}
>
{tooltip()}
</Tooltip>
</OverlayContainer>
)}
</FocusableProvider>
);
},
);
TooltipTrigger.displayName = "TooltipTrigger";

View File

@@ -14,23 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { vi } from "vitest";
import { describe, expect, it } from "vitest";
import { getRoomIdentifierFromUrl } from "../src/UrlParams";
import { Config } from "../src/config/Config";
const ROOM_NAME = "roomNameHere";
const ROOM_ID = "!d45f138fsd";
const ORIGIN = "https://call.element.io";
const HOMESERVER = "call.ems.host";
vi.mock("../src/config/Config");
const HOMESERVER = "localhost";
describe("UrlParams", () => {
beforeAll(() => {
vi.mocked(Config.defaultServerName).mockReturnValue("call.ems.host");
});
describe("handles URL with /room/", () => {
it("and nothing else", () => {
expect(

View File

@@ -21,6 +21,14 @@ limitations under the License.
flex-shrink: 0;
}
.userButton {
appearance: none;
background: none;
border: none;
margin: 0;
cursor: pointer;
}
.userButton svg * {
fill: var(--cpd-color-icon-primary);
}

View File

@@ -14,21 +14,17 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { FC, ReactNode, useCallback, useMemo } from "react";
import { Item } from "@react-stately/collections";
import { FC, useMemo, useState } from "react";
import { useLocation } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { Menu, MenuItem } from "@vector-im/compound-web";
import { Button, LinkButton } from "./button";
import { PopoverMenuTrigger } from "./popover/PopoverMenu";
import { Menu } from "./Menu";
import { TooltipTrigger } from "./Tooltip";
import { LinkButton } from "./button";
import { Avatar, Size } from "./Avatar";
import UserIcon from "./icons/User.svg?react";
import SettingsIcon from "./icons/Settings.svg?react";
import LoginIcon from "./icons/Login.svg?react";
import LogoutIcon from "./icons/Logout.svg?react";
import { Body } from "./typography/Typography";
import styles from "./UserMenu.module.css";
interface Props {
@@ -91,7 +87,7 @@ export const UserMenu: FC<Props> = ({
return arr;
}, [isAuthenticated, isPasswordlessUser, displayName, preventNavigation, t]);
const tooltip = useCallback(() => t("common.profile"), [t]);
const [open, setOpen] = useState(false);
if (!isAuthenticated) {
return (
@@ -102,10 +98,15 @@ export const UserMenu: FC<Props> = ({
}
return (
<PopoverMenuTrigger placement="bottom right">
<TooltipTrigger tooltip={tooltip} placement="bottom left">
<Button
variant="icon"
<Menu
title={t("a11y.user_menu")}
showTitle={false}
align="end"
open={open}
onOpenChange={setOpen}
trigger={
<button
aria-label={t("common.profile")}
className={styles.userButton}
data-testid="usermenu_open"
>
@@ -119,26 +120,18 @@ export const UserMenu: FC<Props> = ({
) : (
<UserIcon />
)}
</Button>
</TooltipTrigger>
{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(props: any): ReactNode => (
<Menu {...props} label={t("a11y.user_menu")} onAction={onAction}>
{items.map(({ key, icon: Icon, label, dataTestid }) => (
<Item key={key} textValue={label}>
<Icon
width={24}
height={24}
className={styles.menuIcon}
data-testid={dataTestid}
/>
<Body overflowEllipsis>{label}</Body>
</Item>
))}
</Menu>
)
</button>
}
</PopoverMenuTrigger>
>
{items.map(({ key, icon: Icon, label, dataTestid }) => (
<MenuItem
key={key}
Icon={Icon}
label={label}
data-test-id={dataTestid}
onSelect={() => onAction(key)}
/>
))}
</Menu>
);
};

View File

@@ -0,0 +1,12 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`QrCode > renders 1`] = `
<div
class="qrCode bar"
>
<img
alt="qr_code"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHQAAAB0CAYAAABUmhYnAAAAAklEQVR4AewaftIAAALBSURBVO3BQW7kQAwEwSxC//9yro88NSBI4/UQjIg/WGMUa5RijVKsUYo1SrFGKdYoxRqlWKMUa5RijVKsUYo1SrFGKdYoxRrl4qEk/CaVkyR0Kl0STlS6JPwmlSeKNUqxRinWKBcvU3lTEk6S8ITKHSpvSsKbijVKsUYp1igXH5aEO1Q+SaVLQqdyRxLuUPmkYo1SrFGKNcrFl1PpknCShE5lkmKNUqxRijXKxZdLQqdyotIloVP5ZsUapVijFGuUiw9T+UuS8CaVv6RYoxRrlGKNcvGyJPwlSehUuiTckYS/rFijFGuUYo0Sf/DFkvAmlW9WrFGKNUqxRrl4KAknKl0SOpWTJJyodEk4UbkjCXeodEk4UXlTsUYp1ijFGuXiIZUuCXck4USlS0KXhE7lk1TelIRO5YlijVKsUYo1ysXLVLok3KHSJaFT6ZLQJaFTOUnCicodSehUTpLwpmKNUqxRijXKxUNJ6FSeSEKn0iXhROUkCZ3Kb0pCp/KmYo1SrFGKNcrFh6mcJKFT6ZJwotIloVPpVLokdCpdEjqVLgmdyh1J6FSeKNYoxRqlWKPEH3yxJHQqJ0noVO5IwolKl4ROpUtCp/JEsUYp1ijFGuXioST8JpU7ktCpnCShUzlROVHpktCpvKlYoxRrlGKNcvEylTcl4USlS8JJEt6UhBOVTqVLQqfyRLFGKdYoxRrl4sOScIfKEyonSehUTpJwh0qXhN9UrFGKNUqxRrn4ckn4JJU7kvA/FWuUYo1SrFEuvpxKl4QTlS4JncodSehU7kjCm4o1SrFGKdYoFx+m8klJOFE5UemScKJyRxI6lU7lTcUapVijFGuUi5cl4X9SOUnCicoTSThJQqfypmKNUqxRijVK/MEao1ijFGuUYo1SrFGKNUqxRinWKMUapVijFGuUYo1SrFGKNUqxRinWKP8AKoQP/lIBoMIAAAAASUVORK5CYII="
/>
</div>
`;

View File

@@ -2,7 +2,6 @@
exports[`Toast renders 1`] = `
<button
aria-describedby="radix-:r5:"
aria-labelledby="radix-:r4:"
class="overlay animate toast"
data-state="open"

View File

@@ -0,0 +1,21 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`Toast > renders 1`] = `
<button
aria-labelledby="radix-:r4:"
class="overlay animate toast"
data-state="open"
id="radix-:r3:"
role="dialog"
style="pointer-events: auto;"
tabindex="-1"
type="button"
>
<h3
class="_typography_yh5dq_162 _font-body-sm-semibold_yh5dq_45"
id="radix-:r4:"
>
Hello world!
</h3>
</button>
`;

View File

@@ -16,11 +16,10 @@ limitations under the License.
import posthog, { CaptureOptions, PostHog, Properties } from "posthog-js";
import { logger } from "matrix-js-sdk/src/logger";
import { MatrixClient } from "matrix-js-sdk";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { Buffer } from "buffer";
import { widget } from "../widget";
import { getSetting, setSetting, getSettingKey } from "../settings/useSetting";
import {
CallEndedTracker,
CallStartedTracker,
@@ -35,7 +34,7 @@ import {
} from "./PosthogEvents";
import { Config } from "../config/Config";
import { getUrlParams } from "../UrlParams";
import { localStorageBus } from "../useLocalStorage";
import { optInAnalytics } from "../settings/settings";
/* Posthog analytics tracking.
*
@@ -131,7 +130,7 @@ export class PosthogAnalytics {
const { analyticsID } = getUrlParams();
// if the embedding platform (element web) already got approval to communicating with posthog
// element call can also send events to posthog
setSetting("opt-in-analytics", Boolean(analyticsID));
optInAnalytics.setValue(Boolean(analyticsID));
}
this.posthog.init(posthogConfig.project_api_key, {
@@ -145,15 +144,13 @@ export class PosthogAnalytics {
advanced_disable_decide: true,
});
this.enabled = true;
} else {
} else if (import.meta.env.MODE !== "test") {
logger.info(
"Posthog is not enabled because there is no api key or no host given in the config",
);
this.enabled = false;
}
this.startListeningToSettingsChanges();
const optInAnalytics = getSetting("opt-in-analytics", false);
this.updateAnonymityAndIdentifyUser(optInAnalytics);
this.startListeningToSettingsChanges(); // Triggers maybeIdentifyUser
}
private sanitizeProperties = (
@@ -336,8 +333,7 @@ export class PosthogAnalytics {
}
public onLoginStatusChanged(): void {
const optInAnalytics = getSetting("opt-in-analytics", false);
this.updateAnonymityAndIdentifyUser(optInAnalytics);
this.maybeIdentifyUser();
}
private updateSuperProperties(): void {
@@ -360,20 +356,12 @@ export class PosthogAnalytics {
return this.eventSignup.getSignupEndTime() > new Date(0);
}
private async updateAnonymityAndIdentifyUser(
pseudonymousOptIn: boolean,
): Promise<void> {
// Update this.anonymity based on the user's analytics opt-in settings
const anonymity = pseudonymousOptIn
? Anonymity.Pseudonymous
: Anonymity.Disabled;
this.setAnonymity(anonymity);
private async maybeIdentifyUser(): Promise<void> {
// We may not yet have a Matrix client at this point, if not, bail. This should get
// triggered again by onLoginStatusChanged once we do have a client.
if (!window.matrixclient) return;
if (anonymity === Anonymity.Pseudonymous) {
if (this.anonymity === Anonymity.Pseudonymous) {
this.setRegistrationType(
window.matrixclient.isGuest() || window.passwordlessUser
? RegistrationType.Guest
@@ -389,7 +377,7 @@ export class PosthogAnalytics {
}
}
if (anonymity !== Anonymity.Disabled) {
if (this.anonymity !== Anonymity.Disabled) {
this.updateSuperProperties();
}
}
@@ -419,8 +407,9 @@ export class PosthogAnalytics {
// * When the user changes their preferences on this device
// Note that for new accounts, pseudonymousAnalyticsOptIn won't be set, so updateAnonymityFromSettings
// won't be called (i.e. this.anonymity will be left as the default, until the setting changes)
localStorageBus.on(getSettingKey("opt-in-analytics"), (optInAnalytics) => {
this.updateAnonymityAndIdentifyUser(optInAnalytics);
optInAnalytics.value.subscribe((optIn) => {
this.setAnonymity(optIn ? Anonymity.Pseudonymous : Anonymity.Disabled);
this.maybeIdentifyUser();
});
}

View File

@@ -72,7 +72,7 @@ export class PosthogSpanProcessor implements SpanProcessor {
try {
return JSON.parse(data);
} catch (e) {
logger.warn("Invalid prev call data", data);
logger.warn("Invalid prev call data", data, "error:", e);
return null;
}
}

View File

@@ -1,44 +0,0 @@
/*
Copyright 2023 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Gets the index of the last element in the array to satsify the given
* predicate.
*/
// TODO: remove this once TypeScript recognizes the existence of
// Array.prototype.findLastIndex
export function findLastIndex<T>(
array: T[],
predicate: (item: T, index: number) => boolean,
): number | null {
for (let i = array.length - 1; i >= 0; i--) {
if (predicate(array[i], i)) return i;
}
return null;
}
/**
* Counts the number of elements in an array that satsify the given predicate.
*/
export const count = <T>(
array: T[],
predicate: (item: T, index: number) => boolean,
): number =>
array.reduce(
(acc, item, index) => (predicate(item, index) ? acc + 1 : acc),
0,
);

View File

@@ -17,11 +17,11 @@ limitations under the License.
import { FC, FormEvent, useCallback, useRef, useState } from "react";
import { useHistory, useLocation, Link } from "react-router-dom";
import { Trans, useTranslation } from "react-i18next";
import { Button } from "@vector-im/compound-web";
import Logo from "../icons/LogoLarge.svg?react";
import { useClient } from "../ClientContext";
import { FieldRow, InputField, ErrorMessage } from "../input/Input";
import { Button } from "../button";
import styles from "./LoginPage.module.css";
import { useInteractiveLogin } from "./useInteractiveLogin";
import { usePageTitle } from "../usePageTitle";
@@ -32,8 +32,8 @@ export const LoginPage: FC = () => {
const { t } = useTranslation();
usePageTitle(t("login_title"));
const { setClient } = useClient();
const login = useInteractiveLogin();
const { client, setClient } = useClient();
const login = useInteractiveLogin(client);
const homeserver = Config.defaultHomeserverUrl(); // TODO: Make this configurable
const usernameRef = useRef<HTMLInputElement>(null);
const passwordRef = useRef<HTMLInputElement>(null);

View File

@@ -28,9 +28,9 @@ import { captureException } from "@sentry/react";
import { sleep } from "matrix-js-sdk/src/utils";
import { Trans, useTranslation } from "react-i18next";
import { logger } from "matrix-js-sdk/src/logger";
import { Button } from "@vector-im/compound-web";
import { FieldRow, InputField, ErrorMessage } from "../input/Input";
import { Button } from "../button";
import { useClientLegacy } from "../ClientContext";
import { useInteractiveRegistration } from "./useInteractiveRegistration";
import styles from "./LoginPage.module.css";
@@ -56,7 +56,7 @@ export const RegisterPage: FC = () => {
const [error, setError] = useState<Error>();
const [password, setPassword] = useState("");
const [passwordConfirmation, setPasswordConfirmation] = useState("");
const { recaptchaKey, register } = useInteractiveRegistration();
const { recaptchaKey, register } = useInteractiveRegistration(client);
const { execute, reset, recaptchaId } = useRecaptcha(recaptchaKey);
const onSubmitRegisterForm = useCallback(

View File

@@ -22,10 +22,17 @@ import {
MatrixClient,
} from "matrix-js-sdk/src/matrix";
import { initClient } from "../matrix-utils";
import { initClient } from "../utils/matrix";
import { Session } from "../ClientContext";
export function useInteractiveLogin(): (
/**
* This provides the login method to login using user credentials.
* @param oldClient If there is an already authenticated client it should be passed to this hook
* this allows the interactive login to sign out the client before logging in.
* @returns A async method that can be called/awaited to log in with the provided credentials.
*/
export function useInteractiveLogin(
oldClient?: MatrixClient,
): (
homeserver: string,
username: string,
password: string,
@@ -36,47 +43,52 @@ export function useInteractiveLogin(): (
username: string,
password: string,
) => Promise<[MatrixClient, Session]>
>(async (homeserver: string, username: string, password: string) => {
const authClient = createClient({ baseUrl: homeserver });
>(
async (homeserver: string, username: string, password: string) => {
const authClient = createClient({ baseUrl: homeserver });
const interactiveAuth = new InteractiveAuth({
matrixClient: authClient,
doRequest: (): Promise<LoginResponse> =>
authClient.login("m.login.password", {
identifier: {
type: "m.id.user",
user: username,
},
password,
}),
stateUpdated: (): void => {},
requestEmailToken: (): Promise<{ sid: string }> => {
return Promise.resolve({ sid: "" });
},
});
const interactiveAuth = new InteractiveAuth({
matrixClient: authClient,
doRequest: (): Promise<LoginResponse> =>
authClient.login("m.login.password", {
identifier: {
type: "m.id.user",
user: username,
},
password,
}),
stateUpdated: (): void => {},
requestEmailToken: (): Promise<{ sid: string }> => {
return Promise.resolve({ sid: "" });
},
});
// XXX: This claims to return an IAuthData which contains none of these
// things - the js-sdk types may be wrong?
/* eslint-disable camelcase,@typescript-eslint/no-explicit-any */
const { user_id, access_token, device_id } =
(await interactiveAuth.attemptAuth()) as any;
const session = {
user_id,
access_token,
device_id,
passwordlessUser: false,
};
// XXX: This claims to return an IAuthData which contains none of these
// things - the js-sdk types may be wrong?
/* eslint-disable camelcase,@typescript-eslint/no-explicit-any */
const { user_id, access_token, device_id } =
(await interactiveAuth.attemptAuth()) as any;
const session = {
user_id,
access_token,
device_id,
passwordlessUser: false,
};
const client = await initClient(
{
baseUrl: homeserver,
accessToken: access_token,
userId: user_id,
deviceId: device_id,
},
false,
);
/* eslint-enable camelcase */
return [client, session];
}, []);
// To not confuse the rust crypto sessions we need to logout the old client before initializing the new one.
await oldClient?.logout(true);
const client = await initClient(
{
baseUrl: homeserver,
accessToken: access_token,
userId: user_id,
deviceId: device_id,
},
false,
);
/* eslint-enable camelcase */
return [client, session];
},
[oldClient],
);
}

View File

@@ -22,12 +22,14 @@ import {
RegisterResponse,
} from "matrix-js-sdk/src/matrix";
import { initClient } from "../matrix-utils";
import { initClient } from "../utils/matrix";
import { Session } from "../ClientContext";
import { Config } from "../config/Config";
import { widget } from "../widget";
export const useInteractiveRegistration = (): {
export const useInteractiveRegistration = (
oldClient?: MatrixClient,
): {
privacyPolicyUrl?: string;
recaptchaKey?: string;
register: (
@@ -105,7 +107,7 @@ export const useInteractiveRegistration = (): {
/* eslint-disable camelcase,@typescript-eslint/no-explicit-any */
const { user_id, access_token, device_id } =
(await interactiveAuth.attemptAuth()) as any;
await oldClient?.logout(true);
const client = await initClient(
{
baseUrl: Config.defaultHomeserverUrl()!,
@@ -136,7 +138,7 @@ export const useInteractiveRegistration = (): {
return [client, session];
},
[],
[oldClient],
);
return { privacyPolicyUrl, recaptchaKey, register };

View File

@@ -20,7 +20,6 @@ import { useTranslation } from "react-i18next";
import { logger } from "matrix-js-sdk/src/logger";
import { translatedError } from "../TranslatedError";
declare global {
interface Window {
mxOnRecaptchaLoaded: () => void;

View File

@@ -1,5 +1,5 @@
/*
Copyright 2021 New Vector Ltd
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,240 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
.button,
.toolbarButton,
.toolbarButtonSecondary,
.iconButton,
.iconCopyButton,
.secondary,
.secondaryHangup,
.copyButton,
.dropdownButton {
position: relative;
display: flex;
justify-content: center;
align-items: center;
background-color: transparent;
padding: 0;
border: none;
cursor: pointer;
text-decoration: none;
box-sizing: border-box;
}
.secondary,
.secondaryHangup,
.button,
.copyButton {
padding: 8px 20px;
border-radius: 8px;
font-size: var(--font-size-body);
font-weight: 600;
}
.button {
color: var(--stopgap-color-on-solid-accent);
background-color: var(--cpd-color-text-action-accent);
}
.button:focus-visible,
.toolbarButton:focus-visible,
.toolbarButtonSecondary:focus-visible,
.iconButton:focus-visible,
.iconCopyButton:focus-visible,
.secondary:focus-visible,
.secondaryHangup:focus-visible,
.copyButton:focus-visible {
outline: auto;
}
.toolbarButton:disabled {
background-color: var(--cpd-color-bg-action-primary-disabled);
box-shadow: none;
}
.toolbarButton,
.toolbarButtonSecondary {
width: 50px;
height: 50px;
border-radius: 50px;
background-color: var(--cpd-color-bg-canvas-default);
color: var(--cpd-color-icon-primary);
border: 1px solid var(--cpd-color-gray-400);
box-shadow: var(--subtle-drop-shadow);
}
.toolbarButton.on,
.toolbarButton.off {
background-color: var(--cpd-color-bg-action-primary-rest);
color: var(--cpd-color-icon-on-solid-primary);
}
.toolbarButtonSecondary.on {
background-color: var(--cpd-color-text-success-primary);
}
.toolbarButton:active,
.toolbarButtonSecondary:active {
background-color: var(--cpd-color-bg-subtle-primary);
border: none;
box-shadow: none;
}
.toolbarButton.on:active,
.toolbarButton.off:active {
background-color: var(--cpd-color-bg-action-primary-pressed);
}
.iconButton:not(.stroke) svg * {
fill: var(--cpd-color-bg-action-primary-rest);
}
.iconButton:not(.stroke):tertiary svg * {
fill: var(--cpd-color-icon-accent-tertiary);
}
.iconButton.on:not(.stroke) svg * {
fill: var(--cpd-color-icon-accent-tertiary);
}
.iconButton.on.stroke svg * {
stroke: var(--cpd-color-icon-accent-tertiary);
}
.hangupButton {
background-color: var(--cpd-color-bg-critical-primary);
border-color: var(--cpd-color-border-critical-subtle);
.endCall > svg {
color: var(--stopgap-color-on-solid-accent);
}
.hangupButton:active {
background-color: var(--cpd-color-bg-critical-pressed);
}
.secondary,
.copyButton {
color: var(--cpd-color-text-action-accent);
border: 2px solid var(--cpd-color-text-action-accent);
background-color: transparent;
}
.secondaryHangup {
color: var(--cpd-color-text-critical-primary);
border: 2px solid var(--cpd-color-border-critical-primary);
background-color: transparent;
}
.copyButton.secondaryCopy {
color: var(--cpd-color-text-primary);
border-color: var(--cpd-color-border-interactive-primary);
}
.copyButton {
width: 100%;
height: 40px;
transition:
border-color 250ms,
background-color 250ms;
}
.copyButton span {
font-weight: 600;
font-size: var(--font-size-body);
margin-right: 10px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.copyButton svg {
flex-shrink: 0;
}
.copyButton:not(.on) svg * {
fill: var(--cpd-color-icon-accent-tertiary);
}
.copyButton.on {
border-color: transparent;
background-color: var(--cpd-color-text-action-accent);
color: white;
}
.copyButton.on svg * {
stroke: white;
}
.copyButton.secondaryCopy:not(.on) svg * {
fill: var(--cpd-color-bg-action-primary-rest);
}
.iconCopyButton svg * {
fill: var(--cpd-color-icon-secondary);
}
.iconCopyButton.on svg *,
.iconCopyButton.on:hover svg * {
fill: transparent;
stroke: var(--cpd-color-text-action-accent);
}
.dropdownButton {
color: var(--cpd-color-text-primary);
padding: 2px 8px;
border-radius: 8px;
}
.dropdownButton:active,
.dropdownButton.on {
background-color: var(--cpd-color-bg-action-secondary-pressed);
}
.dropdownButton svg {
margin-left: 8px;
}
.dropdownButton svg * {
fill: var(--cpd-color-icon-primary);
}
.lg {
height: 40px;
}
.linkButton {
background-color: transparent;
border: none;
color: var(--cpd-color-text-action-accent);
cursor: pointer;
}
@media (hover: hover) {
.toolbarButton:hover,
.toolbarButtonSecondary:hover {
background-color: var(--cpd-color-bg-subtle-primary);
border: none;
box-shadow: none;
}
.toolbarButton.on:hover,
.toolbarButton.off:hover {
background-color: var(--cpd-color-bg-action-primary-hovered);
}
.iconButton:not(.stroke):hover svg * {
fill: var(--cpd-color-icon-accent-tertiary);
}
.hangupButton:hover {
background-color: var(--cpd-color-bg-critical-hovered);
}
.iconCopyButton:hover svg * {
fill: var(--cpd-color-icon-accent-tertiary);
}
.dropdownButton:hover {
background-color: var(--cpd-color-bg-action-secondary-hovered);
}
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 - 2023 New Vector Ltd
Copyright 2022-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -13,133 +13,27 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { FC, forwardRef } from "react";
import { PressEvent } from "@react-types/shared";
import { ComponentPropsWithoutRef, FC } from "react";
import classNames from "classnames";
import { useButton } from "@react-aria/button";
import { mergeProps, useObjectRef } from "@react-aria/utils";
import { useTranslation } from "react-i18next";
import { Tooltip } from "@vector-im/compound-web";
import MicOnSolidIcon from "@vector-im/compound-design-tokens/icons/mic-on-solid.svg?react";
import MicOffSolidIcon from "@vector-im/compound-design-tokens/icons/mic-off-solid.svg?react";
import VideoCallSolidIcon from "@vector-im/compound-design-tokens/icons/video-call-solid.svg?react";
import VideoCallOffSolidIcon from "@vector-im/compound-design-tokens/icons/video-call-off-solid.svg?react";
import EndCallIcon from "@vector-im/compound-design-tokens/icons/end-call.svg?react";
import ShareScreenSolidIcon from "@vector-im/compound-design-tokens/icons/share-screen-solid.svg?react";
import SettingsSolidIcon from "@vector-im/compound-design-tokens/icons/settings-solid.svg?react";
import ChevronDownIcon from "@vector-im/compound-design-tokens/icons/chevron-down.svg?react";
import { Button as CpdButton, Tooltip } from "@vector-im/compound-web";
import {
MicOnSolidIcon,
MicOffSolidIcon,
VideoCallSolidIcon,
VideoCallOffSolidIcon,
EndCallIcon,
ShareScreenSolidIcon,
SettingsSolidIcon,
} from "@vector-im/compound-design-tokens/assets/web/icons";
import styles from "./Button.module.css";
export type ButtonVariant =
| "default"
| "toolbar"
| "toolbarSecondary"
| "icon"
| "secondary"
| "copy"
| "secondaryCopy"
| "iconCopy"
| "secondaryHangup"
| "dropdown"
| "link";
export const variantToClassName = {
default: [styles.button],
toolbar: [styles.toolbarButton],
toolbarSecondary: [styles.toolbarButtonSecondary],
icon: [styles.iconButton],
secondary: [styles.secondary],
copy: [styles.copyButton],
secondaryCopy: [styles.secondaryCopy, styles.copyButton],
iconCopy: [styles.iconCopyButton],
secondaryHangup: [styles.secondaryHangup],
dropdown: [styles.dropdownButton],
link: [styles.linkButton],
};
export type ButtonSize = "lg";
export const sizeToClassName: { lg: string[] } = {
lg: [styles.lg],
};
interface Props {
variant: ButtonVariant;
size: ButtonSize;
on: () => void;
off: () => void;
iconStyle: string;
className: string;
children: Element[];
onPress: (e: PressEvent) => void;
onPressStart: (e: PressEvent) => void;
disabled: boolean;
// TODO: add all props for <Button>
[index: string]: unknown;
interface MicButtonProps extends ComponentPropsWithoutRef<"button"> {
muted: boolean;
}
export const Button = forwardRef<HTMLButtonElement, Props>(
(
{
variant = "default",
size,
on,
off,
iconStyle,
className,
children,
onPress,
onPressStart,
...rest
},
ref,
) => {
const buttonRef = useObjectRef<HTMLButtonElement>(ref);
const { buttonProps } = useButton(
{ onPress, onPressStart, ...rest },
buttonRef,
);
// TODO: react-aria's useButton hook prevents form submission via keyboard
// Remove the hack below after this is merged https://github.com/adobe/react-spectrum/pull/904
let filteredButtonProps = buttonProps;
if (rest.type === "submit" && !rest.onPress) {
const { ...filtered } = buttonProps;
filteredButtonProps = filtered;
}
return (
<button
className={classNames(
variantToClassName[variant],
sizeToClassName[size],
styles[iconStyle],
className,
{
[styles.on]: on,
[styles.off]: off,
},
)}
{...mergeProps(rest, filteredButtonProps)}
ref={buttonRef}
>
<>
{children}
{variant === "dropdown" && <ChevronDownIcon />}
</>
</button>
);
},
);
Button.displayName = "Button";
export const MicButton: FC<{
muted: boolean;
// TODO: add all props for <Button>
[index: string]: unknown;
}> = ({ muted, ...rest }) => {
export const MicButton: FC<MicButtonProps> = ({ muted, ...props }) => {
const { t } = useTranslation();
const Icon = muted ? MicOffSolidIcon : MicOnSolidIcon;
const label = muted
@@ -148,18 +42,21 @@ export const MicButton: FC<{
return (
<Tooltip label={label}>
<Button variant="toolbar" {...rest} on={muted}>
<Icon aria-label={label} />
</Button>
<CpdButton
iconOnly
Icon={Icon}
kind={muted ? "primary" : "secondary"}
{...props}
/>
</Tooltip>
);
};
export const VideoButton: FC<{
interface VideoButtonProps extends ComponentPropsWithoutRef<"button"> {
muted: boolean;
// TODO: add all props for <Button>
[index: string]: unknown;
}> = ({ muted, ...rest }) => {
}
export const VideoButton: FC<VideoButtonProps> = ({ muted, ...props }) => {
const { t } = useTranslation();
const Icon = muted ? VideoCallOffSolidIcon : VideoCallSolidIcon;
const label = muted
@@ -168,19 +65,24 @@ export const VideoButton: FC<{
return (
<Tooltip label={label}>
<Button variant="toolbar" {...rest} on={muted}>
<Icon aria-label={label} />
</Button>
<CpdButton
iconOnly
Icon={Icon}
kind={muted ? "primary" : "secondary"}
{...props}
/>
</Tooltip>
);
};
export const ScreenshareButton: FC<{
interface ShareScreenButtonProps extends ComponentPropsWithoutRef<"button"> {
enabled: boolean;
className?: string;
// TODO: add all props for <Button>
[index: string]: unknown;
}> = ({ enabled, className, ...rest }) => {
}
export const ShareScreenButton: FC<ShareScreenButtonProps> = ({
enabled,
...props
}) => {
const { t } = useTranslation();
const label = enabled
? t("stop_screenshare_button_label")
@@ -188,45 +90,48 @@ export const ScreenshareButton: FC<{
return (
<Tooltip label={label}>
<Button variant="toolbar" {...rest} on={enabled}>
<ShareScreenSolidIcon aria-label={label} />
</Button>
<CpdButton
iconOnly
Icon={ShareScreenSolidIcon}
kind={enabled ? "primary" : "secondary"}
{...props}
/>
</Tooltip>
);
};
export const HangupButton: FC<{
className?: string;
// TODO: add all props for <Button>
[index: string]: unknown;
}> = ({ className, ...rest }) => {
export const EndCallButton: FC<ComponentPropsWithoutRef<"button">> = ({
className,
...props
}) => {
const { t } = useTranslation();
return (
<Tooltip label={t("hangup_button_label")}>
<Button
variant="toolbar"
className={classNames(styles.hangupButton, className)}
{...rest}
>
<EndCallIcon aria-label={t("hangup_button_label")} />
</Button>
<CpdButton
className={classNames(className, styles.endCall)}
iconOnly
Icon={EndCallIcon}
destructive
{...props}
/>
</Tooltip>
);
};
export const SettingsButton: FC<{
className?: string;
// TODO: add all props for <Button>
[index: string]: unknown;
}> = ({ className, ...rest }) => {
export const SettingsButton: FC<ComponentPropsWithoutRef<"button">> = (
props,
) => {
const { t } = useTranslation();
return (
<Tooltip label={t("common.settings")}>
<Button variant="toolbar" {...rest}>
<SettingsSolidIcon aria-label={t("common.settings")} />
</Button>
<CpdButton
iconOnly
Icon={SettingsSolidIcon}
kind="secondary"
{...props}
/>
</Tooltip>
);
};

View File

@@ -1,69 +0,0 @@
/*
Copyright 2022 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { useTranslation } from "react-i18next";
import useClipboard from "react-use-clipboard";
import { FC } from "react";
import CheckIcon from "../icons/Check.svg?react";
import CopyIcon from "../icons/Copy.svg?react";
import { Button, ButtonVariant } from "./Button";
interface Props {
value: string;
children?: JSX.Element | string;
className?: string;
variant?: ButtonVariant;
copiedMessage?: string;
}
export const CopyButton: FC<Props> = ({
value,
children,
className,
variant,
copiedMessage,
...rest
}) => {
const { t } = useTranslation();
const [isCopied, setCopied] = useClipboard(value, { successDuration: 3000 });
return (
<Button
{...rest}
variant={variant === "icon" ? "iconCopy" : variant || "copy"}
on={isCopied}
className={className}
onPress={setCopied}
iconStyle={isCopied ? "stroke" : "fill"}
aria-label={t("action.copy")}
>
{isCopied ? (
<>
{variant !== "icon" && (
<span>{copiedMessage || t("common.copied")}</span>
)}
<CheckIcon />
</>
) : (
<>
{variant !== "icon" && <span>{children || value}</span>}
<CopyIcon />
</>
)}
</Button>
);
};

View File

@@ -17,7 +17,7 @@ limitations under the License.
import { ComponentPropsWithoutRef, FC } from "react";
import { Button } from "@vector-im/compound-web";
import { useTranslation } from "react-i18next";
import UserAddIcon from "@vector-im/compound-design-tokens/icons/user-add.svg?react";
import { UserAddIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
export const InviteButton: FC<
Omit<ComponentPropsWithoutRef<"button">, "children">

61
src/button/Link.tsx Normal file
View File

@@ -0,0 +1,61 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {
ComponentPropsWithoutRef,
forwardRef,
MouseEvent,
useCallback,
useMemo,
} from "react";
import { Link as CpdLink } from "@vector-im/compound-web";
import { useHistory } from "react-router-dom";
import { createPath, LocationDescriptor, Path } from "history";
export function useLink(
to: LocationDescriptor,
): [Path, (e: MouseEvent) => void] {
const history = useHistory();
const path = useMemo(
() => (typeof to === "string" ? to : createPath(to)),
[to],
);
const onClick = useCallback(
(e: MouseEvent) => {
e.preventDefault();
history.push(to);
},
[history, to],
);
return [path, onClick];
}
type Props = Omit<
ComponentPropsWithoutRef<typeof CpdLink>,
"href" | "onClick"
> & { to: LocationDescriptor };
/**
* A version of Compound's link component that integrates with our router setup.
*/
export const Link = forwardRef<HTMLAnchorElement, Props>(function Link(
{ to, ...props },
ref,
) {
const [path, onClick] = useLink(to);
return <CpdLink ref={ref} {...props} href={path} onClick={onClick} />;
});

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,45 +14,24 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { FC, HTMLAttributes } from "react";
import { Link } from "react-router-dom";
import classNames from "classnames";
import * as H from "history";
import { ComponentPropsWithoutRef, forwardRef } from "react";
import { Button } from "@vector-im/compound-web";
import { LocationDescriptor } from "history";
import {
variantToClassName,
sizeToClassName,
ButtonVariant,
ButtonSize,
} from "./Button";
import { useLink } from "./Link";
interface Props extends HTMLAttributes<HTMLAnchorElement> {
children: JSX.Element | string;
to: H.LocationDescriptor | ((location: H.Location) => H.LocationDescriptor);
size?: ButtonSize;
variant?: ButtonVariant;
className?: string;
}
type Props = Omit<
ComponentPropsWithoutRef<typeof Button<"a">>,
"as" | "href"
> & { to: LocationDescriptor };
export const LinkButton: FC<Props> = ({
children,
to,
size,
variant,
className,
...rest
}) => {
return (
<Link
className={classNames(
variantToClassName[variant || "secondary"],
size ? sizeToClassName[size] : [],
className,
)}
to={to}
{...rest}
>
{children}
</Link>
);
};
/**
* A version of Compound's button component that acts as a link and integrates
* with our router setup.
*/
export const LinkButton = forwardRef<HTMLAnchorElement, Props>(
function LinkButton({ to, ...props }, ref) {
const [path, onClick] = useLink(to);
return <Button as="a" ref={ref} {...props} href={path} onClick={onClick} />;
},
);

View File

@@ -15,5 +15,4 @@ limitations under the License.
*/
export * from "./Button";
export * from "./CopyButton";
export * from "./LinkButton";

View File

@@ -44,6 +44,18 @@ export class Config {
return Config.internalInstance.initPromise;
}
/**
* This is a alternative initializer that does not load anything
* from a hosted config file but instead just initializes the conifg using the
* default config.
*
* It is supposed to only be used in tests. (It is executed in `vite.setup.js`)
*/
public static initDefault(): void {
Config.internalInstance = new Config();
Config.internalInstance.config = { ...DEFAULT_CONFIG };
}
// Convenience accessors
public static defaultHomeserverUrl(): string | undefined {
return (

View File

@@ -65,11 +65,21 @@ export interface ConfigOptions {
};
/**
* Allow to join a group calls without audio and video.
* TEMPORARY: Is a feature that's not proved and experimental
* TEMPORARY experimental features.
*/
features?: {
feature_group_calls_without_video_and_audio: boolean;
/**
* Allow to join group calls without audio and video.
*/
feature_group_calls_without_video_and_audio?: boolean;
/**
* Send device-specific call session membership state events instead of
* legacy user-specific call membership state events.
* This setting has no effect when the user joins an active call with
* legacy state events. For compatibility, Element Call will always join
* active legacy calls with legacy state events.
*/
feature_use_device_session_member_events?: boolean;
};
/**

39
src/controls.ts Normal file
View File

@@ -0,0 +1,39 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { Subject } from "rxjs";
export interface Controls {
canEnterPip: () => boolean;
enablePip: () => void;
disablePip: () => void;
}
export const setPipEnabled = new Subject<boolean>();
window.controls = {
canEnterPip(): boolean {
return setPipEnabled.observed;
},
enablePip(): void {
if (!setPipEnabled.observed) throw new Error("No call is running");
setPipEnabled.next(true);
},
disablePip(): void {
if (!setPipEnabled.observed) throw new Error("No call is running");
setPipEnabled.next(false);
},
};

150
src/grid/CallLayout.ts Normal file
View File

@@ -0,0 +1,150 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { BehaviorSubject, Observable } from "rxjs";
import { ComponentType } from "react";
import { MediaViewModel, UserMediaViewModel } from "../state/MediaViewModel";
import { LayoutProps } from "./Grid";
export interface Bounds {
width: number;
height: number;
}
export interface Alignment {
inline: "start" | "end";
block: "start" | "end";
}
export const defaultSpotlightAlignment: Alignment = {
inline: "end",
block: "end",
};
export const defaultPipAlignment: Alignment = { inline: "end", block: "start" };
export interface CallLayoutInputs {
/**
* The minimum bounds of the layout area.
*/
minBounds: Observable<Bounds>;
/**
* The alignment of the floating spotlight tile, if present.
*/
spotlightAlignment: BehaviorSubject<Alignment>;
/**
* The alignment of the small picture-in-picture tile, if present.
*/
pipAlignment: BehaviorSubject<Alignment>;
}
export interface GridTileModel {
type: "grid";
vm: UserMediaViewModel;
}
export interface SpotlightTileModel {
type: "spotlight";
vms: MediaViewModel[];
maximised: boolean;
}
export type TileModel = GridTileModel | SpotlightTileModel;
export interface CallLayoutOutputs<Model> {
/**
* Whether the scrolling layer of the layout should appear on top.
*/
scrollingOnTop: boolean;
/**
* The visually fixed (non-scrolling) layer of the layout.
*/
fixed: ComponentType<LayoutProps<Model, TileModel, HTMLDivElement>>;
/**
* The layer of the layout that can overflow and be scrolled.
*/
scrolling: ComponentType<LayoutProps<Model, TileModel, HTMLDivElement>>;
}
/**
* A layout system for media tiles.
*/
export type CallLayout<Model> = (
inputs: CallLayoutInputs,
) => CallLayoutOutputs<Model>;
export interface GridArrangement {
tileWidth: number;
tileHeight: number;
gap: number;
columns: number;
}
const tileMaxAspectRatio = 17 / 9;
const tileMinAspectRatio = 4 / 3;
/**
* Determine the ideal arrangement of tiles into a grid of a particular size.
*/
export function arrangeTiles(
width: number,
minHeight: number,
tileCount: number,
): GridArrangement {
// The goal here is to determine the grid size and padding that maximizes
// use of screen space for n tiles without making those tiles too small or
// too cropped (having an extreme aspect ratio)
const gap = width < 800 ? 16 : 20;
const area = width * minHeight;
// Magic numbers that make tiles scale up nicely as the window gets larger
const tileArea = Math.pow(Math.sqrt(area) / 8 + 125, 2);
const tilesPerPage = Math.min(tileCount, area / tileArea);
let columns = Math.min(
// Don't create more columns than we have items for
tilesPerPage,
// The ideal number of columns is given by a packing of equally-sized
// squares into a grid.
// width / column = height / row.
// columns * rows = number of squares.
// ∴ columns = sqrt(width / height * number of squares).
// Except we actually want 16:9-ish tiles rather than squares, so we
// divide the width-to-height ratio by the target aspect ratio.
Math.round(
Math.sqrt((width / minHeight / tileMinAspectRatio) * tilesPerPage),
),
);
let rows = tilesPerPage / columns;
// If all the tiles could fit on one page, we want to ensure that they do by
// not leaving fractional rows hanging off the bottom
if (tilesPerPage === tileCount) {
rows = Math.ceil(rows);
// We may now be able to fit the tiles into fewer columns
columns = Math.ceil(tileCount / rows);
}
let tileWidth = (width - (columns + 1) * gap) / columns;
let tileHeight = (minHeight - (rows - 1) * gap) / rows;
// Impose a minimum and maximum aspect ratio on the tiles
const tileAspectRatio = tileWidth / tileHeight;
if (tileAspectRatio > tileMaxAspectRatio)
tileWidth = tileHeight * tileMaxAspectRatio;
else if (tileAspectRatio < tileMinAspectRatio)
tileHeight = tileWidth / tileMinAspectRatio;
return { tileWidth, tileHeight, gap, columns };
}

View File

@@ -1,11 +1,11 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
.popoverMenuTrigger {
position: relative;
display: inline-block;
.grid {
contain: layout style;
}
.slot {
contain: strict;
}

514
src/grid/Grid.tsx Normal file
View File

@@ -0,0 +1,514 @@
/*
Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import {
SpringRef,
TransitionFn,
animated,
useTransition,
} from "@react-spring/web";
import { EventTypes, Handler, useScroll } from "@use-gesture/react";
import {
CSSProperties,
ComponentProps,
ComponentType,
Dispatch,
FC,
LegacyRef,
ReactNode,
SetStateAction,
createContext,
forwardRef,
memo,
useContext,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import useMeasure from "react-use-measure";
import classNames from "classnames";
import styles from "./Grid.module.css";
import { useMergedRefs } from "../useMergedRefs";
import { TileWrapper } from "./TileWrapper";
import { usePrefersReducedMotion } from "../usePrefersReducedMotion";
import { useInitial } from "../useInitial";
interface Rect {
x: number;
y: number;
width: number;
height: number;
}
interface Tile<Model> {
id: string;
model: Model;
onDrag: DragCallback | undefined;
}
type PlacedTile<Model> = Tile<Model> & Rect;
interface TileSpring {
opacity: number;
scale: number;
zIndex: number;
x: number;
y: number;
width: number;
height: number;
}
interface TileSpringUpdate extends Partial<TileSpring> {
from?: Partial<TileSpring>;
reset?: boolean;
immediate?: boolean | ((key: string) => boolean);
delay?: (key: string) => number;
}
interface DragState {
tileId: string;
tileX: number;
tileY: number;
cursorX: number;
cursorY: number;
}
interface SlotProps<Model> extends Omit<ComponentProps<"div">, "onDrag"> {
id: string;
model: Model;
onDrag?: DragCallback;
style?: CSSProperties;
className?: string;
}
interface Offset {
x: number;
y: number;
}
/**
* Gets the offset of one element relative to an ancestor.
*/
function offset(element: HTMLElement, relativeTo: Element): Offset {
if (
!(element.offsetParent instanceof HTMLElement) ||
element.offsetParent === relativeTo
) {
return { x: element.offsetLeft, y: element.offsetTop };
} else {
const o = offset(element.offsetParent, relativeTo);
o.x += element.offsetLeft;
o.y += element.offsetTop;
return o;
}
}
interface LayoutContext {
setGeneration: Dispatch<SetStateAction<number | null>>;
}
const LayoutContext = createContext<LayoutContext | null>(null);
/**
* Enables Grid to react to layout changes. You must call this in your Layout
* component or else Grid will not be reactive.
*/
export function useUpdateLayout(): void {
const context = useContext(LayoutContext);
if (context === null)
throw new Error("useUpdateLayout called outside a Grid layout context");
// On every render, tell Grid that the layout may have changed
useEffect(() =>
context.setGeneration((prev) => (prev === null ? 0 : prev + 1)),
);
}
export interface LayoutProps<LayoutModel, TileModel, R extends HTMLElement> {
ref: LegacyRef<R>;
model: LayoutModel;
/**
* Component creating an invisible "slot" for a tile to go in.
*/
Slot: ComponentType<SlotProps<TileModel>>;
}
export interface TileProps<Model, R extends HTMLElement> {
ref: LegacyRef<R>;
className?: string;
style?: ComponentProps<typeof animated.div>["style"];
/**
* The width this tile will have once its animations have settled.
*/
targetWidth: number;
/**
* The height this tile will have once its animations have settled.
*/
targetHeight: number;
model: Model;
}
interface Drag {
/**
* The X coordinate of the dragged tile in grid space.
*/
x: number;
/**
* The Y coordinate of the dragged tile in grid space.
*/
y: number;
/**
* The X coordinate of the dragged tile, as a scalar of the grid width.
*/
xRatio: number;
/**
* The Y coordinate of the dragged tile, as a scalar of the grid height.
*/
yRatio: number;
}
export type DragCallback = (drag: Drag) => void;
interface LayoutMemoProps<LayoutModel, TileModel, R extends HTMLElement>
extends LayoutProps<LayoutModel, TileModel, R> {
Layout: ComponentType<LayoutProps<LayoutModel, TileModel, R>>;
}
interface Props<
LayoutModel,
TileModel,
LayoutRef extends HTMLElement,
TileRef extends HTMLElement,
> {
/**
* Data with which to populate the layout.
*/
model: LayoutModel;
/**
* A component which creates an invisible layout grid of "slots" for tiles to
* go in. The root element must have a data-generation attribute which
* increments whenever the layout may have changed.
*/
Layout: ComponentType<LayoutProps<LayoutModel, TileModel, LayoutRef>>;
/**
* The component used to render each tile in the layout.
*/
Tile: ComponentType<TileProps<TileModel, TileRef>>;
className?: string;
style?: CSSProperties;
}
/**
* A grid of animated tiles.
*/
export function Grid<
LayoutModel,
TileModel,
LayoutRef extends HTMLElement,
TileRef extends HTMLElement,
>({
model,
Layout,
Tile,
className,
style,
}: Props<LayoutModel, TileModel, LayoutRef, TileRef>): ReactNode {
// Overview: This component places tiles by rendering an invisible layout grid
// of "slots" for tiles to go in. Once rendered, it uses the DOM API to get
// the dimensions of each slot, feeding these numbers back into react-spring
// to let the actual tiles move freely atop the layout.
// To tell us when the layout has changed, the layout system increments its
// data-generation attribute, which we watch with a MutationObserver.
const [gridRef1, gridBounds] = useMeasure();
const [gridRoot, gridRef2] = useState<HTMLElement | null>(null);
const gridRef = useMergedRefs<HTMLElement>(gridRef1, gridRef2);
const [layoutRoot, setLayoutRoot] = useState<HTMLElement | null>(null);
const [generation, setGeneration] = useState<number | null>(null);
const tiles = useInitial(() => new Map<string, Tile<TileModel>>());
const prefersReducedMotion = usePrefersReducedMotion();
const Slot: FC<SlotProps<TileModel>> = useMemo(
() =>
function Slot({ id, model, onDrag, style, className, ...props }) {
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => {
tiles.set(id, { id, model, onDrag });
return (): void => void tiles.delete(id);
}, [id, model, onDrag]);
return (
<div
ref={ref}
className={classNames(className, styles.slot)}
data-id={id}
style={style}
{...props}
/>
);
},
[tiles],
);
// We must memoize the Layout component to break the update loop where a
// render of Grid causes a re-render of Layout, which in turn re-renders Grid
const LayoutMemo = useMemo(
() =>
memo(
forwardRef<
LayoutRef,
LayoutMemoProps<LayoutModel, TileModel, LayoutRef>
>(function LayoutMemo({ Layout, ...props }, ref): ReactNode {
return <Layout {...props} ref={ref} />;
}),
),
[],
);
const context: LayoutContext = useMemo(() => ({ setGeneration }), []);
// Combine the tile definitions and slots together to create placed tiles
const placedTiles = useMemo(() => {
const result: PlacedTile<TileModel>[] = [];
if (gridRoot !== null && layoutRoot !== null) {
const slots = layoutRoot.getElementsByClassName(
styles.slot,
) as HTMLCollectionOf<HTMLElement>;
for (const slot of slots) {
const id = slot.getAttribute("data-id")!;
if (slot.offsetWidth > 0 && slot.offsetHeight > 0)
result.push({
...tiles.get(id)!,
...offset(slot, gridRoot),
width: slot.offsetWidth,
height: slot.offsetHeight,
});
}
}
return result;
// The rects may change due to the grid resizing or updating to a new
// generation, but eslint can't statically verify this
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [gridRoot, layoutRoot, tiles, gridBounds, generation]);
// Drag state is stored in a ref rather than component state, because we use
// react-spring's imperative API during gestures to improve responsiveness
const dragState = useRef<DragState | null>(null);
const [tileTransitions, springRef] = useTransition(
placedTiles,
() => ({
key: ({ id }: Tile<TileModel>): string => id,
from: ({
x,
y,
width,
height,
}: PlacedTile<TileModel>): TileSpringUpdate => ({
opacity: 0,
scale: 0,
zIndex: 1,
x,
y,
width,
height,
immediate: prefersReducedMotion,
}),
enter: { opacity: 1, scale: 1, immediate: prefersReducedMotion },
update: ({
id,
x,
y,
width,
height,
}: PlacedTile<TileModel>): TileSpringUpdate | null =>
id === dragState.current?.tileId
? null
: {
x,
y,
width,
height,
immediate: prefersReducedMotion,
},
leave: { opacity: 0, scale: 0, immediate: prefersReducedMotion },
config: { mass: 0.7, tension: 252, friction: 25 },
}),
// react-spring's types are bugged and can't infer the spring type
) as unknown as [
TransitionFn<PlacedTile<TileModel>, TileSpring>,
SpringRef<TileSpring>,
];
// Because we're using react-spring in imperative mode, we're responsible for
// firing animations manually whenever the tiles array updates
useEffect(() => {
springRef.start();
}, [placedTiles, springRef]);
const animateDraggedTile = (
endOfGesture: boolean,
callback: DragCallback,
): void => {
const { tileId, tileX, tileY } = dragState.current!;
const tile = placedTiles.find((t) => t.id === tileId)!;
springRef.current
.find((c) => (c.item as Tile<TileModel>).id === tileId)
?.start(
endOfGesture
? {
scale: 1,
zIndex: 1,
x: tile.x,
y: tile.y,
width: tile.width,
height: tile.height,
immediate:
prefersReducedMotion || ((key): boolean => key === "zIndex"),
// Allow the tile's position to settle before pushing its
// z-index back down
delay: (key): number => (key === "zIndex" ? 500 : 0),
}
: {
scale: 1.1,
zIndex: 2,
x: tileX,
y: tileY,
immediate:
prefersReducedMotion ||
((key): boolean =>
key === "zIndex" || key === "x" || key === "y"),
},
);
if (endOfGesture)
callback({
x: tileX,
y: tileY,
xRatio: tileX / (gridBounds.width - tile.width),
yRatio: tileY / (gridBounds.height - tile.height),
});
};
// Callback for useDrag. We could call useDrag here, but the default
// pattern of spreading {...bind()} across the children to bind the gesture
// ends up breaking memoization and ruining this component's performance.
// Instead, we pass this callback to each tile via a ref, to let them bind the
// gesture using the much more sensible ref-based method.
const onTileDrag = (
tileId: string,
{
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
tap,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
initial: [initialX, initialY],
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
delta: [dx, dy],
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
last,
}: Parameters<Handler<"drag", EventTypes["drag"]>>[0],
): void => {
if (!tap) {
const tileController = springRef.current.find(
(c) => (c.item as Tile<TileModel>).id === tileId,
)!;
const callback = tiles.get(tileController.item.id)!.onDrag;
if (callback != null) {
if (dragState.current === null) {
const tileSpring = tileController.get();
dragState.current = {
tileId,
tileX: tileSpring.x,
tileY: tileSpring.y,
cursorX: initialX - gridBounds.x,
cursorY: initialY - gridBounds.y + scrollOffset.current,
};
}
dragState.current.tileX += dx;
dragState.current.tileY += dy;
dragState.current.cursorX += dx;
dragState.current.cursorY += dy;
animateDraggedTile(last, callback);
if (last) dragState.current = null;
}
}
};
const onTileDragRef = useRef(onTileDrag);
onTileDragRef.current = onTileDrag;
const scrollOffset = useRef(0);
useScroll(
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
({ xy: [, y], delta: [, dy] }) => {
scrollOffset.current = y;
if (dragState.current !== null) {
dragState.current.tileY += dy;
dragState.current.cursorY += dy;
animateDraggedTile(false, tiles.get(dragState.current.tileId)!.onDrag!);
}
},
{ target: gridRoot ?? undefined },
);
return (
<div
ref={gridRef}
className={classNames(className, styles.grid)}
style={style}
>
<LayoutContext.Provider value={context}>
<LayoutMemo
ref={setLayoutRoot}
Layout={Layout}
model={model}
Slot={Slot}
/>
</LayoutContext.Provider>
{tileTransitions((spring, { id, model, onDrag, width, height }) => (
<TileWrapper
key={id}
id={id}
onDrag={onDrag ? onTileDragRef : null}
targetWidth={width}
targetHeight={height}
model={model}
Tile={Tile}
{...spring}
/>
))}
</div>
);
}

View File

@@ -0,0 +1,61 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.fixed,
.scrolling {
block-size: 100%;
}
.scrolling {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
gap: var(--gap);
}
.scrolling > .slot {
width: var(--width);
height: var(--height);
}
.fixed {
position: relative;
}
.fixed > .slot {
position: absolute;
inline-size: 404px;
block-size: 233px;
inset-block: 0;
inset-inline: var(--cpd-space-3x);
}
.fixed > .slot[data-block-alignment="start"] {
inset-block-end: unset;
}
.fixed > .slot[data-block-alignment="end"] {
inset-block-start: unset;
}
.fixed > .slot[data-inline-alignment="start"] {
inset-inline-end: unset;
}
.fixed > .slot[data-inline-alignment="end"] {
inset-inline-start: unset;
}

129
src/grid/GridLayout.tsx Normal file
View File

@@ -0,0 +1,129 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { CSSProperties, forwardRef, useCallback, useMemo } from "react";
import { distinctUntilChanged } from "rxjs";
import { useObservableEagerState } from "observable-hooks";
import { GridLayout as GridLayoutModel } from "../state/CallViewModel";
import styles from "./GridLayout.module.css";
import { useInitial } from "../useInitial";
import {
CallLayout,
GridTileModel,
TileModel,
arrangeTiles,
} from "./CallLayout";
import { DragCallback, useUpdateLayout } from "./Grid";
interface GridCSSProperties extends CSSProperties {
"--gap": string;
"--width": string;
"--height": string;
}
/**
* An implementation of the "grid" layout, in which all participants are shown
* together in a scrolling grid.
*/
export const makeGridLayout: CallLayout<GridLayoutModel> = ({
minBounds,
spotlightAlignment,
}) => ({
scrollingOnTop: false,
// The "fixed" (non-scrolling) part of the layout is where the spotlight tile
// lives
fixed: forwardRef(function GridLayoutFixed({ model, Slot }, ref) {
useUpdateLayout();
const alignment = useObservableEagerState(
useInitial(() =>
spotlightAlignment.pipe(
distinctUntilChanged(
(a1, a2) => a1.block === a2.block && a1.inline === a2.inline,
),
),
),
);
const tileModel: TileModel | undefined = useMemo(
() =>
model.spotlight && {
type: "spotlight",
vms: model.spotlight,
maximised: false,
},
[model.spotlight],
);
const onDragSpotlight: DragCallback = useCallback(
({ xRatio, yRatio }) =>
spotlightAlignment.next({
block: yRatio < 0.5 ? "start" : "end",
inline: xRatio < 0.5 ? "start" : "end",
}),
[],
);
return (
<div ref={ref} className={styles.fixed}>
{tileModel && (
<Slot
className={styles.slot}
id="spotlight"
model={tileModel}
onDrag={onDragSpotlight}
data-block-alignment={alignment.block}
data-inline-alignment={alignment.inline}
/>
)}
</div>
);
}),
// The scrolling part of the layout is where all the grid tiles live
scrolling: forwardRef(function GridLayout({ model, Slot }, ref) {
useUpdateLayout();
const { width, height: minHeight } = useObservableEagerState(minBounds);
const { gap, tileWidth, tileHeight } = useMemo(
() => arrangeTiles(width, minHeight, model.grid.length),
[width, minHeight, model.grid.length],
);
const tileModels: GridTileModel[] = useMemo(
() => model.grid.map((vm) => ({ type: "grid", vm })),
[model.grid],
);
return (
<div
ref={ref}
className={styles.scrolling}
style={
{
width,
"--gap": `${gap}px`,
"--width": `${Math.floor(tileWidth)}px`,
"--height": `${Math.floor(tileHeight)}px`,
} as GridCSSProperties
}
>
{tileModels.map((m) => (
<Slot key={m.vm.id} className={styles.slot} id={m.vm.id} model={m} />
))}
</div>
);
}),
});

View File

@@ -0,0 +1,54 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.layer {
block-size: 100%;
display: grid;
place-items: center;
}
.container {
position: relative;
}
.local {
position: absolute;
inline-size: 180px;
block-size: 135px;
inset: var(--cpd-space-4x);
}
.spotlight {
position: absolute;
inline-size: 404px;
block-size: 233px;
}
.slot[data-block-alignment="start"] {
inset-block-end: unset;
}
.slot[data-block-alignment="end"] {
inset-block-start: unset;
}
.slot[data-inline-alignment="start"] {
inset-inline-end: unset;
}
.slot[data-inline-alignment="end"] {
inset-inline-start: unset;
}

View File

@@ -0,0 +1,88 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { forwardRef, useCallback, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames";
import { OneOnOneLayout as OneOnOneLayoutModel } from "../state/CallViewModel";
import { CallLayout, GridTileModel, arrangeTiles } from "./CallLayout";
import styles from "./OneOnOneLayout.module.css";
import { DragCallback, useUpdateLayout } from "./Grid";
/**
* An implementation of the "one-on-one" layout, in which the remote participant
* is shown at maximum size, overlaid by a small view of the local participant.
*/
export const makeOneOnOneLayout: CallLayout<OneOnOneLayoutModel> = ({
minBounds,
pipAlignment,
}) => ({
scrollingOnTop: false,
fixed: forwardRef(function OneOnOneLayoutFixed(_props, ref) {
useUpdateLayout();
return <div ref={ref} />;
}),
scrolling: forwardRef(function OneOnOneLayoutScrolling({ model, Slot }, ref) {
useUpdateLayout();
const { width, height } = useObservableEagerState(minBounds);
const pipAlignmentValue = useObservableEagerState(pipAlignment);
const { tileWidth, tileHeight } = useMemo(
() => arrangeTiles(width, height, 1),
[width, height],
);
const remoteTileModel: GridTileModel = useMemo(
() => ({ type: "grid", vm: model.remote }),
[model.remote],
);
const localTileModel: GridTileModel = useMemo(
() => ({ type: "grid", vm: model.local }),
[model.local],
);
const onDragLocalTile: DragCallback = useCallback(
({ xRatio, yRatio }) =>
pipAlignment.next({
block: yRatio < 0.5 ? "start" : "end",
inline: xRatio < 0.5 ? "start" : "end",
}),
[],
);
return (
<div ref={ref} className={styles.layer}>
<Slot
id={remoteTileModel.vm.id}
model={remoteTileModel}
className={styles.container}
style={{ width: tileWidth, height: tileHeight }}
>
<Slot
className={classNames(styles.slot, styles.local)}
id={localTileModel.vm.id}
model={localTileModel}
onDrag={onDragLocalTile}
data-block-alignment={pipAlignmentValue.block}
data-inline-alignment={pipAlignmentValue.inline}
/>
</Slot>
</div>
);
}),
});

View File

@@ -0,0 +1,54 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.layer {
block-size: 100%;
}
.spotlight {
block-size: 100%;
inline-size: 100%;
}
.pip {
position: absolute;
inline-size: 135px;
block-size: 160px;
inset: var(--cpd-space-4x);
}
@media (min-width: 600px) {
.pip {
inline-size: 180px;
block-size: 135px;
}
}
.pip[data-block-alignment="start"] {
inset-block-end: unset;
}
.pip[data-block-alignment="end"] {
inset-block-start: unset;
}
.pip[data-inline-alignment="start"] {
inset-inline-end: unset;
}
.pip[data-inline-alignment="end"] {
inset-inline-start: unset;
}

View File

@@ -0,0 +1,91 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { forwardRef, useCallback, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks";
import { SpotlightExpandedLayout as SpotlightExpandedLayoutModel } from "../state/CallViewModel";
import { CallLayout, GridTileModel, SpotlightTileModel } from "./CallLayout";
import { DragCallback, useUpdateLayout } from "./Grid";
import styles from "./SpotlightExpandedLayout.module.css";
/**
* An implementation of the "expanded spotlight" layout, in which the spotlight
* tile stretches edge-to-edge and is overlaid by a picture-in-picture tile.
*/
export const makeSpotlightExpandedLayout: CallLayout<
SpotlightExpandedLayoutModel
> = ({ pipAlignment }) => ({
scrollingOnTop: true,
fixed: forwardRef(function SpotlightExpandedLayoutFixed(
{ model, Slot },
ref,
) {
useUpdateLayout();
const spotlightTileModel: SpotlightTileModel = useMemo(
() => ({ type: "spotlight", vms: model.spotlight, maximised: true }),
[model.spotlight],
);
return (
<div ref={ref} className={styles.layer}>
<Slot
className={styles.spotlight}
id="spotlight"
model={spotlightTileModel}
/>
</div>
);
}),
scrolling: forwardRef(function SpotlightExpandedLayoutScrolling(
{ model, Slot },
ref,
) {
useUpdateLayout();
const pipAlignmentValue = useObservableEagerState(pipAlignment);
const pipTileModel: GridTileModel | undefined = useMemo(
() => model.pip && { type: "grid", vm: model.pip },
[model.pip],
);
const onDragPip: DragCallback = useCallback(
({ xRatio, yRatio }) =>
pipAlignment.next({
block: yRatio < 0.5 ? "start" : "end",
inline: xRatio < 0.5 ? "start" : "end",
}),
[],
);
return (
<div ref={ref} className={styles.layer}>
{pipTileModel && (
<Slot
className={styles.pip}
id="pip"
model={pipTileModel}
onDrag={onDragPip}
data-block-alignment={pipAlignmentValue.block}
data-inline-alignment={pipAlignmentValue.inline}
/>
)}
</div>
);
}),
});

View File

@@ -0,0 +1,54 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.layer {
block-size: 100%;
display: grid;
--gap: 20px;
gap: var(--gap);
--grid-slot-width: 180px;
grid-template-columns: 1fr var(--grid-slot-width);
grid-template-rows: minmax(1fr, auto);
padding-inline: var(--gap);
}
.spotlight {
container: spotlight / size;
display: grid;
place-items: center;
}
/* CSS makes us put a condition here, even though all we want to do is
unconditionally select the container so we can use cq units */
@container spotlight (width > 0) {
.spotlight > .slot {
inline-size: min(100cqi, 100cqb * (17 / 9));
block-size: min(100cqb, 100cqi / (4 / 3));
}
}
.grid {
display: flex;
flex-wrap: wrap;
gap: var(--gap);
justify-content: center;
align-content: center;
}
.grid > .slot {
inline-size: 180px;
block-size: 135px;
}

View File

@@ -0,0 +1,92 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { forwardRef, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames";
import { CallLayout, GridTileModel, TileModel } from "./CallLayout";
import { SpotlightLandscapeLayout as SpotlightLandscapeLayoutModel } from "../state/CallViewModel";
import styles from "./SpotlightLandscapeLayout.module.css";
import { useUpdateLayout } from "./Grid";
/**
* An implementation of the "spotlight landscape" layout, in which the spotlight
* tile takes up most of the space on the left, and the grid of participants is
* shown as a scrolling rail on the right.
*/
export const makeSpotlightLandscapeLayout: CallLayout<
SpotlightLandscapeLayoutModel
> = ({ minBounds }) => ({
scrollingOnTop: false,
fixed: forwardRef(function SpotlightLandscapeLayoutFixed(
{ model, Slot },
ref,
) {
useUpdateLayout();
useObservableEagerState(minBounds);
const tileModel: TileModel = useMemo(
() => ({
type: "spotlight",
vms: model.spotlight,
maximised: false,
}),
[model.spotlight],
);
return (
<div ref={ref} className={styles.layer}>
<div className={styles.spotlight}>
<Slot className={styles.slot} id="spotlight" model={tileModel} />
</div>
<div className={styles.grid} />
</div>
);
}),
scrolling: forwardRef(function SpotlightLandscapeLayoutScrolling(
{ model, Slot },
ref,
) {
useUpdateLayout();
useObservableEagerState(minBounds);
const tileModels: GridTileModel[] = useMemo(
() => model.grid.map((vm) => ({ type: "grid", vm })),
[model.grid],
);
return (
<div ref={ref} className={styles.layer}>
<div
className={classNames(styles.spotlight, {
[styles.withIndicators]: model.spotlight.length > 1,
})}
/>
<div className={styles.grid}>
{tileModels.map((m) => (
<Slot
key={m.vm.id}
className={styles.slot}
id={m.vm.id}
model={m}
/>
))}
</div>
</div>
);
}),
});

View File

@@ -0,0 +1,56 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
.layer {
block-size: 100%;
display: grid;
--gap: 20px;
gap: var(--gap);
margin-inline: 0;
display: block;
}
.spotlight {
container: spotlight / size;
display: grid;
place-items: center;
inline-size: 100%;
aspect-ratio: 16 / 9;
margin-block-end: var(--cpd-space-4x);
}
.spotlight.withIndicators {
margin-block-end: calc(2 * var(--cpd-space-4x) + 2px);
}
.spotlight > .slot {
inline-size: 100%;
block-size: 100%;
}
.grid {
display: flex;
flex-wrap: wrap;
gap: var(--grid-gap);
justify-content: center;
align-content: start;
padding-inline: var(--grid-gap);
}
.grid > .slot {
inline-size: var(--grid-tile-width);
block-size: var(--grid-tile-height);
}

View File

@@ -0,0 +1,118 @@
/*
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { CSSProperties, forwardRef, useMemo } from "react";
import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames";
import {
CallLayout,
GridTileModel,
TileModel,
arrangeTiles,
} from "./CallLayout";
import { SpotlightPortraitLayout as SpotlightPortraitLayoutModel } from "../state/CallViewModel";
import styles from "./SpotlightPortraitLayout.module.css";
import { useUpdateLayout } from "./Grid";
interface GridCSSProperties extends CSSProperties {
"--grid-gap": string;
"--grid-tile-width": string;
"--grid-tile-height": string;
}
/**
* An implementation of the "spotlight portrait" layout, in which the spotlight
* tile is shown across the top of the screen, and the grid of participants
* scrolls behind it.
*/
export const makeSpotlightPortraitLayout: CallLayout<
SpotlightPortraitLayoutModel
> = ({ minBounds }) => ({
scrollingOnTop: false,
fixed: forwardRef(function SpotlightPortraitLayoutFixed(
{ model, Slot },
ref,
) {
useUpdateLayout();
const tileModel: TileModel = useMemo(
() => ({
type: "spotlight",
vms: model.spotlight,
maximised: true,
}),
[model.spotlight],
);
return (
<div ref={ref} className={styles.layer}>
<div className={styles.spotlight}>
<Slot className={styles.slot} id="spotlight" model={tileModel} />
</div>
</div>
);
}),
scrolling: forwardRef(function SpotlightPortraitLayoutScrolling(
{ model, Slot },
ref,
) {
useUpdateLayout();
const { width } = useObservableEagerState(minBounds);
const { gap, tileWidth, tileHeight } = arrangeTiles(
width,
// TODO: We pretend that the minimum height is the width, because the
// actual minimum height is difficult to calculate
width,
model.grid.length,
);
const tileModels: GridTileModel[] = useMemo(
() => model.grid.map((vm) => ({ type: "grid", vm })),
[model.grid],
);
return (
<div
ref={ref}
className={styles.layer}
style={
{
"--grid-gap": `${gap}px`,
"--grid-tile-width": `${Math.floor(tileWidth)}px`,
"--grid-tile-height": `${Math.floor(tileHeight)}px`,
} as GridCSSProperties
}
>
<div
className={classNames(styles.spotlight, {
[styles.withIndicators]: model.spotlight.length > 1,
})}
/>
<div className={styles.grid}>
{tileModels.map((m) => (
<Slot
key={m.vm.id}
className={styles.slot}
id={m.vm.id}
model={m}
/>
))}
</div>
</div>
);
}),
});

View File

@@ -1,11 +1,11 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,9 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
.videoGrid {
position: relative;
overflow: hidden;
flex: 1;
touch-action: none;
.tile.draggable {
cursor: grab;
}
.tile.draggable:active {
cursor: grabbing;
}

View File

@@ -1,5 +1,5 @@
/*
Copyright 2023 New Vector Ltd
Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,83 +14,76 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { memo, ReactNode, RefObject, useRef } from "react";
import { ComponentType, memo, RefObject, useRef } from "react";
import { EventTypes, Handler, useDrag } from "@use-gesture/react";
import { SpringValue, to } from "@react-spring/web";
import { SpringValue } from "@react-spring/web";
import classNames from "classnames";
import { ChildrenProperties } from "./VideoGrid";
import { TileProps } from "./Grid";
import styles from "./TileWrapper.module.css";
interface Props<T> {
interface Props<M, R extends HTMLElement> {
id: string;
onDragRef: RefObject<
onDrag: RefObject<
(
tileId: string,
state: Parameters<Handler<"drag", EventTypes["drag"]>>[0],
) => void
>;
> | null;
targetWidth: number;
targetHeight: number;
data: T;
model: M;
Tile: ComponentType<TileProps<M, R>>;
opacity: SpringValue<number>;
scale: SpringValue<number>;
shadow: SpringValue<number>;
shadowSpread: SpringValue<number>;
zIndex: SpringValue<number>;
x: SpringValue<number>;
y: SpringValue<number>;
width: SpringValue<number>;
height: SpringValue<number>;
children: (props: ChildrenProperties<T>) => ReactNode;
}
const TileWrapper_ = memo(
<T,>({
<M, R extends HTMLElement>({
id,
onDragRef,
onDrag,
targetWidth,
targetHeight,
data,
model,
Tile,
opacity,
scale,
shadow,
shadowSpread,
zIndex,
x,
y,
width,
height,
children,
}: Props<T>) => {
const ref = useRef<HTMLElement | null>(null);
}: Props<M, R>) => {
const ref = useRef<R | null>(null);
useDrag((state) => onDragRef?.current!(id, state), {
useDrag((state) => onDrag?.current!(id, state), {
target: ref,
filterTaps: true,
preventScroll: true,
});
return (
<>
{children({
ref,
style: {
opacity,
scale,
zIndex,
x,
y,
width,
height,
boxShadow: to(
[shadow, shadowSpread],
(s, ss) => `rgba(0, 0, 0, 0.5) 0px ${s}px ${2 * s}px ${ss}px`,
),
},
targetWidth,
targetHeight,
data,
})}
</>
<Tile
ref={ref}
className={classNames(styles.tile, { [styles.draggable]: onDrag })}
style={{
opacity,
scale,
zIndex,
x,
y,
width,
height,
}}
targetWidth={targetWidth}
targetHeight={targetHeight}
model={model}
/>
);
},
);
@@ -104,4 +97,6 @@ TileWrapper_.displayName = "TileWrapper";
// We pretend this component is a simple function rather than a
// NamedExoticComponent, because that's the only way we can fit in a type
// parameter
export const TileWrapper = TileWrapper_ as <T>(props: Props<T>) => JSX.Element;
export const TileWrapper = TileWrapper_ as <M, R extends HTMLElement>(
props: Props<M, R>,
) => JSX.Element;

View File

@@ -42,8 +42,7 @@ limitations under the License.
align-items: center;
}
.avatar,
.copyButtonSpacer {
.avatar {
flex-shrink: 0;
}
@@ -64,18 +63,6 @@ limitations under the License.
margin-top: 8px;
}
.copyButtonSpacer,
.copyButton {
width: 16px;
height: 16px;
}
.copyButton {
position: absolute;
top: 12px;
right: 12px;
}
.callList {
display: flex;
flex-wrap: wrap;

View File

@@ -15,20 +15,19 @@ limitations under the License.
*/
import { render, RenderResult } from "@testing-library/react";
import { CallList } from "../../src/home/CallList";
import { MatrixClient } from "matrix-js-sdk";
import { GroupCallRoom } from "../../src/home/useGroupCallRooms";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { MemoryRouter } from "react-router-dom";
import { ClientProvider } from "../../src/ClientContext";
import { describe, expect, it } from "vitest";
import { CallList } from "../../src/home/CallList";
import { GroupCallRoom } from "../../src/home/useGroupCallRooms";
describe("CallList", () => {
const renderComponent = (rooms: GroupCallRoom[]): RenderResult => {
return render(
<ClientProvider>
<MemoryRouter>
<CallList client={{} as MatrixClient} rooms={rooms} />
</MemoryRouter>
</ClientProvider>,
<MemoryRouter>
<CallList client={{} as MatrixClient} rooms={rooms} />
</MemoryRouter>,
);
};

View File

@@ -1,5 +1,5 @@
/*
Copyright 2022 New Vector Ltd
Copyright 2022-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,10 +20,9 @@ import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { Room } from "matrix-js-sdk/src/models/room";
import { FC } from "react";
import { CopyButton } from "../button";
import { Avatar, Size } from "../Avatar";
import styles from "./CallList.module.css";
import { getAbsoluteRoomUrl, getRelativeRoomUrl } from "../matrix-utils";
import { getRelativeRoomUrl } from "../utils/matrix";
import { Body } from "../typography/Typography";
import { GroupCallRoom } from "./useGroupCallRooms";
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
@@ -81,12 +80,6 @@ const CallTile: FC<CallTileProps> = ({ name, avatarUrl, room }) => {
</div>
<div className={styles.copyButtonSpacer} />
</Link>
<CopyButton
className={styles.copyButton}
variant="icon"
// Todo add the viaServers to the created link
value={getAbsoluteRoomUrl(room.roomId, roomEncryptionSystem, room.name)}
/>
</div>
);
};

View File

@@ -14,19 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { PressEvent } from "@react-types/shared";
import { useTranslation } from "react-i18next";
import { FC } from "react";
import { FC, MouseEvent } from "react";
import { Button } from "@vector-im/compound-web";
import { Modal } from "../Modal";
import { Button } from "../button";
import { FieldRow } from "../input/Input";
import styles from "./JoinExistingCallModal.module.css";
interface Props {
open: boolean;
onDismiss: () => void;
onJoin: (e: PressEvent) => void;
onJoin: (e: MouseEvent) => void;
}
export const JoinExistingCallModal: FC<Props> = ({
@@ -44,8 +43,8 @@ export const JoinExistingCallModal: FC<Props> = ({
>
<p>{t("join_existing_call_modal.text")}</p>
<FieldRow rightAlign className={styles.buttons}>
<Button onPress={onDismiss}>{t("action.no")}</Button>
<Button onPress={onJoin} data-testid="home_joinExistingRoom">
<Button onClick={onDismiss}>{t("action.no")}</Button>
<Button onClick={onJoin} data-testid="home_joinExistingRoom">
{t("join_existing_call_modal.join_button")}
</Button>
</FieldRow>

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