mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-20 20:49:20 +00:00
Compare commits
153 Commits
hs/modal-t
...
robin/clos
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05c079e3ed | ||
|
|
cf174261c9 | ||
|
|
e36029c9c0 | ||
|
|
0469d8ef56 | ||
|
|
fc8da6ef58 | ||
|
|
4e1b4fae19 | ||
|
|
5c18868aa4 | ||
|
|
9ce16b68e9 | ||
|
|
ad9114a6e4 | ||
|
|
44e1c136df | ||
|
|
1bbbd519c7 | ||
|
|
51e4a3b14b | ||
|
|
8da38d173a | ||
|
|
13887a8943 | ||
|
|
03721f078b | ||
|
|
d146bedf05 | ||
|
|
63f595f958 | ||
|
|
279912d951 | ||
|
|
94e5d032a1 | ||
|
|
720c400e5f | ||
|
|
0718774cef | ||
|
|
a2b452c1d8 | ||
|
|
465a784345 | ||
|
|
8de96878c0 | ||
|
|
b7b9771577 | ||
|
|
3885eefa4c | ||
|
|
9176e06195 | ||
|
|
380fa67f57 | ||
|
|
8830bd74cb | ||
|
|
3ab9bb72e2 | ||
|
|
38085baab8 | ||
|
|
8891a9a70e | ||
|
|
826d0ee40d | ||
|
|
fbc2cd3e97 | ||
|
|
770730ba6c | ||
|
|
b3ceb5300c | ||
|
|
ffbc48fe86 | ||
|
|
4655da3c35 | ||
|
|
585998cb87 | ||
|
|
8ec2f9bb31 | ||
|
|
2ee468ba44 | ||
|
|
17eb435a7a | ||
|
|
1678ca71c1 | ||
|
|
90fe8e0529 | ||
|
|
64749d0b7a | ||
|
|
79cd3047e9 | ||
|
|
9078c35e06 | ||
|
|
2833d9a816 | ||
|
|
8598be1d92 | ||
|
|
02d2de3831 | ||
|
|
6d1aa0087b | ||
|
|
8b4b9f4494 | ||
|
|
a551cde47b | ||
|
|
01b9d7a70e | ||
|
|
f56d4a32a3 | ||
|
|
eed1b98cf9 | ||
|
|
c1208ac7b6 | ||
|
|
d77e9e8f08 | ||
|
|
2e172aa3be | ||
|
|
9650ca9687 | ||
|
|
f7e4b79502 | ||
|
|
20840d901e | ||
|
|
4c1c818ba9 | ||
|
|
f022eb09a2 | ||
|
|
50934a53cd | ||
|
|
99d5886e32 | ||
|
|
137a53dbee | ||
|
|
6e5c468780 | ||
|
|
1478dbe6a1 | ||
|
|
85d8e036d5 | ||
|
|
84e172a2ba | ||
|
|
7fddad02e0 | ||
|
|
3b3f7762a7 | ||
|
|
2297675b06 | ||
|
|
8f4b932c3c | ||
|
|
88782a0332 | ||
|
|
9eae1f4145 | ||
|
|
3d096426be | ||
|
|
83fa9661cf | ||
|
|
6c24763196 | ||
|
|
c4c266536b | ||
|
|
3535cbe2e6 | ||
|
|
dac89b97ae | ||
|
|
854e0ab7ae | ||
|
|
20976e1ee3 | ||
|
|
f12e6601fe | ||
|
|
4b2d8403d7 | ||
|
|
03f0fffa57 | ||
|
|
6486ffe777 | ||
|
|
3dad62f9e3 | ||
|
|
8465bb4c13 | ||
|
|
8be6655d8b | ||
|
|
464cb16409 | ||
|
|
a045cc042b | ||
|
|
29469501db | ||
|
|
a6efdf004f | ||
|
|
50d380cf37 | ||
|
|
6830744096 | ||
|
|
4f9333ca0c | ||
|
|
699b69f019 | ||
|
|
67e5abcf31 | ||
|
|
b22d2dba5f | ||
|
|
97aeb18a24 | ||
|
|
e79cae820f | ||
|
|
2bf08c8fb3 | ||
|
|
ca63035dc1 | ||
|
|
942e07f103 | ||
|
|
18daf446c8 | ||
|
|
8771a06986 | ||
|
|
b3da45612e | ||
|
|
2d262d27dd | ||
|
|
022367ec2e | ||
|
|
56e736b0ee | ||
|
|
3e1e08c883 | ||
|
|
6645a6e5a2 | ||
|
|
a6683b230c | ||
|
|
06a02b4dd8 | ||
|
|
c560b58811 | ||
|
|
7b57fc2942 | ||
|
|
68d71a8329 | ||
|
|
1df2e0c48f | ||
|
|
f1233cad20 | ||
|
|
5d88c52e30 | ||
|
|
c7e220e310 | ||
|
|
5b94dd6f1a | ||
|
|
0ffb4cc23d | ||
|
|
f4096a6d43 | ||
|
|
c9676f2466 | ||
|
|
640ba8b79f | ||
|
|
34abca0c0b | ||
|
|
bea9a24b14 | ||
|
|
fd383328e2 | ||
|
|
938beccb6e | ||
|
|
05eb2a06f4 | ||
|
|
2961cfa52c | ||
|
|
65742db4f2 | ||
|
|
430337e725 | ||
|
|
4a71283826 | ||
|
|
7440f39fef | ||
|
|
69776ba08e | ||
|
|
bf4596dfc5 | ||
|
|
4877474b7d | ||
|
|
4705ab4218 | ||
|
|
e37f36937e | ||
|
|
d1774d63ab | ||
|
|
c33c703570 | ||
|
|
82c6db1f94 | ||
|
|
44cb16d0b8 | ||
|
|
a672224324 | ||
|
|
c5bd68f7db | ||
|
|
2de105c9fd | ||
|
|
275e0bdb00 | ||
|
|
377ccf8f45 |
@@ -37,6 +37,7 @@ module.exports = {
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-await": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"rxjs/no-exposed-subjects": "error",
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
|
||||
1
.github/workflows/build.yaml
vendored
1
.github/workflows/build.yaml
vendored
@@ -23,3 +23,4 @@ jobs:
|
||||
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
||||
SENTRY_URL: ${{ secrets.SENTRY_URL }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
3
.github/workflows/element-call.yaml
vendored
3
.github/workflows/element-call.yaml
vendored
@@ -14,6 +14,8 @@ on:
|
||||
required: true
|
||||
SENTRY_AUTH_TOKEN:
|
||||
required: true
|
||||
CODECOV_TOKEN:
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -36,6 +38,7 @@ jobs:
|
||||
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
|
||||
SENTRY_URL: ${{ secrets.SENTRY_URL }}
|
||||
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
VITE_APP_VERSION: ${{ inputs.vite_app_version }}
|
||||
NODE_OPTIONS: "--max-old-space-size=4096"
|
||||
- name: Upload Artifact
|
||||
|
||||
4
.github/workflows/translations-download.yaml
vendored
4
.github/workflows/translations-download.yaml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
run: "yarn install --frozen-lockfile"
|
||||
|
||||
- name: Prune i18n
|
||||
run: "rm -R public/locales"
|
||||
run: "rm -R locales"
|
||||
|
||||
- name: Download translation files
|
||||
uses: localazy/download@0a79880fb66150601e3b43606fab69c88123c087 # v1.1.0
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
groups: "-p includeSourceLang:true"
|
||||
|
||||
- name: Fix the owner of the downloaded files
|
||||
run: "sudo chown runner:docker -R public/locales"
|
||||
run: "sudo chown runner:docker -R locales"
|
||||
|
||||
- name: Prettier
|
||||
run: yarn prettier:format
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,5 +6,6 @@ dist-ssr
|
||||
*.local
|
||||
.idea/
|
||||
public/config.json
|
||||
backend/synapse_tmp/*
|
||||
/coverage
|
||||
yarn-error.log
|
||||
|
||||
@@ -2,9 +2,3 @@ FROM nginxinc/nginx-unprivileged:alpine
|
||||
|
||||
COPY ./dist /app
|
||||
COPY config/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
USER root
|
||||
|
||||
RUN rm -rf /usr/share/nginx/html
|
||||
|
||||
USER 101
|
||||
|
||||
135
README.md
135
README.md
@@ -3,17 +3,24 @@
|
||||
[](https://matrix.to/#/#webrtc:matrix.org)
|
||||
[](https://localazy.com/p/element-call)
|
||||
|
||||
Group calls with WebRTC that leverage [Matrix](https://matrix.org) and an open-source WebRTC toolkit from [LiveKit](https://livekit.io/).
|
||||
Group calls with WebRTC that leverage [Matrix](https://matrix.org) and an
|
||||
open-source WebRTC toolkit from [LiveKit](https://livekit.io/).
|
||||
|
||||
For prior version of the Element Call that relied solely on full-mesh logic, check [`full-mesh`](https://github.com/element-hq/element-call/tree/full-mesh) branch.
|
||||
For prior version of the Element Call that relied solely on full-mesh logic,
|
||||
check [`full-mesh`](https://github.com/element-hq/element-call/tree/full-mesh)
|
||||
branch.
|
||||
|
||||

|
||||
|
||||
To try it out, visit our hosted version at [call.element.io](https://call.element.io). You can also find the latest development version continuously deployed to [call.element.dev](https://call.element.dev/).
|
||||
To try it out, visit our hosted version at
|
||||
[call.element.io](https://call.element.io). You can also find the latest
|
||||
development version continuously deployed to
|
||||
[call.element.dev](https://call.element.dev/).
|
||||
|
||||
## Host it yourself
|
||||
|
||||
Until prebuilt tarballs are available, you'll need to build Element Call from source. First, clone and install the package:
|
||||
Until prebuilt tarballs are available, you'll need to build Element Call from
|
||||
source. First, clone and install the package:
|
||||
|
||||
```
|
||||
git clone https://github.com/element-hq/element-call.git
|
||||
@@ -22,17 +29,23 @@ 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 that can be configured with custom routes (see below).
|
||||
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:
|
||||
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:
|
||||
|
||||
```
|
||||
cp config/config.sample.json public/config.json
|
||||
# edit public/config.json
|
||||
```
|
||||
|
||||
Because Element Call uses client-side routing, your server must be able to route any requests to non-existing paths back to `/index.html`. For example, in Nginx you can achieve this with the `try_files` directive:
|
||||
Because Element Call uses client-side routing, your server must be able to route
|
||||
any requests to non-existing paths back to `/index.html`. For example, in Nginx
|
||||
you can achieve this with the `try_files` directive:
|
||||
|
||||
```
|
||||
server {
|
||||
@@ -44,28 +57,63 @@ server {
|
||||
}
|
||||
```
|
||||
|
||||
By default, the app expects you to have a Matrix homeserver (such as [Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html)) installed locally and running on port 8008. If you wish to use a homeserver on a different URL or one that is hosted on a different server, you can add a config file as above, and include the homeserver URL that you'd like to use.
|
||||
By default, the app expects you to have a Matrix homeserver (such as
|
||||
[Synapse](https://element-hq.github.io/synapse/latest/setup/installation.html))
|
||||
installed locally and running on port 8008. If you wish to use a homeserver on a
|
||||
different URL or one that is hosted on a different server, you can add a config
|
||||
file as above, and include the homeserver URL that you'd like to use.
|
||||
|
||||
Element Call requires a homeserver with registration enabled without any 3pid or token requirements, if you want it to be used by unregistered users. Furthermore, it is not recommended to use it with an existing homeserver where user accounts have joined normal rooms, as it may not be able to handle those yet and it may behave unreliably.
|
||||
Element Call requires a homeserver with registration enabled without any 3pid or
|
||||
token requirements, if you want it to be used by unregistered users.
|
||||
Furthermore, it is not recommended to use it with an existing homeserver where
|
||||
user accounts have joined normal rooms, as it may not be able to handle those
|
||||
yet and it may behave unreliably.
|
||||
|
||||
Therefore, to use a self-hosted homeserver, this is recommended to be a new server where any user account created has not joined any normal rooms anywhere in the Matrix federated network. The homeserver used can be setup to disable federation, so as to prevent spam registrations (if you keep registrations open) and to ensure Element Call continues to work in case any user decides to log in to their Element Call account using the standard Element app and joins normal rooms that Element Call cannot handle.
|
||||
Therefore, to use a self-hosted homeserver, this is recommended to be a new
|
||||
server where any user account created has not joined any normal rooms anywhere
|
||||
in the Matrix federated network. The homeserver used can be setup to disable
|
||||
federation, so as to prevent spam registrations (if you keep registrations open)
|
||||
and to ensure Element Call continues to work in case any user decides to log in
|
||||
to their Element Call account using the standard Element app and joins normal
|
||||
rooms that Element Call cannot handle.
|
||||
|
||||
## Configuration
|
||||
|
||||
There are currently two different config files. `.env` holds variables that are used at build time, while `public/config.json` holds variables that are used at runtime. Documentation and default values for `public/config.json` can be found in [ConfigOptions.ts](src/config/ConfigOptions.ts).
|
||||
There are currently two different config files. `.env` holds variables that are
|
||||
used at build time, while `public/config.json` holds variables that are used at
|
||||
runtime. Documentation and default values for `public/config.json` can be found
|
||||
in [ConfigOptions.ts](src/config/ConfigOptions.ts).
|
||||
|
||||
If you're using [Synapse](https://github.com/element-hq/synapse/), you'll need to additionally add the following to `homeserver.yaml` or Element Call won't work:
|
||||
If you're using [Synapse](https://github.com/element-hq/synapse/), you'll need
|
||||
to additionally add the following to `homeserver.yaml` or Element Call won't
|
||||
work:
|
||||
|
||||
```
|
||||
experimental_features:
|
||||
# MSC3266: Room summary API. Used for knocking over federation
|
||||
msc3266_enabled: true
|
||||
|
||||
# The maximum allowed duration by which sent events can be delayed, as
|
||||
# per MSC4140.
|
||||
max_event_delay_duration: 24h
|
||||
|
||||
rc_message:
|
||||
# This needs to match at least the heart-beat frequency plus a bit of headroom
|
||||
# Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s
|
||||
per_second: 0.5
|
||||
burst_count: 30
|
||||
```
|
||||
|
||||
MSC3266 allows to request a room summary of rooms you are not joined.
|
||||
The summary contains the room join rules. We need that to decide if the user gets prompted with the option to knock ("ask to join"), a cannot join error or the join view.
|
||||
MSC3266 allows to request a room summary of rooms you are not joined. The
|
||||
summary contains the room join rules. We need that to decide if the user gets
|
||||
prompted with the option to knock ("Request to join call"), a cannot join error or the
|
||||
join view.
|
||||
|
||||
Element Call requires a Livekit SFU behind a Livekit jwt service to work. The url to the Livekit jwt service can either be configured in the config of Element Call (fallback/legacy configuration) or be configured by your homeserver via the `.well-known`.
|
||||
This is the recommended method.
|
||||
Element Call requires a Livekit SFU alongside a [Livekit JWT
|
||||
service](https://github.com/element-hq/lk-jwt-service) to work. The url to the
|
||||
Livekit JWT service can either be configured in the config of Element Call
|
||||
(fallback/legacy configuration) or be configured by your homeserver via the
|
||||
`.well-known/matrix/client`. This is the recommended method.
|
||||
|
||||
The configuration is a list of Foci configs:
|
||||
|
||||
@@ -88,13 +136,18 @@ The configuration is a list of Foci configs:
|
||||
|
||||
## Translation
|
||||
|
||||
If you'd like to help translate Element Call, head over to [Localazy](https://localazy.com/p/element-call). You're also encouraged to join the [Element Translators](https://matrix.to/#/#translators:element.io) space to discuss and coordinate translation efforts.
|
||||
If you'd like to help translate Element Call, head over to
|
||||
[Localazy](https://localazy.com/p/element-call). You're also encouraged to join
|
||||
the [Element Translators](https://matrix.to/#/#translators:element.io) space to
|
||||
discuss and coordinate translation efforts.
|
||||
|
||||
## Development
|
||||
|
||||
### Frontend
|
||||
|
||||
Element Call is built against [matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/pull/2553). To get started, clone, install, and link the package:
|
||||
Element Call is built against
|
||||
[matrix-js-sdk](https://github.com/matrix-org/matrix-js-sdk/pull/2553). To get
|
||||
started, clone, install, and link the package:
|
||||
|
||||
```
|
||||
git clone https://github.com/matrix-org/matrix-js-sdk.git
|
||||
@@ -112,6 +165,15 @@ yarn
|
||||
yarn link matrix-js-sdk
|
||||
```
|
||||
|
||||
To use it, create a local config by, e.g., `cp ./config/config.devenv.json
|
||||
./public/config.json` and adapt it if necessary. The `config.devenv.json` config
|
||||
should work with the backend development environment as outlined in the next
|
||||
section out of box.
|
||||
|
||||
(Be aware, that this `config.devenv.json` is exposing a deprecated fallback
|
||||
LiveKit config key. If the homeserver advertises SFU backend via
|
||||
`.well-known/matrix/client` this has precedence.)
|
||||
|
||||
You're now ready to launch the development server:
|
||||
|
||||
```
|
||||
@@ -120,25 +182,25 @@ yarn dev
|
||||
|
||||
### Backend
|
||||
|
||||
A docker compose file is provided to start a LiveKit server and auth
|
||||
service for development. These use a test 'secret' published in this
|
||||
repository, so this must be used only for local development and
|
||||
**_never be exposed to the public Internet._**
|
||||
A docker compose file `dev-backend-docker-compose.yml` is provided to start the
|
||||
whole stack of components which is required for a local development environment:
|
||||
|
||||
To use it, add a SFU parameter in your local config `./public/config.json`:
|
||||
(Be aware, that this is only the fallback Livekit SFU. If the homeserver
|
||||
advertises one in the client well-known, this will not be used.)
|
||||
- Minimum Synapse Setup (servername: synapse.localhost)
|
||||
- LiveKit JWT Service (Note requires Federation API and hence a TLS reverse proxy)
|
||||
- Minimum TLS reverse proxy (servername: synapse.localhost) Note certificates
|
||||
are valid for at least 10 years from now
|
||||
- Minimum LiveKit SFU Setup using dev defaults for config
|
||||
- Redis db for completness
|
||||
|
||||
```json
|
||||
"livekit": {
|
||||
"livekit_service_url": "http://localhost:7881"
|
||||
},
|
||||
```
|
||||
These use a test 'secret' published in this repository, so this must be used
|
||||
only for local development and **_never be exposed to the public Internet._**
|
||||
|
||||
Run backend components:
|
||||
|
||||
```
|
||||
yarn backend
|
||||
# or for podman-compose
|
||||
# podman-compose -f dev-backend-docker-compose.yml up
|
||||
```
|
||||
|
||||
### Test Coverage
|
||||
@@ -150,7 +212,8 @@ yarn backend
|
||||
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:
|
||||
1. Run `yarn i18n` to extract the new key and update the translation files. This
|
||||
will add a skeleton entry to the `locales/en-GB/app.json` file:
|
||||
```jsonc
|
||||
{
|
||||
...
|
||||
@@ -158,14 +221,16 @@ To add a new translation key you can do these steps:
|
||||
...
|
||||
}
|
||||
```
|
||||
1. Update the skeleton entry in the `public/locales/en-GB/app.json` file with the English translation:
|
||||
```jsonc
|
||||
1. Update the skeleton entry in the `locales/en-GB/app.json` file with
|
||||
the English translation:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
...
|
||||
"some_new_key": "Some new key",
|
||||
...
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
version: "3.9"
|
||||
|
||||
networks:
|
||||
lkbackend:
|
||||
|
||||
services:
|
||||
auth-service:
|
||||
image: ghcr.io/element-hq/lk-jwt-service:latest-ci
|
||||
hostname: auth-server
|
||||
# Use host network in case the configured homeserver runs on localhost
|
||||
network_mode: host
|
||||
environment:
|
||||
- LK_JWT_PORT=8881
|
||||
- LIVEKIT_URL=ws://localhost:7880
|
||||
- LIVEKIT_KEY=devkey
|
||||
- LIVEKIT_SECRET=secret
|
||||
# If the configured homeserver runs on localhost, it'll probably be using
|
||||
# a self-signed certificate
|
||||
- LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
networks:
|
||||
- lkbackend
|
||||
|
||||
livekit:
|
||||
image: livekit/livekit-server:latest
|
||||
command: --dev --config /etc/livekit.yaml
|
||||
restart: unless-stopped
|
||||
# The SFU seems to work far more reliably when we let it share the host
|
||||
# network rather than opening specific ports (but why?? we're not missing
|
||||
# any…)
|
||||
network_mode: host
|
||||
# ports:
|
||||
# - "7880:7880/tcp"
|
||||
# - "7881:7881/tcp"
|
||||
# - "7882:7882/tcp"
|
||||
# - "50100-50200:50100-50200/udp"
|
||||
volumes:
|
||||
- ./backend/livekit.yaml:/etc/livekit.yaml
|
||||
networks:
|
||||
- lkbackend
|
||||
|
||||
redis:
|
||||
image: redis:6-alpine
|
||||
command: redis-server /etc/redis.conf
|
||||
ports:
|
||||
- 6379:6379
|
||||
volumes:
|
||||
- ./backend/redis.conf:/etc/redis.conf
|
||||
networks:
|
||||
- lkbackend
|
||||
51
backend/dev_homeserver.yaml
Normal file
51
backend/dev_homeserver.yaml
Normal file
@@ -0,0 +1,51 @@
|
||||
server_name: "synapse.localhost"
|
||||
public_baseurl: http://synapse.localhost:8008/
|
||||
|
||||
pid_file: /data/homeserver.pid
|
||||
|
||||
listeners:
|
||||
- port: 8008
|
||||
tls: false
|
||||
type: http
|
||||
x_forwarded: true
|
||||
resources:
|
||||
- names: [client, federation, openid]
|
||||
compress: false
|
||||
|
||||
database:
|
||||
name: sqlite3
|
||||
args:
|
||||
database: /data/homeserver.db
|
||||
|
||||
media_store_path: /data/media_store
|
||||
signing_key_path: "/data/SERVERNAME.signing.key"
|
||||
trusted_key_servers:
|
||||
- server_name: "matrix.org"
|
||||
|
||||
experimental_features:
|
||||
# MSC3266: Room summary API. Used for knocking over federation
|
||||
msc3266_enabled: true
|
||||
|
||||
# The maximum allowed duration by which sent events can be delayed, as
|
||||
# per MSC4140. Must be a positive value if set. Defaults to no
|
||||
# duration (null), which disallows sending delayed events.
|
||||
max_event_delay_duration: 24h
|
||||
|
||||
# Ratelimiting settings for client actions (registration, login, messaging).
|
||||
#
|
||||
# Each ratelimiting configuration is made of two parameters:
|
||||
# - per_second: number of requests a client can send per second.
|
||||
# - burst_count: number of requests a client can send before being throttled.
|
||||
|
||||
rc_message:
|
||||
# This needs to match at least the heart-beat frequency plus a bit of headroom
|
||||
# Currently the heart-beat is every 5 seconds which translates into a rate of 0.2s
|
||||
per_second: 0.5
|
||||
burst_count: 30
|
||||
|
||||
# Required for Element Call in Single Page Mode due to on-the-fly user registration
|
||||
enable_registration: true
|
||||
enable_registration_without_verification: true
|
||||
|
||||
report_stats: false
|
||||
serve_server_wellknown: true
|
||||
22
backend/tls_localhost_cert.pem
Normal file
22
backend/tls_localhost_cert.pem
Normal file
@@ -0,0 +1,22 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDtzCCAp+gAwIBAgIUCmJjl3HAeLmrPwRg+/OzikW6peQwDQYJKoZIhvcNAQEL
|
||||
BQAwazELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9u
|
||||
ZG9uMQ4wDAYDVQQKDAVBbHJvczEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDESMBAG
|
||||
A1UEAwwJbG9jYWxob3N0MB4XDTI0MTEwNDIxNDcwMFoXDTM0MTEwMjIxNDcwMFow
|
||||
azELMAkGA1UEBhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9u
|
||||
MQ4wDAYDVQQKDAVBbHJvczEWMBQGA1UECwwNSVQgRGVwYXJ0bWVudDESMBAGA1UE
|
||||
AwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs368
|
||||
ExLSudP8luNoY5UfaPqBSVJUPYBi+JGyd36tyN75p5OI7xSfHTttQxuD4KrExBFP
|
||||
C8mAhE1eoZPBVBOZJ4FYWBJfMaQnCjeqU+laP36td65kSJYbUYlKYH1WpxEpCdgx
|
||||
wWOKkP/kPX5YXbYqODx9aBJXgoT3yAJW7AniIoL+eLFnS9Xo86TPqCDBTJU9ocwK
|
||||
gPIDLhDv60724rhZT1kbGp7ECqRovndoDTQjuws2D3yNMfQ+4rrQGPXHGmP5PcaR
|
||||
0R7uueB+6APyC7MJbuhbxxg/+DFHrRi3lJsgwxuh2hi/+vWw8zgKlgYIwHFA9X0l
|
||||
cX0UlQdENMH3bgcGIwIDAQABo1MwUTAdBgNVHQ4EFgQUUFGxw7zoiHXGwRqtagjZ
|
||||
RPYc85cwHwYDVR0jBBgwFoAUUFGxw7zoiHXGwRqtagjZRPYc85cwDwYDVR0TAQH/
|
||||
BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEALokb1z2lu3qW141b2wm14ilZQKCZ
|
||||
reNNuUR95Uom96FXPH4QVEH+mYTXXJ5UrfNhQYKQFpdE+5S4HL/UqEOxtWvbAHpK
|
||||
nsLQ62J8m+0+uwiJGqeQpWr03KJgXDAVE9X3XwMlp/+buxSLhc+GIHWuXW56itV2
|
||||
jiZJYjhO5SnhhgTWNoVZk93qXuuWEN0yacw7c3Fr1IvFYYYWufbXTk70dbZihPDK
|
||||
VD141o8tpp6FerSKHNYDqkVFDyTz3DVOhQQJ59zfMre7bFr+PpTTl4vIuGzXEY+E
|
||||
HPjUSlOzwkCoh5fu7Fs3qG55rJt8akhTEoKpiBTaLucgAjVWNHeci1+Yxg==
|
||||
-----END CERTIFICATE-----
|
||||
28
backend/tls_localhost_key.pem
Normal file
28
backend/tls_localhost_key.pem
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzfrwTEtK50/yW
|
||||
42hjlR9o+oFJUlQ9gGL4kbJ3fq3I3vmnk4jvFJ8dO21DG4PgqsTEEU8LyYCETV6h
|
||||
k8FUE5kngVhYEl8xpCcKN6pT6Vo/fq13rmRIlhtRiUpgfVanESkJ2DHBY4qQ/+Q9
|
||||
flhdtio4PH1oEleChPfIAlbsCeIigv54sWdL1ejzpM+oIMFMlT2hzAqA8gMuEO/r
|
||||
TvbiuFlPWRsansQKpGi+d2gNNCO7CzYPfI0x9D7iutAY9ccaY/k9xpHRHu654H7o
|
||||
A/ILswlu6FvHGD/4MUetGLeUmyDDG6HaGL/69bDzOAqWBgjAcUD1fSVxfRSVB0Q0
|
||||
wfduBwYjAgMBAAECggEACTqdSExxzJ+LX5ARFaWyOBSWly2GKqSyR14+aInOklhx
|
||||
9QgkmfOxJrCf3TvJ8RWhXloW0Aqr8qGDxG0Ixgjn7rG7gskXCey1xn8MNppLS0kj
|
||||
ztaG+NB3AR89ABm8XdoHsSY45geh3/Ni9I0i1VardGQafUJhgNLTZqjwIodzkBtJ
|
||||
S/bi4uFk1lGNfuvWQvWqzGXUvd1l1YupV6iA4GfhXlUvrSBZwftLBD6xEvQaSqsA
|
||||
pHvBxTfMXG4RMAkNPDIElkuQ8++CGi1gIRkJfmrv4OgbbitteMnxqqqGYV0zSNCg
|
||||
R/5FG6umIV7lDLBHZCSCk7wmfmq2UUvzhHThHy4yMQKBgQDu4TwFJCIcVIj7Wj4r
|
||||
DUBFvz6Lgbltqb+YAMUBtpiDcAQxDJWmedh6dK04ts5CFAFRlRjjuz2uFn7qlVBm
|
||||
uye9R7tL+tOv5viqDXU78a4snFywoXub6yzpbxrW8B4W1pdIUvQmhwCcDwvO1V24
|
||||
7Vj2vxcM5I9dsk1aCQSi3VY5yQKBgQDAW/VoTRwhU6OUc6sji5Z5dnkMjkP6NZK9
|
||||
CSrTWLAMGaLPY+g6fFS7JMNSvfWm/okypD6rcN7p0cxMK3mfFKmMiyPRde0wdrci
|
||||
sGFjGxM/2d2D7KTMC9iMYwA0K17UIna+UiYPfhR/muIg/dCyjlkKDFs9Z4jk//r1
|
||||
91bmznt2iwKBgFdiYXhn/Wprqih4nKFXGZnqGdEixVhObl4GegrkZuo+AeqHdf8O
|
||||
N5ikMfG7PbyCYPEdH5u/FRMn+4mI0X6jHChroyJqQSHp1jEu9yHUiSicknOyvusM
|
||||
nsNN932FHRyxp2m3nsSxQhHUlzc0ajKJ8K9iu+XlfmSCIzW6cs25Nh+xAoGBAJro
|
||||
M0wIdPPdsCj3sUVRvx8XqknTM6kGhaIYBNXoYPWNm5BaC4U15OJEq8sxUOdnqcMP
|
||||
g6x6m/k+S8C3bh0O/a9Bydl/l0BlCfw0gGjYP/s2ju4Tn272xy/e9iYNGzPIgUmp
|
||||
TB9D0GwmpZ4d6HgyrD+sTbm4bATGpCp6QhBjDggbAoGBAJVMMtZ4pF8D6mLMRZGR
|
||||
pQjNPy+MH13XYmDRc/BSF8KJ4yKk3tohr9LSXzxR0SEB43NoL1bHkucZrNjGyL8x
|
||||
jktnwkoIs96kO2mPrl1TqWkXs5RjGkkSTbAJovIcvkRU31SWap/WzN2kHpmRVcQc
|
||||
KEFKXT5fUYZCLLWxhgZFlGPp
|
||||
-----END PRIVATE KEY-----
|
||||
40
backend/tls_localhost_nginx.conf
Normal file
40
backend/tls_localhost_nginx.conf
Normal file
@@ -0,0 +1,40 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
listen 443 ssl;
|
||||
listen 8448 ssl;
|
||||
listen [::]:443 ssl;
|
||||
listen [::]:8448 ssl;
|
||||
server_name synapse.localhost;
|
||||
ssl_certificate /root/ssl/cert.pem;
|
||||
ssl_certificate_key /root/ssl/key.pem;
|
||||
|
||||
# well-known config adding rtc_foci backend
|
||||
# Note well-known is currently not effective due to:
|
||||
# https://spec.matrix.org/v1.12/client-server-api/#well-known-uri the spec
|
||||
# says it must be at https://$server_name/... (implied port 443) Hence, we
|
||||
# currently rely for local development environment on deprecated config.json
|
||||
# setting for livekit_service_url
|
||||
location /.well-known/matrix/client {
|
||||
return 200 '{"m.homeserver": {"base_url": "http://synapse.localhost:8008"}, "org.matrix.msc4143.rtc_foci": [{"type": "livekit", "livekit_service_url": "http://localhost:8080"}]}';
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# Reverse proxy for Matrix Synapse Homeserver
|
||||
# This is also required for development environment.
|
||||
# Reason: the lk-jwt-service uses the federation API for the openid token
|
||||
# verification, which requires TLS
|
||||
location / {
|
||||
proxy_pass "http://homeserver:8008";
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
|
||||
}
|
||||
15
config/config.devenv.json
Normal file
15
config/config.devenv.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"default_server_config": {
|
||||
"m.homeserver": {
|
||||
"base_url": "http://synapse.localhost:8008",
|
||||
"server_name": "synapse.localhost"
|
||||
}
|
||||
},
|
||||
"livekit": {
|
||||
"livekit_service_url": "http://localhost:8009"
|
||||
},
|
||||
"features": {
|
||||
"feature_use_device_session_member_events": true
|
||||
},
|
||||
"eula": "https://static.element.io/legal/online-EULA.pdf"
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"default_server_config": {
|
||||
"m.homeserver": {
|
||||
"base_url": "https://call.ems.host",
|
||||
"server_name": "call.ems.host"
|
||||
"base_url": "http://synapse.localhost:8008",
|
||||
"server_name": "synapse.localhost"
|
||||
}
|
||||
},
|
||||
"livekit": {
|
||||
"livekit_service_url": "http://localhost:7881"
|
||||
},
|
||||
"features": {
|
||||
"feature_use_device_session_member_events": true
|
||||
},
|
||||
|
||||
@@ -3,23 +3,17 @@ server {
|
||||
server_name localhost;
|
||||
|
||||
root /app;
|
||||
gzip_static on;
|
||||
gzip_vary on;
|
||||
|
||||
location / {
|
||||
# disable cache entriely by default (apart from Etag which is accurate enough)
|
||||
add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
|
||||
if_modified_since off;
|
||||
expires off;
|
||||
# also turn off last-modified since they are just the timestamps of the file in the docker image
|
||||
# and may or may not bear any resemblance to when the resource changed
|
||||
add_header Last-Modified "";
|
||||
|
||||
try_files $uri /$uri /index.html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "public, max-age=30, stale-while-revalidate=30";
|
||||
}
|
||||
|
||||
# assets can be cached because they have hashed filenames
|
||||
location /assets {
|
||||
expires 1w;
|
||||
add_header Cache-Control "public, no-transform";
|
||||
add_header Cache-Control "public, immutable, max-age=31536000";
|
||||
}
|
||||
|
||||
location /apple-app-site-association {
|
||||
|
||||
86
dev-backend-docker-compose.yml
Normal file
86
dev-backend-docker-compose.yml
Normal file
@@ -0,0 +1,86 @@
|
||||
networks:
|
||||
ecbackend:
|
||||
|
||||
services:
|
||||
auth-service:
|
||||
image: ghcr.io/element-hq/lk-jwt-service:latest-ci
|
||||
hostname: auth-server
|
||||
environment:
|
||||
- LK_JWT_PORT=8080
|
||||
- LIVEKIT_URL=ws://localhost:7880
|
||||
- LIVEKIT_KEY=devkey
|
||||
- LIVEKIT_SECRET=secret
|
||||
# If the configured homeserver runs on localhost, it'll probably be using
|
||||
# a self-signed certificate
|
||||
- LIVEKIT_INSECURE_SKIP_VERIFY_TLS=YES_I_KNOW_WHAT_I_AM_DOING
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
ports:
|
||||
# HOST_PORT:CONTAINER_PORT
|
||||
- 8009:8080
|
||||
networks:
|
||||
- ecbackend
|
||||
|
||||
livekit:
|
||||
image: livekit/livekit-server:latest
|
||||
command: --dev --config /etc/livekit.yaml
|
||||
restart: unless-stopped
|
||||
# The SFU seems to work far more reliably when we let it share the host
|
||||
# network rather than opening specific ports (but why?? we're not missing
|
||||
# any…)
|
||||
ports:
|
||||
# HOST_PORT:CONTAINER_PORT
|
||||
- 7880:7880/tcp
|
||||
- 7881:7881/tcp
|
||||
- 7882:7882/tcp
|
||||
- 50100-50200:50100-50200/udp
|
||||
volumes:
|
||||
- ./backend/dev_livekit.yaml:/etc/livekit.yaml:Z
|
||||
networks:
|
||||
- ecbackend
|
||||
|
||||
redis:
|
||||
image: redis:6-alpine
|
||||
command: redis-server /etc/redis.conf
|
||||
ports:
|
||||
# HOST_PORT:CONTAINER_PORT
|
||||
- 6379:6379
|
||||
volumes:
|
||||
- ./backend/redis.conf:/etc/redis.conf:Z
|
||||
networks:
|
||||
- ecbackend
|
||||
|
||||
synapse:
|
||||
hostname: homeserver
|
||||
image: docker.io/matrixdotorg/synapse:latest
|
||||
environment:
|
||||
- SYNAPSE_CONFIG_PATH=/data/cfg/homeserver.yaml
|
||||
# Needed for rootless podman-compose such that the uid/gid mapping does
|
||||
# fit local user uid. If the container runs as root (uid 0) it is fine as
|
||||
# it actually maps to your non-root user on the host (e.g. 1000).
|
||||
# Otherwise uid mapping will not match your non-root user.
|
||||
- UID=0
|
||||
- GID=0
|
||||
volumes:
|
||||
- ./backend/synapse_tmp:/data:Z
|
||||
- ./backend/dev_homeserver.yaml:/data/cfg/homeserver.yaml:Z
|
||||
networks:
|
||||
- ecbackend
|
||||
|
||||
nginx:
|
||||
# openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout tls_localhost_key.pem -out tls_localhost_cert.pem -subj "/C=GB/ST=London/L=London/O=Alros/OU=IT Department/CN=localhost"
|
||||
hostname: synapse.localhost
|
||||
image: nginx:latest
|
||||
volumes:
|
||||
- ./backend/tls_localhost_nginx.conf:/etc/nginx/conf.d/default.conf:Z
|
||||
- ./backend/tls_localhost_key.pem:/root/ssl/key.pem:Z
|
||||
- ./backend/tls_localhost_cert.pem:/root/ssl/cert.pem:Z
|
||||
ports:
|
||||
# HOST_PORT:CONTAINER_PORT
|
||||
- "8008:80"
|
||||
- "4443:443"
|
||||
depends_on:
|
||||
- synapse
|
||||
networks:
|
||||
- ecbackend
|
||||
@@ -25,230 +25,38 @@ There are two formats for Element Call urls.
|
||||
```
|
||||
|
||||
With this format the livekit alias that will be used is the `<room_name>`.
|
||||
All ppl connecting to this url will end up in the same unencrypted room.
|
||||
All people connecting to this URL will end up in the same unencrypted room.
|
||||
This does not scale, is super unsecure
|
||||
(ppl could end up in the same room by accident) and it also is not really
|
||||
(people could end up in the same room by accident) and it also is not really
|
||||
possible to support encryption.
|
||||
The url parameters are spit into two categories: **general** and **widget related**.
|
||||
|
||||
## Widget related params
|
||||
## Parameters
|
||||
|
||||
**widgetId**
|
||||
The id used by the widget. The presence of this parameter implies that element
|
||||
call will not connect to a homeserver directly and instead tries to establish
|
||||
postMessage communication via the `parentUrl`.
|
||||
|
||||
```ts
|
||||
widgetId: string | null;
|
||||
```
|
||||
|
||||
**parentUrl**
|
||||
The url used to send widget action postMessages. This should be the domain of
|
||||
the client or the webview the widget is hosted in. (in case the widget is not
|
||||
in an Iframe but in a dedicated webview we send the postMessages same webview
|
||||
the widget lives in. Filtering is done in the widget so it ignores the messages
|
||||
it receives from itself)
|
||||
|
||||
```ts
|
||||
parentUrl: string | null;
|
||||
```
|
||||
|
||||
**userId**
|
||||
The user's ID (only used in matryoshka mode).
|
||||
|
||||
```ts
|
||||
userId: string | null;
|
||||
```
|
||||
|
||||
**deviceId**
|
||||
The device's ID (only used in matryoshka mode).
|
||||
|
||||
```ts
|
||||
deviceId: string | null;
|
||||
```
|
||||
|
||||
**baseUrl**
|
||||
The base URL of the homeserver to use for media lookups in matryoshka mode.
|
||||
|
||||
```ts
|
||||
baseUrl: string | null;
|
||||
```
|
||||
|
||||
### General url parameters
|
||||
|
||||
**roomId**
|
||||
Anything about what room we're pointed to should be from useRoomIdentifier which
|
||||
parses the path and resolves alias with respect to the default server name, however
|
||||
roomId is an exception as we need the room ID in embedded (matroyska) mode, and not
|
||||
the room alias (or even the via params because we are not trying to join it). This
|
||||
is also not validated, where it is in useRoomIdentifier().
|
||||
|
||||
```ts
|
||||
roomId: string | null;
|
||||
```
|
||||
|
||||
**confineToRoom**
|
||||
Whether the app should keep the user confined to the current call/room.
|
||||
|
||||
```ts
|
||||
confineToRoom: boolean; (default: false)
|
||||
```
|
||||
|
||||
**appPrompt**
|
||||
Whether upon entering a room, the user should be prompted to launch the
|
||||
native mobile app. (Affects only Android and iOS.)
|
||||
|
||||
The app prompt must also be enabled in the config for this to take effect.
|
||||
|
||||
```ts
|
||||
appPrompt: boolean; (default: true)
|
||||
```
|
||||
|
||||
**preload**
|
||||
Whether the app should pause before joining the call until it sees an
|
||||
io.element.join widget action, allowing it to be preloaded.
|
||||
|
||||
```ts
|
||||
preload: boolean; (default: false)
|
||||
```
|
||||
|
||||
**hideHeader**
|
||||
Whether to hide the room header when in a call.
|
||||
|
||||
```ts
|
||||
hideHeader: boolean; (default: false)
|
||||
```
|
||||
|
||||
**showControls**
|
||||
Whether to show the buttons to mute, screen-share, invite, hangup are shown
|
||||
when in a call.
|
||||
|
||||
```ts
|
||||
showControls: boolean; (default: true)
|
||||
```
|
||||
|
||||
**hideScreensharing**
|
||||
Whether to hide the screen-sharing button.
|
||||
|
||||
```ts
|
||||
hideScreensharing: boolean; (default: false)
|
||||
```
|
||||
|
||||
**enableE2EE** (Deprecated)
|
||||
Whether to use end-to-end encryption. This is a legacy flag for the full mesh branch.
|
||||
It is not used on the livekit branch and has no impact there!
|
||||
|
||||
```ts
|
||||
enableE2EE: boolean; (default: true)
|
||||
```
|
||||
|
||||
**perParticipantE2EE**
|
||||
Whether to use per participant encryption.
|
||||
Keys will be exchanged over encrypted matrix room messages.
|
||||
|
||||
```ts
|
||||
perParticipantE2EE: boolean; (default: false)
|
||||
```
|
||||
|
||||
**password**
|
||||
E2EE password when using a shared secret.
|
||||
(For individual sender keys in embedded mode this is not required.)
|
||||
|
||||
```ts
|
||||
password: string | null;
|
||||
```
|
||||
|
||||
**displayName**
|
||||
The display name to use for auto-registration.
|
||||
|
||||
```ts
|
||||
displayName: string | null;
|
||||
```
|
||||
|
||||
**lang**
|
||||
The BCP 47 code of the language the app should use.
|
||||
|
||||
```ts
|
||||
lang: string | null;
|
||||
```
|
||||
|
||||
**fonts**
|
||||
The font/fonts which the interface should use.
|
||||
There can be multiple font url parameters: `?font=font-one&font=font-two...`
|
||||
|
||||
```ts
|
||||
font: string;
|
||||
font: string;
|
||||
...
|
||||
```
|
||||
|
||||
**fontScale**
|
||||
The factor by which to scale the interface's font size.
|
||||
|
||||
```ts
|
||||
fontScale: number | null;
|
||||
```
|
||||
|
||||
**analyticsID**
|
||||
The Posthog analytics ID. It is only available if the user has given consent for
|
||||
sharing telemetry in element web.
|
||||
|
||||
```ts
|
||||
analyticsID: string | null;
|
||||
```
|
||||
|
||||
**allowIceFallback**
|
||||
Whether the app is allowed to use fallback STUN servers for ICE in case the
|
||||
user's homeserver doesn't provide any.
|
||||
|
||||
```ts
|
||||
allowIceFallback: boolean; (default: false)
|
||||
```
|
||||
|
||||
**skipLobby**
|
||||
Setting this flag skips the lobby and brings you in the call directly.
|
||||
In the widget this can be combined with preload to pass the device settings
|
||||
with the join widget action.
|
||||
|
||||
```ts
|
||||
skipLobby: boolean; (default: false)
|
||||
```
|
||||
|
||||
**returnToLobby**
|
||||
Setting this flag makes element call show the lobby in widget mode after leaving
|
||||
a call.
|
||||
This is useful for video rooms.
|
||||
If set to false, the widget will show a blank page after leaving the call.
|
||||
|
||||
```ts
|
||||
returnToLobby: boolean; (default: false)
|
||||
```
|
||||
|
||||
**theme**
|
||||
The theme to use for element call.
|
||||
can be "light", "dark", "light-high-contrast" or "dark-high-contrast".
|
||||
If not set element call will use the dark theme.
|
||||
|
||||
```ts
|
||||
theme: string | null;
|
||||
```
|
||||
|
||||
**viaServers**
|
||||
This defines the homeserver that is going to be used when joining a room.
|
||||
It has to be set to a non default value for links to rooms
|
||||
that are not on the default homeserver,
|
||||
that is in use for the current user.
|
||||
|
||||
```ts
|
||||
viaServers: string; (default: undefined)
|
||||
```
|
||||
|
||||
**homeserver**
|
||||
This defines the homeserver that is going to be used when registering
|
||||
a new (guest) user.
|
||||
This can be user to configure a non default guest user server when
|
||||
creating a spa link.
|
||||
|
||||
```ts
|
||||
homeserver: string; (default: undefined)
|
||||
```
|
||||
| Name | Values | Required for widget | Required for SPA | Description |
|
||||
| ------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `allowIceFallback` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Allows use of fallback STUN servers for ICE if the user's homeserver doesn’t provide any. |
|
||||
| `analyticsID` | Posthog analytics ID | No | No | Available only with user's consent for sharing telemetry in Element Web. |
|
||||
| `appPrompt` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Prompts the user to launch the native mobile app upon entering a room, applicable only on Android and iOS, and must be enabled in config. |
|
||||
| `baseUrl` | | Yes | Not applicable | The base URL of the homeserver to use for media lookups. |
|
||||
| `confineToRoom` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Keeps the user confined to the current call/room. |
|
||||
| `deviceId` | Matrix device ID | Yes | Not applicable | The Matrix device ID for the widget host. |
|
||||
| `displayName` | | No | No | Display name used for auto-registration. |
|
||||
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
|
||||
| `fontScale` | A decimal number such as `0.9` | No | No | Factor by which to scale the interface's font size. |
|
||||
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
|
||||
| `hideHeader` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the room header when in a call. |
|
||||
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
|
||||
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
|
||||
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
|
||||
| `parentUrl` | | Yes | Not applicable | The url used to send widget action postMessages. This should be the domain of the client or the webview the widget is hosted in. (in case the widget is not in an Iframe but in a dedicated webview we send the postMessages same WebView the widget lives in. Filtering is done in the widget so it ignores the messages it receives from itself) |
|
||||
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
|
||||
| `perParticipantE2EE` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Enables per participant encryption with Keys exchanged over encrypted matrix room messages. |
|
||||
| `preload` | `true` or `false` | No, defaults to `false` | Not applicable | Pauses app before joining a call until an `io.element.join` widget action is seen, allowing preloading. |
|
||||
| `returnToLobby` | `true` or `false` | No, defaults to `false` | Not applicable | Displays the lobby in widget mode after leaving a call; shows a blank page if set to `false`. Useful for video rooms. |
|
||||
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
|
||||
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
|
||||
| `skipLobby` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. |
|
||||
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
|
||||
| `userId` | [Matrix User Identifier](https://spec.matrix.org/v1.12/appendices/#user-identifiers) | Yes | Not applicable | The Matrix user ID. |
|
||||
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
|
||||
| `widgetId` | [MSC2774](https://github.com/matrix-org/matrix-spec-proposals/pull/2774) format widget ID | Yes | Not applicable | The id used by the widget. The presence of this parameter implies that element call will not connect to a homeserver directly and instead tries to establish postMessage communication via the `parentUrl`. |
|
||||
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
],
|
||||
},
|
||||
locales: ["en-GB"],
|
||||
output: "public/locales/$LOCALE/$NAMESPACE.json",
|
||||
output: "locales/$LOCALE/$NAMESPACE.json",
|
||||
input: ["src/**/*.{ts,tsx}"],
|
||||
sort: true,
|
||||
};
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
"features": ["plural_postfix_us", "filter_untranslated"],
|
||||
"files": [
|
||||
{
|
||||
"pattern": "public/locales/en-GB/*.json",
|
||||
"pattern": "locales/en-GB/*.json",
|
||||
"lang": "inherited"
|
||||
},
|
||||
{
|
||||
"group": "existing",
|
||||
"pattern": "public/locales/*/*.json",
|
||||
"excludes": ["public/locales/en-GB/*.json"],
|
||||
"pattern": "locales/*/*.json",
|
||||
"excludes": ["locales/en-GB/*.json"],
|
||||
"lang": "${autodetectLang}"
|
||||
}
|
||||
]
|
||||
@@ -22,7 +22,7 @@
|
||||
"download": {
|
||||
"files": [
|
||||
{
|
||||
"output": "public/locales/${langLsrDash}/${file}"
|
||||
"output": "locales/${langLsrDash}/${file}"
|
||||
}
|
||||
],
|
||||
"includeSourceLang": "${includeSourceLang|false}",
|
||||
|
||||
@@ -8,9 +8,14 @@
|
||||
"edit": "Bearbeiten",
|
||||
"go": "Los geht’s",
|
||||
"invite": "Einladen",
|
||||
"lower_hand": "Handmeldung zurücknehmen",
|
||||
"no": "Nein",
|
||||
"pick_reaction": "Reaktion auswählen",
|
||||
"raise_hand": "Handmeldung",
|
||||
"register": "Registrieren",
|
||||
"remove": "Entfernen",
|
||||
"show_less": "Weniger anzeigen",
|
||||
"show_more": "Mehr anzeigen",
|
||||
"sign_in": "Anmelden",
|
||||
"sign_out": "Abmelden",
|
||||
"submit": "Absenden",
|
||||
@@ -55,8 +60,10 @@
|
||||
"password": "Passwort",
|
||||
"preferences": "Einstellungen",
|
||||
"profile": "Profil",
|
||||
"raise_hand": "Hand heben",
|
||||
"reaction": "Reaktion",
|
||||
"reactions": "Reaktionen",
|
||||
"settings": "Einstellungen",
|
||||
"something_went_wrong": "Etwas ist schief gelaufen",
|
||||
"unencrypted": "Nicht verschlüsselt",
|
||||
"username": "Benutzername",
|
||||
"video": "Video"
|
||||
@@ -64,12 +71,6 @@
|
||||
"crypto_version": "Krypto-Version:{{version}}",
|
||||
"device_id": "Geräte-ID: {{id}}",
|
||||
"disconnected_banner": "Die Verbindung zum Server wurde getrennt.",
|
||||
"e2ee_encryption_status": {
|
||||
"connecting": "Verbinden...",
|
||||
"key_invalid": "Der Medien-Krypto-Schlüssel für diese Person ist ungültig",
|
||||
"key_missing": "Aktueller Medien-Krypto-Schlüssel für diese Person noch nicht erhalten",
|
||||
"password_invalid": "Diese Person verwendet ein anderes Passwort, sodass Sie nicht mit ihr kommunizieren können"
|
||||
},
|
||||
"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": {
|
||||
@@ -79,8 +80,8 @@
|
||||
"call_ended_heading": "Anruf beendet",
|
||||
"failed_heading": "Beitreten fehlgeschlagen",
|
||||
"failed_text": "Anruf nicht gefunden oder Beitritt nicht erlaubt",
|
||||
"knock_reject_body": "Die Mitglieder des Raums haben Deine Beitrittsanfrage abgelehnt.",
|
||||
"knock_reject_heading": "Beitritt nicht erlaubt",
|
||||
"knock_reject_body": "Die Teilnahmeanfrage wurde abgelehnt.",
|
||||
"knock_reject_heading": "Zugriff verweigert",
|
||||
"reason": "Grund"
|
||||
},
|
||||
"hangup_button_label": "Anruf beenden",
|
||||
@@ -98,11 +99,11 @@
|
||||
"layout_grid_label": "Raster",
|
||||
"layout_spotlight_label": "Fokus",
|
||||
"lobby": {
|
||||
"ask_to_join": "Beitritt anfragen",
|
||||
"ask_to_join": "Teilnahmeanfrage senden",
|
||||
"join_as_guest": "Als Gast beitreten",
|
||||
"join_button": "Anruf beitreten",
|
||||
"leave_button": "Zurück zu kürzlichen Anrufen",
|
||||
"waiting_for_invite": "Anfrage gesendet"
|
||||
"waiting_for_invite": "Anfrage gesendet! Warten auf Teilnahmefreigabe …"
|
||||
},
|
||||
"log_in": "Anmelden",
|
||||
"logging_in": "Anmelden …",
|
||||
@@ -113,7 +114,7 @@
|
||||
"matrix_id": "Matrix-ID: {{id}}",
|
||||
"microphone_off": "Mikrofon aus",
|
||||
"microphone_on": "Mikrofon an",
|
||||
"mute_microphone_button_label": "Mikrofon deaktivieren",
|
||||
"mute_microphone_button_label": "Mikrofon stumm schalten",
|
||||
"participant_count_one": "{{count, number}}",
|
||||
"participant_count_other": "{{count, number}}",
|
||||
"qr_code": "QR-Code",
|
||||
@@ -141,6 +142,10 @@
|
||||
"room_auth_view_eula_caption": "Mit einem Klick auf „Weiter“ akzeptierst du unseren <2>Endbenutzer-Lizenzvertrag (EULA)</2>",
|
||||
"screenshare_button_label": "Bildschirm teilen",
|
||||
"settings": {
|
||||
"audio_tab": {
|
||||
"effect_volume_description": "Lautstärke anpassen, mit der Reaktionen und Handmeldungen abgespielt werden",
|
||||
"effect_volume_label": "Lautstärke der Soundeffekte"
|
||||
},
|
||||
"developer_settings_label": "Entwicklereinstellungen",
|
||||
"developer_settings_label_description": "Zeige die Entwicklereinstellungen im Einstellungsfenster.",
|
||||
"developer_tab_title": "Entwickler",
|
||||
@@ -153,10 +158,17 @@
|
||||
"feedback_tab_title": "Rückmeldung",
|
||||
"more_tab_title": "Mehr",
|
||||
"opt_in_description": "<0></0><1></1>Du kannst deine Zustimmung durch Abwählen dieses Kästchens zurückziehen. Falls du dich aktuell in einem Anruf befindest, wird diese Einstellung nach dem Ende des Anrufs wirksam.",
|
||||
"preferences_tab": {
|
||||
"reactions_play_sound_description": "Einen Soundeffekt abspielen, wenn jemand eine Reaktion sendet",
|
||||
"reactions_play_sound_label": "Reaktionstöne abspielen",
|
||||
"reactions_show_description": "Zeige eine Animation, wenn jemand eine Reaktion sendet.",
|
||||
"reactions_show_label": "Reaktionen anzeigen",
|
||||
"reactions_title": "Reaktionen"
|
||||
},
|
||||
"preferences_tab_body": "Hier können zusätzliche Optionen für individuelle Anforderungen eingestellt werden",
|
||||
"preferences_tab_h4": "Einstellungen",
|
||||
"preferences_tab_show_hand_raised_timer_description": "Einen Timer anzeigen, wenn ein Teilnehmer seine Hand hebt",
|
||||
"preferences_tab_show_hand_raised_timer_label": "Dauer des Handhebens anzeigen",
|
||||
"preferences_tab_show_hand_raised_timer_description": "Einen Timer zur Handmeldung anzeigen",
|
||||
"preferences_tab_show_hand_raised_timer_label": "Dauer der Handmeldung anzeigen",
|
||||
"speaker_device_selection_label": "Lautsprecher"
|
||||
},
|
||||
"star_rating_input_label_one": "{{count}} Stern",
|
||||
@@ -170,14 +182,15 @@
|
||||
"unauthenticated_view_body": "Noch nicht registriert? <2>Konto erstellen</2>",
|
||||
"unauthenticated_view_eula_caption": "Mit einem Klick auf „Los geht’s“ akzeptierst du unseren <2>Endbenutzer-Lizenzvertrag (EULA)</2>",
|
||||
"unauthenticated_view_login_button": "Melde dich mit deinem Konto an",
|
||||
"unmute_microphone_button_label": "Mikrofon aktivieren",
|
||||
"unmute_microphone_button_label": "Mikrofon einschalten",
|
||||
"version": "{{productName}} Version: {{version}}",
|
||||
"video_tile": {
|
||||
"always_show": "Immer anzeigen",
|
||||
"change_fit_contain": "An Fenster anpassen",
|
||||
"collapse": "Minimieren",
|
||||
"expand": "Erweitern",
|
||||
"mute_for_me": "Für mich stummschalten",
|
||||
"mute_for_me": "Für mich stumm schalten",
|
||||
"muted_for_me": "Für mich stumm geschaltet",
|
||||
"volume": "Lautstärke"
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,14 @@
|
||||
"edit": "Edit",
|
||||
"go": "Go",
|
||||
"invite": "Invite",
|
||||
"lower_hand": "Lower hand",
|
||||
"no": "No",
|
||||
"pick_reaction": "Pick reaction",
|
||||
"raise_hand": "Raise hand",
|
||||
"register": "Register",
|
||||
"remove": "Remove",
|
||||
"show_less": "Show less",
|
||||
"show_more": "Show more",
|
||||
"sign_in": "Sign in",
|
||||
"sign_out": "Sign out",
|
||||
"submit": "Submit",
|
||||
@@ -55,8 +60,10 @@
|
||||
"password": "Password",
|
||||
"preferences": "Preferences",
|
||||
"profile": "Profile",
|
||||
"raise_hand": "Raise hand",
|
||||
"reaction": "Reaction",
|
||||
"reactions": "Reactions",
|
||||
"settings": "Settings",
|
||||
"something_went_wrong": "Something went wrong",
|
||||
"unencrypted": "Not encrypted",
|
||||
"username": "Username",
|
||||
"video": "Video"
|
||||
@@ -64,12 +71,6 @@
|
||||
"crypto_version": "Crypto version: {{version}}",
|
||||
"device_id": "Device ID: {{id}}",
|
||||
"disconnected_banner": "Connectivity to the server has been lost.",
|
||||
"e2ee_encryption_status": {
|
||||
"connecting": "Connecting...",
|
||||
"key_invalid": "The end-to-end encrypted media key for this person is invalid",
|
||||
"key_missing": "You haven't received the current end-to-end encrypted media key for this person yet",
|
||||
"password_invalid": "This person is using a different password so you won't be able to communicate with them"
|
||||
},
|
||||
"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>",
|
||||
"group_call_loader": {
|
||||
@@ -79,8 +80,8 @@
|
||||
"call_ended_heading": "Call ended",
|
||||
"failed_heading": "Failed to join",
|
||||
"failed_text": "Call not found or is not accessible.",
|
||||
"knock_reject_body": "The room members declined your request to join.",
|
||||
"knock_reject_heading": "Not allowed to join",
|
||||
"knock_reject_body": "Your request to join was declined.",
|
||||
"knock_reject_heading": "Access denied",
|
||||
"reason": "Reason"
|
||||
},
|
||||
"hangup_button_label": "End call",
|
||||
@@ -98,11 +99,11 @@
|
||||
"layout_grid_label": "Grid",
|
||||
"layout_spotlight_label": "Spotlight",
|
||||
"lobby": {
|
||||
"ask_to_join": "Ask to join call",
|
||||
"ask_to_join": "Request to join call",
|
||||
"join_as_guest": "Join as guest",
|
||||
"join_button": "Join call",
|
||||
"leave_button": "Back to recents",
|
||||
"waiting_for_invite": "Request sent"
|
||||
"waiting_for_invite": "Request sent! Waiting for permission to join…"
|
||||
},
|
||||
"log_in": "Log In",
|
||||
"logging_in": "Logging in…",
|
||||
@@ -141,6 +142,10 @@
|
||||
"room_auth_view_eula_caption": "By clicking \"Continue\", you agree to our <2>End User Licensing Agreement (EULA)</2>",
|
||||
"screenshare_button_label": "Share screen",
|
||||
"settings": {
|
||||
"audio_tab": {
|
||||
"effect_volume_description": "Adjust the volume at which reactions and hand raised effects play",
|
||||
"effect_volume_label": "Sound effect volume"
|
||||
},
|
||||
"developer_settings_label": "Developer Settings",
|
||||
"developer_settings_label_description": "Expose developer settings in the settings window.",
|
||||
"developer_tab_title": "Developer",
|
||||
@@ -153,13 +158,20 @@
|
||||
"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.",
|
||||
"preferences_tab": {
|
||||
"reactions_play_sound_description": "Play a sound effect when anyone sends a reaction into a call.",
|
||||
"reactions_play_sound_label": "Play reaction sounds",
|
||||
"reactions_show_description": "Show an animation when anyone sends a reaction.",
|
||||
"reactions_show_label": "Show reactions",
|
||||
"reactions_title": "Reactions"
|
||||
},
|
||||
"preferences_tab_body": "Here you can configure extra options for an improved experience",
|
||||
"preferences_tab_h4": "Preferences",
|
||||
"preferences_tab_show_hand_raised_timer_description": "Show a timer when a participant raises their hand",
|
||||
"preferences_tab_show_hand_raised_timer_label": "Show hand raise duration",
|
||||
"speaker_device_selection_label": "Speaker"
|
||||
},
|
||||
"star_rating_input_label_one": "{{count}} stars",
|
||||
"star_rating_input_label_one": "{{count}} star",
|
||||
"star_rating_input_label_other": "{{count}} stars",
|
||||
"start_new_call": "Start new call",
|
||||
"start_video_button_label": "Start video",
|
||||
@@ -178,6 +190,7 @@
|
||||
"collapse": "Collapse",
|
||||
"expand": "Expand",
|
||||
"mute_for_me": "Mute for me",
|
||||
"muted_for_me": "Muted for me",
|
||||
"volume": "Volume"
|
||||
}
|
||||
}
|
||||
26
package.json
26
package.json
@@ -17,19 +17,23 @@
|
||||
"i18n:check": "i18next --fail-on-warnings --fail-on-update",
|
||||
"test": "vitest",
|
||||
"test:coverage": "vitest --coverage",
|
||||
"backend": "docker-compose -f backend-docker-compose.yml up"
|
||||
"backend": "docker-compose -f dev-backend-docker-compose.yml up"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.16.5",
|
||||
"@babel/preset-env": "^7.22.20",
|
||||
"@babel/preset-react": "^7.22.15",
|
||||
"@babel/preset-typescript": "^7.23.0",
|
||||
"@codecov/vite-plugin": "^1.3.0",
|
||||
"@fontsource/inconsolata": "^5.1.0",
|
||||
"@fontsource/inter": "^5.1.0",
|
||||
"@formatjs/intl-durationformat": "^0.6.1",
|
||||
"@formatjs/intl-segmenter": "^11.7.3",
|
||||
"@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.54.0",
|
||||
"@opentelemetry/exporter-trace-otlp-http": "^0.55.0",
|
||||
"@opentelemetry/resources": "^1.25.1",
|
||||
"@opentelemetry/sdk-trace-base": "^1.25.1",
|
||||
"@opentelemetry/sdk-trace-web": "^1.9.1",
|
||||
@@ -41,14 +45,16 @@
|
||||
"@sentry/react": "^8.0.0",
|
||||
"@sentry/vite-plugin": "^2.0.0",
|
||||
"@testing-library/dom": "^10.1.0",
|
||||
"@testing-library/jest-dom": "^6.6.3",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@testing-library/react-hooks": "^8.0.1",
|
||||
"@testing-library/user-event": "^14.5.1",
|
||||
"@types/content-type": "^1.1.5",
|
||||
"@types/grecaptcha": "^3.0.9",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/lodash": "^4.14.199",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.0.0",
|
||||
"@types/pako": "^2.0.3",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
@@ -57,8 +63,8 @@
|
||||
"@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",
|
||||
"@vector-im/compound-design-tokens": "^1.9.1",
|
||||
"@vector-im/compound-web": "^7.2.0",
|
||||
"@vitejs/plugin-basic-ssl": "^1.0.1",
|
||||
"@vitejs/plugin-react": "^4.0.1",
|
||||
"@vitest/coverage-v8": "^2.0.5",
|
||||
@@ -79,15 +85,14 @@
|
||||
"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.5.7",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"loglevel": "^1.9.1",
|
||||
"matrix-js-sdk": "matrix-org/matrix-js-sdk#623b40177a71a2b719762bebe51528f3d8c8ca9e",
|
||||
"matrix-widget-api": "^1.8.2",
|
||||
"matrix-js-sdk": "matrix-org/matrix-js-sdk#2210255d6ffc909c574fb8ef16f92140b2fb7797",
|
||||
"matrix-widget-api": "^1.10.0",
|
||||
"normalize.css": "^8.0.1",
|
||||
"observable-hooks": "^4.2.3",
|
||||
"pako": "^2.0.4",
|
||||
@@ -107,8 +112,9 @@
|
||||
"typescript": "^5.1.6",
|
||||
"typescript-eslint-language-service": "^5.0.5",
|
||||
"unique-names-generator": "^4.6.0",
|
||||
"vaul": "^0.9.0",
|
||||
"vaul": "^1.0.0",
|
||||
"vite": "^5.0.0",
|
||||
"vite-plugin-compression2": "^1.3.1",
|
||||
"vite-plugin-html-template": "^1.1.0",
|
||||
"vite-plugin-svgr": "^4.0.0",
|
||||
"vitest": "^2.0.0",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"applinks": {
|
||||
"details": [
|
||||
{
|
||||
"appIDs": [
|
||||
"7J4U792NQT.io.element.elementx",
|
||||
"7J4U792NQT.io.element.elementx.nightly",
|
||||
"7J4U792NQT.io.element.elementx.pr"
|
||||
],
|
||||
"components": [
|
||||
{
|
||||
"?": {
|
||||
"no_universal_links": "?*"
|
||||
},
|
||||
"exclude": true,
|
||||
"comment": "Opt out of universal links"
|
||||
},
|
||||
{
|
||||
"/": "/*",
|
||||
"comment": "Matches any URL"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
[
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "io.element.android.x.debug",
|
||||
"sha256_cert_fingerprints": [
|
||||
"B0:B0:51:DC:56:5C:81:2F:E1:7F:6F:3E:94:5B:4D:79:04:71:23:AB:0D:A6:12:86:76:9E:B2:94:91:97:13:0E"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "io.element.android.x.nightly",
|
||||
"sha256_cert_fingerprints": [
|
||||
"CA:D3:85:16:84:3A:05:CC:EB:00:AB:7B:D3:80:0F:01:BA:8F:E0:4B:38:86:F3:97:D8:F7:9A:1B:C4:54:E4:0F"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "io.element.android.x",
|
||||
"sha256_cert_fingerprints": [
|
||||
"C6:DB:9B:9C:8C:BD:D6:5D:16:E8:EC:8C:8B:91:C8:31:B9:EF:C9:5C:BF:98:AE:41:F6:A9:D8:35:15:1A:7E:16"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="favicon.png" />
|
||||
<link rel="preload" href="/config.json" as="fetch" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:base"],
|
||||
"extends": ["config:recommended"],
|
||||
"packageRules": [
|
||||
{
|
||||
"groupName": "all non-major dependencies",
|
||||
@@ -26,8 +26,8 @@
|
||||
},
|
||||
{
|
||||
"groupName": "Compound",
|
||||
"matchPackagePrefixes": ["@vector-im/compound-"],
|
||||
"schedule": "before 5am on Tuesday and Friday"
|
||||
"schedule": "before 5am on Tuesday and Friday",
|
||||
"matchPackageNames": ["@vector-im/compound-{/,}**"]
|
||||
},
|
||||
{
|
||||
"groupName": "LiveKit client",
|
||||
@@ -35,7 +35,7 @@
|
||||
},
|
||||
{
|
||||
"groupName": "LiveKit components",
|
||||
"matchPackagePrefixes": ["@livekit/components-"]
|
||||
"matchPackageNames": ["@livekit/components-{/,}**"]
|
||||
},
|
||||
{
|
||||
"groupName": "Vaul",
|
||||
|
||||
6
src/@types/global.d.ts
vendored
6
src/@types/global.d.ts
vendored
@@ -6,6 +6,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import "matrix-js-sdk/src/@types/global";
|
||||
import type { DurationFormat as PolyfillDurationFormat } from "@formatjs/intl-durationformat";
|
||||
import { Controls } from "../controls";
|
||||
|
||||
declare global {
|
||||
@@ -23,4 +24,9 @@ declare global {
|
||||
// Safari only supports this prefixed, so tell the type system about it
|
||||
webkitRequestFullscreen: () => void;
|
||||
}
|
||||
|
||||
namespace Intl {
|
||||
// Add DurationFormat as part of the Intl namespace because we polyfill it
|
||||
const DurationFormat: typeof PolyfillDurationFormat;
|
||||
}
|
||||
}
|
||||
|
||||
2
src/@types/i18next.d.ts
vendored
2
src/@types/i18next.d.ts
vendored
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import "i18next";
|
||||
// import all namespaces (for the default language, only)
|
||||
import app from "../../public/locales/en-GB/app.json";
|
||||
import app from "../../locales/en-GB/app.json";
|
||||
|
||||
declare module "i18next" {
|
||||
interface CustomTypeOptions {
|
||||
|
||||
18
src/@types/matrix-js-sdk.d.ts
vendored
Normal file
18
src/@types/matrix-js-sdk.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import {
|
||||
ElementCallReactionEventType,
|
||||
ECallReactionEventContent,
|
||||
} from "../reactions";
|
||||
|
||||
// Extend Matrix JS SDK types via Typescript declaration merging to support unspecced event fields and types
|
||||
declare module "matrix-js-sdk/src/types" {
|
||||
export interface TimelineEvents {
|
||||
[ElementCallReactionEventType]: ECallReactionEventContent;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { useMemo, FC } from "react";
|
||||
import { useMemo, FC, CSSProperties } from "react";
|
||||
import { Avatar as CompoundAvatar } from "@vector-im/compound-web";
|
||||
|
||||
import { getAvatarUrl } from "./utils/matrix";
|
||||
@@ -33,6 +33,7 @@ interface Props {
|
||||
className?: string;
|
||||
src?: string;
|
||||
size?: Size | number;
|
||||
style?: CSSProperties;
|
||||
}
|
||||
|
||||
export const Avatar: FC<Props> = ({
|
||||
@@ -41,6 +42,8 @@ export const Avatar: FC<Props> = ({
|
||||
name,
|
||||
src,
|
||||
size = Size.MD,
|
||||
style,
|
||||
...props
|
||||
}) => {
|
||||
const { client } = useClient();
|
||||
|
||||
@@ -64,6 +67,8 @@ export const Avatar: FC<Props> = ({
|
||||
name={name}
|
||||
size={`${sizePx}px`}
|
||||
src={resolvedSrc}
|
||||
style={style}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -16,19 +16,13 @@ import {
|
||||
useMemo,
|
||||
} from "react";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import {
|
||||
ClientEvent,
|
||||
ICreateClientOpts,
|
||||
MatrixClient,
|
||||
} from "matrix-js-sdk/src/client";
|
||||
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 { WidgetApi } from "matrix-widget-api";
|
||||
import { ClientEvent, type MatrixClient } from "matrix-js-sdk/src/client";
|
||||
|
||||
import type { WidgetApi } from "matrix-widget-api";
|
||||
import { ErrorView } from "./FullScreenView";
|
||||
import { fallbackICEServerAllowed, initClient } from "./utils/matrix";
|
||||
import { widget } from "./widget";
|
||||
import {
|
||||
PosthogAnalytics,
|
||||
@@ -36,7 +30,6 @@ import {
|
||||
} from "./analytics/PosthogAnalytics";
|
||||
import { translatedError } from "./TranslatedError";
|
||||
import { useEventTarget } from "./useEvents";
|
||||
import { Config } from "./config/Config";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -359,7 +352,7 @@ export const ClientProvider: FC<Props> = ({ children }) => {
|
||||
);
|
||||
};
|
||||
|
||||
type InitResult = {
|
||||
export type InitResult = {
|
||||
widgetApi: WidgetApi | null;
|
||||
client: MatrixClient;
|
||||
passwordlessUser: boolean;
|
||||
@@ -376,50 +369,8 @@ async function loadClient(): Promise<InitResult | null> {
|
||||
passwordlessUser: false,
|
||||
};
|
||||
} else {
|
||||
// We're running as a standalone application
|
||||
try {
|
||||
const session = loadSession();
|
||||
if (!session) {
|
||||
logger.log("No session stored; continuing without a client");
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.log("Using a standalone client");
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
const { user_id, device_id, access_token, passwordlessUser } = session;
|
||||
const initClientParams: ICreateClientOpts = {
|
||||
baseUrl: Config.defaultHomeserverUrl()!,
|
||||
accessToken: access_token,
|
||||
userId: user_id,
|
||||
deviceId: device_id,
|
||||
fallbackICEServerAllowed: fallbackICEServerAllowed,
|
||||
livekitServiceURL: Config.get().livekit?.livekit_service_url,
|
||||
};
|
||||
|
||||
try {
|
||||
const client = await initClient(initClientParams, true);
|
||||
return {
|
||||
widgetApi: null,
|
||||
client,
|
||||
passwordlessUser,
|
||||
};
|
||||
} catch (err) {
|
||||
if (err instanceof MatrixError && err.errcode === "M_UNKNOWN_TOKEN") {
|
||||
// We can't use this session anymore, so let's log it out
|
||||
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;
|
||||
}
|
||||
} catch (err) {
|
||||
clearSession();
|
||||
throw err;
|
||||
}
|
||||
const { initSPA } = await import("./utils/spa");
|
||||
return initSPA(loadSession, clearSession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
.modal {
|
||||
--inset-inline: 520px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ Please see LICENSE in the repository root for full details.
|
||||
.drawer {
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
inset-block-end: 0;
|
||||
inset-inline: max(0px, calc((100% - 520px) / 2));
|
||||
inset-inline: max(0px, calc((100% - var(--inset-inline)) / 2));
|
||||
max-block-size: 90%;
|
||||
border-start-start-radius: var(--border-radius);
|
||||
border-start-end-radius: var(--border-radius);
|
||||
|
||||
73
src/Modal.test.tsx
Normal file
73
src/Modal.test.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { expect, test } from "vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { ReactNode, useState } from "react";
|
||||
import { afterEach } from "node:test";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
import { Modal } from "./Modal";
|
||||
|
||||
const originalMatchMedia = window.matchMedia;
|
||||
afterEach(() => {
|
||||
window.matchMedia = originalMatchMedia;
|
||||
});
|
||||
|
||||
test("that nothing is rendered when the modal is closed", () => {
|
||||
const { queryByRole } = render(
|
||||
<Modal title="My modal" open={false}>
|
||||
<p>This is the content.</p>
|
||||
</Modal>,
|
||||
);
|
||||
expect(queryByRole("dialog")).toBeNull();
|
||||
});
|
||||
|
||||
test("the content is rendered when the modal is open", () => {
|
||||
const { queryByRole } = render(
|
||||
<Modal title="My modal" open={true}>
|
||||
<p>This is the content.</p>
|
||||
</Modal>,
|
||||
);
|
||||
expect(queryByRole("dialog")).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("the modal can be closed by clicking the close button", async () => {
|
||||
function ModalFn(): ReactNode {
|
||||
const [isOpen, setOpen] = useState(true);
|
||||
return (
|
||||
<Modal title="My modal" open={isOpen} onDismiss={() => setOpen(false)}>
|
||||
<p>This is the content.</p>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
const user = userEvent.setup();
|
||||
const { queryByRole, getByRole } = render(<ModalFn />);
|
||||
await user.click(getByRole("button", { name: "action.close" }));
|
||||
expect(queryByRole("dialog")).toBeNull();
|
||||
});
|
||||
|
||||
test("the modal renders as a drawer in mobile viewports", () => {
|
||||
window.matchMedia = function (query): MediaQueryList {
|
||||
return {
|
||||
matches: query.includes("hover: none"),
|
||||
addEventListener(): MediaQueryList {
|
||||
return this as MediaQueryList;
|
||||
},
|
||||
removeEventListener(): MediaQueryList {
|
||||
return this as MediaQueryList;
|
||||
},
|
||||
} as unknown as MediaQueryList;
|
||||
};
|
||||
|
||||
const { queryByRole } = render(
|
||||
<Modal title="My modal" open={true}>
|
||||
<p>This is the content.</p>
|
||||
</Modal>,
|
||||
);
|
||||
expect(queryByRole("dialog")).toMatchSnapshot();
|
||||
});
|
||||
@@ -27,8 +27,21 @@ import { useMediaQuery } from "./useMediaQuery";
|
||||
|
||||
export interface Props {
|
||||
title: string;
|
||||
/**
|
||||
* Hide the modal header. Used for smaller popups where the context is readily apparent.
|
||||
* A title should still be specified for users using assistive technology.
|
||||
*/
|
||||
hideHeader?: boolean;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
/**
|
||||
* Class name to be used when in drawer mode (touchscreen).
|
||||
*/
|
||||
classNameDrawer?: string;
|
||||
/**
|
||||
* Class name to be used when in modal mode (desktop).
|
||||
*/
|
||||
classNameModal?: string;
|
||||
/**
|
||||
* The controlled open state of the modal.
|
||||
*/
|
||||
@@ -54,8 +67,11 @@ export interface Props {
|
||||
*/
|
||||
export const Modal: FC<Props> = ({
|
||||
title,
|
||||
hideHeader,
|
||||
children,
|
||||
className,
|
||||
classNameDrawer,
|
||||
classNameModal,
|
||||
open,
|
||||
onDismiss,
|
||||
tabbed,
|
||||
@@ -84,11 +100,13 @@ export const Modal: FC<Props> = ({
|
||||
<Drawer.Content
|
||||
className={classNames(
|
||||
className,
|
||||
classNameDrawer,
|
||||
overlayStyles.overlay,
|
||||
styles.modal,
|
||||
styles.drawer,
|
||||
{ [styles.tabbed]: tabbed },
|
||||
)}
|
||||
role="dialog"
|
||||
// Suppress the warning about there being no description; the modal
|
||||
// has an accessible title
|
||||
aria-describedby={undefined}
|
||||
@@ -108,18 +126,46 @@ export const Modal: FC<Props> = ({
|
||||
</Drawer.Root>
|
||||
);
|
||||
} else {
|
||||
const titleNode = (
|
||||
<DialogTitle asChild>
|
||||
<Heading as="h2" weight="semibold" size="md">
|
||||
{title}
|
||||
</Heading>
|
||||
</DialogTitle>
|
||||
);
|
||||
const header = (
|
||||
<div className={styles.header}>
|
||||
{titleNode}
|
||||
{onDismiss !== undefined && (
|
||||
<DialogClose
|
||||
className={styles.close}
|
||||
data-testid="modal_close"
|
||||
aria-label={t("action.close")}
|
||||
>
|
||||
<CloseIcon width={20} height={20} />
|
||||
</DialogClose>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<DialogRoot open={open} onOpenChange={onOpenChange}>
|
||||
<DialogPortal>
|
||||
<DialogOverlay
|
||||
className={classNames(overlayStyles.bg, overlayStyles.animate)}
|
||||
/>
|
||||
{/* Suppress the warning about there being no description; the modal
|
||||
has an accessible title */}
|
||||
<DialogContent asChild aria-describedby={undefined} {...rest}>
|
||||
<DialogContent
|
||||
asChild
|
||||
// Suppress the warning about there being no description; the modal
|
||||
// has an accessible title
|
||||
aria-describedby={undefined}
|
||||
role="dialog"
|
||||
{...rest}
|
||||
>
|
||||
<Glass
|
||||
className={classNames(
|
||||
className,
|
||||
classNameModal,
|
||||
overlayStyles.overlay,
|
||||
overlayStyles.animate,
|
||||
styles.modal,
|
||||
@@ -128,22 +174,10 @@ export const Modal: FC<Props> = ({
|
||||
)}
|
||||
>
|
||||
<div className={styles.content}>
|
||||
<div className={styles.header}>
|
||||
<DialogTitle asChild>
|
||||
<Heading as="h2" weight="semibold" size="md">
|
||||
{title}
|
||||
</Heading>
|
||||
</DialogTitle>
|
||||
{onDismiss !== undefined && (
|
||||
<DialogClose
|
||||
className={styles.close}
|
||||
data-testid="modal_close"
|
||||
aria-label={t("action.close")}
|
||||
>
|
||||
<CloseIcon width={20} height={20} />
|
||||
</DialogClose>
|
||||
)}
|
||||
</div>
|
||||
{!hideHeader ? header : null}
|
||||
{hideHeader ? (
|
||||
<VisuallyHidden asChild>{titleNode}</VisuallyHidden>
|
||||
) : null}
|
||||
<div className={styles.body}>{children}</div>
|
||||
</div>
|
||||
</Glass>
|
||||
|
||||
@@ -42,8 +42,9 @@ Please see LICENSE in the repository root for full details.
|
||||
}
|
||||
|
||||
.overlay.animate {
|
||||
--overlay-top: 50%;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
top: var(--overlay-top);
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ Please see LICENSE in the repository root for full details.
|
||||
import { FC, useCallback } from "react";
|
||||
import { Root, Track, Range, Thumb } from "@radix-ui/react-slider";
|
||||
import classNames from "classnames";
|
||||
import { Tooltip } from "@vector-im/compound-web";
|
||||
|
||||
import styles from "./Slider.module.css";
|
||||
|
||||
@@ -66,7 +67,10 @@ export const Slider: FC<Props> = ({
|
||||
<Track className={styles.track}>
|
||||
<Range className={styles.highlight} />
|
||||
</Track>
|
||||
<Thumb className={styles.handle} aria-label={label} />
|
||||
{/* Note: This is expected not to be visible on mobile.*/}
|
||||
<Tooltip placement="top" label={Math.round(value * 100).toString() + "%"}>
|
||||
<Thumb className={styles.handle} aria-label={label} />
|
||||
</Tooltip>
|
||||
</Root>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { getRoomIdentifierFromUrl } from "../src/UrlParams";
|
||||
import { getRoomIdentifierFromUrl, getUrlParams } from "../src/UrlParams";
|
||||
|
||||
const ROOM_NAME = "roomNameHere";
|
||||
const ROOM_ID = "!d45f138fsd";
|
||||
@@ -86,4 +86,18 @@ describe("UrlParams", () => {
|
||||
.roomAlias,
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
describe("preload", () => {
|
||||
it("defaults to false", () => {
|
||||
expect(getUrlParams().preload).toBe(false);
|
||||
});
|
||||
|
||||
it("ignored in SPA mode", () => {
|
||||
expect(getUrlParams("?preload=true").preload).toBe(false);
|
||||
});
|
||||
|
||||
it("respected in widget mode", () => {
|
||||
expect(getUrlParams("?preload=true&widgetId=12345").preload).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -211,8 +211,11 @@ export const getUrlParams = (
|
||||
|
||||
const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
|
||||
|
||||
const widgetId = parser.getParam("widgetId");
|
||||
const isWidget = !!widgetId;
|
||||
|
||||
return {
|
||||
widgetId: parser.getParam("widgetId"),
|
||||
widgetId,
|
||||
parentUrl: parser.getParam("parentUrl"),
|
||||
|
||||
// NB. we don't validate roomId here as we do in getRoomIdentifierFromUrl:
|
||||
@@ -224,7 +227,7 @@ export const getUrlParams = (
|
||||
confineToRoom:
|
||||
parser.getFlagParam("confineToRoom") || parser.getFlagParam("embed"),
|
||||
appPrompt: parser.getFlagParam("appPrompt", true),
|
||||
preload: parser.getFlagParam("preload"),
|
||||
preload: isWidget ? parser.getFlagParam("preload") : false,
|
||||
hideHeader: parser.getFlagParam("hideHeader"),
|
||||
showControls: parser.getFlagParam("showControls", true),
|
||||
hideScreensharing: parser.getFlagParam("hideScreensharing"),
|
||||
|
||||
78
src/__snapshots__/Modal.test.tsx.snap
Normal file
78
src/__snapshots__/Modal.test.tsx.snap
Normal file
@@ -0,0 +1,78 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`the content is rendered when the modal is open 1`] = `
|
||||
<div
|
||||
aria-labelledby="radix-:r4:"
|
||||
class="overlay animate modal dialog _glass_1x9g9_17"
|
||||
data-state="open"
|
||||
id="radix-:r3:"
|
||||
role="dialog"
|
||||
style="pointer-events: auto;"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="content"
|
||||
>
|
||||
<div
|
||||
class="header"
|
||||
>
|
||||
<h2
|
||||
class="_typography_yh5dq_162 _font-heading-md-semibold_yh5dq_121"
|
||||
id="radix-:r4:"
|
||||
>
|
||||
My modal
|
||||
</h2>
|
||||
</div>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
<p>
|
||||
This is the content.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`the modal renders as a drawer in mobile viewports 1`] = `
|
||||
<div
|
||||
aria-labelledby="radix-:ra:"
|
||||
class="overlay modal drawer"
|
||||
data-state="open"
|
||||
data-vaul-animate="true"
|
||||
data-vaul-custom-container="false"
|
||||
data-vaul-delayed-snap-points="false"
|
||||
data-vaul-drawer=""
|
||||
data-vaul-drawer-direction="bottom"
|
||||
data-vaul-snap-points="false"
|
||||
id="radix-:r9:"
|
||||
role="dialog"
|
||||
style="pointer-events: auto;"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="content"
|
||||
>
|
||||
<div
|
||||
class="header"
|
||||
>
|
||||
<div
|
||||
class="handle"
|
||||
/>
|
||||
<h2
|
||||
id="radix-:ra:"
|
||||
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
|
||||
>
|
||||
My modal
|
||||
</h2>
|
||||
</div>
|
||||
<div
|
||||
class="body"
|
||||
>
|
||||
<p>
|
||||
This is the content.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { Button as CpdButton, Tooltip } from "@vector-im/compound-web";
|
||||
import {
|
||||
ComponentPropsWithoutRef,
|
||||
FC,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { EventType, RelationType } from "matrix-js-sdk/src/matrix";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
|
||||
|
||||
import { useReactions } from "../useReactions";
|
||||
import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships";
|
||||
|
||||
interface InnerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
raised: boolean;
|
||||
}
|
||||
|
||||
const InnerButton: FC<InnerButtonProps> = ({ raised, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Tooltip label={t("common.raise_hand")}>
|
||||
<CpdButton
|
||||
kind={raised ? "primary" : "secondary"}
|
||||
{...props}
|
||||
style={{ paddingLeft: 8, paddingRight: 8 }}
|
||||
>
|
||||
<p
|
||||
role="img"
|
||||
aria-hidden
|
||||
style={{
|
||||
width: "30px",
|
||||
height: "0px",
|
||||
display: "inline-block",
|
||||
fontSize: "22px",
|
||||
}}
|
||||
>
|
||||
✋
|
||||
</p>
|
||||
</CpdButton>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
interface RaisedHandToggleButtonProps {
|
||||
rtcSession: MatrixRTCSession;
|
||||
client: MatrixClient;
|
||||
}
|
||||
|
||||
export function RaiseHandToggleButton({
|
||||
client,
|
||||
rtcSession,
|
||||
}: RaisedHandToggleButtonProps): ReactNode {
|
||||
const { raisedHands, lowerHand } = useReactions();
|
||||
const [busy, setBusy] = useState(false);
|
||||
const userId = client.getUserId()!;
|
||||
const isHandRaised = !!raisedHands[userId];
|
||||
const memberships = useMatrixRTCSessionMemberships(rtcSession);
|
||||
|
||||
const toggleRaisedHand = useCallback(() => {
|
||||
const raiseHand = async (): Promise<void> => {
|
||||
if (isHandRaised) {
|
||||
try {
|
||||
setBusy(true);
|
||||
await lowerHand();
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
} else {
|
||||
const myMembership = memberships.find((m) => m.sender === userId);
|
||||
if (!myMembership?.eventId) {
|
||||
logger.error("Cannot find own membership event");
|
||||
return;
|
||||
}
|
||||
const parentEventId = myMembership.eventId;
|
||||
try {
|
||||
setBusy(true);
|
||||
const reaction = await client.sendEvent(
|
||||
rtcSession.room.roomId,
|
||||
EventType.Reaction,
|
||||
{
|
||||
"m.relates_to": {
|
||||
rel_type: RelationType.Annotation,
|
||||
event_id: parentEventId,
|
||||
key: "🖐️",
|
||||
},
|
||||
},
|
||||
);
|
||||
logger.debug("Sent raise hand event", reaction.event_id);
|
||||
} catch (ex) {
|
||||
logger.error("Failed to send reaction event", ex);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void raiseHand();
|
||||
}, [
|
||||
client,
|
||||
isHandRaised,
|
||||
memberships,
|
||||
rtcSession.room.roomId,
|
||||
userId,
|
||||
lowerHand,
|
||||
]);
|
||||
|
||||
return (
|
||||
<InnerButton
|
||||
disabled={busy}
|
||||
onClick={toggleRaisedHand}
|
||||
raised={isHandRaised}
|
||||
/>
|
||||
);
|
||||
}
|
||||
113
src/button/ReactionToggleButton.module.css
Normal file
113
src/button/ReactionToggleButton.module.css
Normal file
@@ -0,0 +1,113 @@
|
||||
.raisedButton > svg {
|
||||
color: var(--cpd-color-icon-on-solid-primary);
|
||||
}
|
||||
|
||||
.reactionPopupMenu {
|
||||
--reaction-button-padding: 10px;
|
||||
--reaction-button-fontsize: 20px;
|
||||
--reaction-button-gap: var(--cpd-separator-spacing);
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
@media (max-width: 420px) {
|
||||
.reactionPopupMenu {
|
||||
--reaction-button-padding: 8px;
|
||||
--reaction-button-fontsize: 16px;
|
||||
--reaction-button-gap: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
div.reactionPopupMenuRoot.reactionPopupMenuModal {
|
||||
--overlay-top: 82vh;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
div.reactionPopupMenuRoot {
|
||||
/* Center the drawer */
|
||||
--inset-inline: 30em;
|
||||
}
|
||||
|
||||
.reactionPopupMenuRoot > div {
|
||||
width: fit-content;
|
||||
max-width: 100vw;
|
||||
}
|
||||
|
||||
div.reactionPopupMenuRoot.reactionPopupMenuModal > div > div {
|
||||
padding-inline: var(--cpd-space-6x);
|
||||
padding-block: var(--cpd-space-6x);
|
||||
}
|
||||
|
||||
.reactionPopupMenu section {
|
||||
height: fit-content;
|
||||
flex: 1;
|
||||
max-width: fit-content;
|
||||
}
|
||||
|
||||
.reactionPopupMenu section.reactionsMenuSection {
|
||||
margin: auto 0;
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
.reactionsMenu {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
flex-grow: 1;
|
||||
gap: var(--reaction-button-gap);
|
||||
/* Height of 3 rows plus padding. */
|
||||
max-height: calc(
|
||||
((var(--reaction-button-fontsize) + var(--cpd-separator-spacing)) * 2) * 3
|
||||
);
|
||||
max-width: calc(
|
||||
((var(--reaction-button-fontsize) + var(--cpd-separator-spacing)) * 2) * 5
|
||||
);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
list-style: none;
|
||||
flex-wrap: wrap;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: row;
|
||||
justify-content: start;
|
||||
align-items: auto;
|
||||
align-content: start;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.reactionsMenu > * {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.reactionButton {
|
||||
padding: var(--reaction-button-padding);
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
font-size: var(--reaction-button-fontsize);
|
||||
min-block-size: unset;
|
||||
border: none;
|
||||
aspect-ratio: 1 / 1;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.verticalSeperator {
|
||||
background-color: var(--cpd-color-gray-800);
|
||||
width: 2px;
|
||||
height: auto;
|
||||
margin-left: var(--cpd-separator-spacing);
|
||||
margin-right: var(--cpd-separator-spacing);
|
||||
}
|
||||
|
||||
.alert {
|
||||
margin-bottom: var(--cpd-space-3x);
|
||||
animation: grow-in 200ms;
|
||||
height: 2.5em;
|
||||
}
|
||||
|
||||
@keyframes grow-in {
|
||||
from {
|
||||
height: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
height: 2.5em;
|
||||
}
|
||||
}
|
||||
157
src/button/ReactionToggleButton.test.tsx
Normal file
157
src/button/ReactionToggleButton.test.tsx
Normal file
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { render } from "@testing-library/react";
|
||||
import { expect, test } from "vitest";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
import { userEvent } from "@testing-library/user-event";
|
||||
import { ReactNode } from "react";
|
||||
|
||||
import {
|
||||
MockRoom,
|
||||
MockRTCSession,
|
||||
TestReactionsWrapper,
|
||||
} from "../utils/testReactions";
|
||||
import { ReactionToggleButton } from "./ReactionToggleButton";
|
||||
import { ElementCallReactionEventType } from "../reactions";
|
||||
|
||||
const memberUserIdAlice = "@alice:example.org";
|
||||
const memberEventAlice = "$membership-alice:example.org";
|
||||
|
||||
const membership: Record<string, string> = {
|
||||
[memberEventAlice]: memberUserIdAlice,
|
||||
};
|
||||
|
||||
function TestComponent({
|
||||
rtcSession,
|
||||
}: {
|
||||
rtcSession: MockRTCSession;
|
||||
}): ReactNode {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<TestReactionsWrapper rtcSession={rtcSession}>
|
||||
<ReactionToggleButton userId={memberUserIdAlice} />
|
||||
</TestReactionsWrapper>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
test("Can open menu", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByLabelText, container } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("Can raise hand", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByLabelText, container } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
await user.click(getByLabelText("action.raise_hand"));
|
||||
expect(room.testSentEvents).toEqual([
|
||||
[
|
||||
undefined,
|
||||
"m.reaction",
|
||||
{
|
||||
"m.relates_to": {
|
||||
event_id: memberEventAlice,
|
||||
key: "🖐️",
|
||||
rel_type: "m.annotation",
|
||||
},
|
||||
},
|
||||
],
|
||||
]);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("Can lower hand", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByLabelText, container } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
const reactionEvent = room.testSendHandRaise(memberEventAlice, membership);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
await user.click(getByLabelText("action.lower_hand"));
|
||||
expect(room.testRedactedEvents).toEqual([[undefined, reactionEvent]]);
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test("Can react with emoji", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByLabelText, getByText } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
await user.click(getByText("🐶"));
|
||||
expect(room.testSentEvents).toEqual([
|
||||
[
|
||||
undefined,
|
||||
ElementCallReactionEventType,
|
||||
{
|
||||
"m.relates_to": {
|
||||
event_id: memberEventAlice,
|
||||
rel_type: "m.reference",
|
||||
},
|
||||
name: "dog",
|
||||
emoji: "🐶",
|
||||
},
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
test("Can fully expand emoji picker", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByText, container, getByLabelText } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
await user.click(getByLabelText("action.show_more"));
|
||||
expect(container).toMatchSnapshot();
|
||||
await user.click(getByText("🦗"));
|
||||
|
||||
expect(room.testSentEvents).toEqual([
|
||||
[
|
||||
undefined,
|
||||
ElementCallReactionEventType,
|
||||
{
|
||||
"m.relates_to": {
|
||||
event_id: memberEventAlice,
|
||||
rel_type: "m.reference",
|
||||
},
|
||||
name: "crickets",
|
||||
emoji: "🦗",
|
||||
},
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
test("Can close reaction dialog", async () => {
|
||||
const user = userEvent.setup();
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByLabelText, container } = render(
|
||||
<TestComponent rtcSession={rtcSession} />,
|
||||
);
|
||||
await user.click(getByLabelText("common.reactions"));
|
||||
await user.click(getByLabelText("action.show_more"));
|
||||
await user.click(getByLabelText("action.show_less"));
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
244
src/button/ReactionToggleButton.tsx
Normal file
244
src/button/ReactionToggleButton.tsx
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { Button as CpdButton, Tooltip, Alert } from "@vector-im/compound-web";
|
||||
import {
|
||||
RaisedHandSolidIcon,
|
||||
ChevronDownIcon,
|
||||
ChevronUpIcon,
|
||||
ReactionSolidIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import {
|
||||
ComponentPropsWithoutRef,
|
||||
FC,
|
||||
ReactNode,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import classNames from "classnames";
|
||||
|
||||
import { useReactions } from "../useReactions";
|
||||
import styles from "./ReactionToggleButton.module.css";
|
||||
import { ReactionOption, ReactionSet, ReactionsRowSize } from "../reactions";
|
||||
import { Modal } from "../Modal";
|
||||
|
||||
interface InnerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
raised: boolean;
|
||||
open: boolean;
|
||||
}
|
||||
|
||||
const InnerButton: FC<InnerButtonProps> = ({ raised, open, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Tooltip label={t("common.reactions")}>
|
||||
<CpdButton
|
||||
className={classNames(raised && styles.raisedButton)}
|
||||
aria-expanded={open}
|
||||
aria-haspopup
|
||||
kind={raised || open ? "primary" : "secondary"}
|
||||
iconOnly
|
||||
Icon={raised ? RaisedHandSolidIcon : ReactionSolidIcon}
|
||||
{...props}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
export function ReactionPopupMenu({
|
||||
sendReaction,
|
||||
toggleRaisedHand,
|
||||
isHandRaised,
|
||||
canReact,
|
||||
errorText,
|
||||
}: {
|
||||
sendReaction: (reaction: ReactionOption) => void;
|
||||
toggleRaisedHand: () => void;
|
||||
errorText?: string;
|
||||
isHandRaised: boolean;
|
||||
canReact: boolean;
|
||||
}): ReactNode {
|
||||
const { t } = useTranslation();
|
||||
const [isFullyExpanded, setExpanded] = useState(false);
|
||||
|
||||
const filteredReactionSet = useMemo(
|
||||
() => (isFullyExpanded ? ReactionSet : ReactionSet.slice(0, 5)),
|
||||
[isFullyExpanded],
|
||||
);
|
||||
const label = isHandRaised ? t("action.lower_hand") : t("action.raise_hand");
|
||||
return (
|
||||
<>
|
||||
{errorText && (
|
||||
<Alert
|
||||
className={styles.alert}
|
||||
type="critical"
|
||||
title={t("common.something_went_wrong")}
|
||||
>
|
||||
{errorText}
|
||||
</Alert>
|
||||
)}
|
||||
<div className={styles.reactionPopupMenu}>
|
||||
<section className={styles.handRaiseSection}>
|
||||
<Tooltip label={label} caption="H">
|
||||
<CpdButton
|
||||
kind={isHandRaised ? "primary" : "secondary"}
|
||||
aria-keyshortcuts="H"
|
||||
aria-pressed={isHandRaised}
|
||||
aria-label={label}
|
||||
onClick={() => toggleRaisedHand()}
|
||||
iconOnly
|
||||
Icon={RaisedHandSolidIcon}
|
||||
/>
|
||||
</Tooltip>
|
||||
</section>
|
||||
<div className={styles.verticalSeperator} />
|
||||
<section className={styles.reactionsMenuSection}>
|
||||
<menu
|
||||
className={classNames(
|
||||
isFullyExpanded && styles.reactionsMenuExpanded,
|
||||
styles.reactionsMenu,
|
||||
)}
|
||||
>
|
||||
{filteredReactionSet.map((reaction, index) => (
|
||||
<li key={reaction.name}>
|
||||
<Tooltip
|
||||
label={reaction.name}
|
||||
caption={
|
||||
index < ReactionsRowSize
|
||||
? (index + 1).toString()
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<CpdButton
|
||||
kind="secondary"
|
||||
className={styles.reactionButton}
|
||||
disabled={!canReact}
|
||||
onClick={() => sendReaction(reaction)}
|
||||
aria-keyshortcuts={
|
||||
index < ReactionsRowSize
|
||||
? (index + 1).toString()
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
{reaction.emoji}
|
||||
</CpdButton>
|
||||
</Tooltip>
|
||||
</li>
|
||||
))}
|
||||
</menu>
|
||||
</section>
|
||||
<section style={{ marginLeft: "var(--cpd-separator-spacing)" }}>
|
||||
<Tooltip
|
||||
label={
|
||||
isFullyExpanded ? t("action.show_less") : t("action.show_more")
|
||||
}
|
||||
>
|
||||
<CpdButton
|
||||
iconOnly
|
||||
aria-label={
|
||||
isFullyExpanded ? t("action.show_less") : t("action.show_more")
|
||||
}
|
||||
Icon={isFullyExpanded ? ChevronUpIcon : ChevronDownIcon}
|
||||
kind="tertiary"
|
||||
onClick={() => setExpanded(!isFullyExpanded)}
|
||||
/>
|
||||
</Tooltip>
|
||||
</section>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
interface ReactionToggleButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
userId: string;
|
||||
}
|
||||
|
||||
export function ReactionToggleButton({
|
||||
userId,
|
||||
...props
|
||||
}: ReactionToggleButtonProps): ReactNode {
|
||||
const { t } = useTranslation();
|
||||
const { raisedHands, toggleRaisedHand, sendReaction, reactions } =
|
||||
useReactions();
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [showReactionsMenu, setShowReactionsMenu] = useState(false);
|
||||
const [errorText, setErrorText] = useState<string>();
|
||||
|
||||
const isHandRaised = !!raisedHands[userId];
|
||||
const canReact = !reactions[userId];
|
||||
|
||||
useEffect(() => {
|
||||
// Clear whenever the reactions menu state changes.
|
||||
setErrorText(undefined);
|
||||
}, [showReactionsMenu]);
|
||||
|
||||
const sendRelation = useCallback(
|
||||
async (reaction: ReactionOption) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
await sendReaction(reaction);
|
||||
setErrorText(undefined);
|
||||
setShowReactionsMenu(false);
|
||||
} catch (ex) {
|
||||
setErrorText(ex instanceof Error ? ex.message : "Unknown error");
|
||||
logger.error("Failed to send reaction", ex);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
},
|
||||
[sendReaction],
|
||||
);
|
||||
|
||||
const wrappedToggleRaisedHand = useCallback(() => {
|
||||
const toggleHand = async (): Promise<void> => {
|
||||
try {
|
||||
setBusy(true);
|
||||
await toggleRaisedHand();
|
||||
setShowReactionsMenu(false);
|
||||
} catch (ex) {
|
||||
setErrorText(ex instanceof Error ? ex.message : "Unknown error");
|
||||
logger.error("Failed to raise/lower hand", ex);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
void toggleHand();
|
||||
}, [toggleRaisedHand]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<InnerButton
|
||||
disabled={busy}
|
||||
onClick={() => setShowReactionsMenu((show) => !show)}
|
||||
raised={isHandRaised}
|
||||
open={showReactionsMenu}
|
||||
{...props}
|
||||
/>
|
||||
<Modal
|
||||
open={showReactionsMenu}
|
||||
title={t("action.pick_reaction")}
|
||||
hideHeader
|
||||
classNameModal={styles.reactionPopupMenuModal}
|
||||
className={styles.reactionPopupMenuRoot}
|
||||
onDismiss={() => setShowReactionsMenu(false)}
|
||||
>
|
||||
<ReactionPopupMenu
|
||||
errorText={errorText}
|
||||
isHandRaised={isHandRaised}
|
||||
canReact={!busy && canReact}
|
||||
sendReaction={(reaction) => void sendRelation(reaction)}
|
||||
toggleRaisedHand={wrappedToggleRaisedHand}
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
163
src/button/__snapshots__/ReactionToggleButton.test.tsx.snap
Normal file
163
src/button/__snapshots__/ReactionToggleButton.test.tsx.snap
Normal file
@@ -0,0 +1,163 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Can close reaction dialog 1`] = `
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-aria-hidden="true"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-expanded="true"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby=":r9l:"
|
||||
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Can fully expand emoji picker 1`] = `
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-aria-hidden="true"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-expanded="true"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby=":r6c:"
|
||||
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Can lower hand 1`] = `
|
||||
<div>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby=":r36:"
|
||||
class="_button_i91xf_17 raisedButton _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M11 3a1 1 0 1 1 2 0v8.5a.5.5 0 0 0 1 0V4a1 1 0 1 1 2 0v10.2l3.284-2.597a1.081 1.081 0 0 1 1.47 1.577c-.613.673-1.214 1.367-1.818 2.064-1.267 1.463-2.541 2.934-3.944 4.235A6 6 0 0 1 5 15V7a1 1 0 0 1 2 0v5.5a.5.5 0 0 0 1 0V4a1 1 0 0 1 2 0v7.5a.5.5 0 0 0 1 0V3Z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Can open menu 1`] = `
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-aria-hidden="true"
|
||||
>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-expanded="true"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby=":r0:"
|
||||
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Can raise hand 1`] = `
|
||||
<div>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby=":r1j:"
|
||||
class="_button_i91xf_17 _has-icon_i91xf_66 _icon-only_i91xf_59"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10Zm3.536-6.464a1 1 0 0 0-1.415-1.415A2.988 2.988 0 0 1 12 15a2.988 2.988 0 0 1-2.121-.879 1 1 0 1 0-1.414 1.415A4.987 4.987 0 0 0 12 17c1.38 0 2.632-.56 3.536-1.464ZM10 10.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Zm5.5 1.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
`;
|
||||
@@ -7,4 +7,4 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
export * from "./Button";
|
||||
export * from "./LinkButton";
|
||||
export * from "./RaisedHandToggleButton";
|
||||
export * from "./ReactionToggleButton";
|
||||
|
||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { merge } from "lodash";
|
||||
import { merge } from "lodash-es";
|
||||
|
||||
import { getUrlParams } from "../UrlParams";
|
||||
import {
|
||||
@@ -28,11 +28,11 @@ export class Config {
|
||||
const internalInstance = new Config();
|
||||
Config.internalInstance = internalInstance;
|
||||
|
||||
Config.internalInstance.initPromise = downloadConfig(
|
||||
"../config.json",
|
||||
).then((config) => {
|
||||
internalInstance.config = merge({}, DEFAULT_CONFIG, config);
|
||||
});
|
||||
Config.internalInstance.initPromise = downloadConfig("/config.json").then(
|
||||
(config) => {
|
||||
internalInstance.config = merge({}, DEFAULT_CONFIG, config);
|
||||
},
|
||||
);
|
||||
}
|
||||
return Config.internalInstance.initPromise;
|
||||
}
|
||||
@@ -74,11 +74,7 @@ async function downloadConfig(
|
||||
configJsonFilename: string,
|
||||
): Promise<ConfigOptions> {
|
||||
const url = new URL(configJsonFilename, window.location.href);
|
||||
url.searchParams.set("cachebuster", Date.now().toString());
|
||||
const res = await fetch(url, {
|
||||
cache: "no-cache",
|
||||
method: "GET",
|
||||
});
|
||||
const res = await fetch(url);
|
||||
|
||||
if (!res.ok || res.status === 404 || res.status === 0) {
|
||||
// Lack of a config isn't an error, we should just use the defaults.
|
||||
|
||||
@@ -96,6 +96,30 @@ export interface ConfigOptions {
|
||||
* Note that this can additionally be disabled by the app's URL parameters.
|
||||
*/
|
||||
app_prompt?: boolean;
|
||||
|
||||
/**
|
||||
* These are low level options that are used to configure the MatrixRTC session.
|
||||
* Take care when changing these options.
|
||||
*/
|
||||
matrix_rtc_session?: {
|
||||
/**
|
||||
* How long (in milliseconds) to wait before rotating end-to-end media encryption keys
|
||||
* when someone leaves a call.
|
||||
*/
|
||||
key_rotation_on_leave_delay?: number;
|
||||
|
||||
/**
|
||||
* How often (in milliseconds) keep-alive messages should be sent to the server for
|
||||
* the MatrixRTC membership event.
|
||||
*/
|
||||
membership_keep_alive_period?: number;
|
||||
|
||||
/**
|
||||
* How long (in milliseconds) after the last keep-alive the server should expire the
|
||||
* MatrixRTC membership event.
|
||||
*/
|
||||
membership_server_side_expiry_timeout?: number;
|
||||
};
|
||||
}
|
||||
|
||||
// Overrides members from ConfigOptions that are always provided by the
|
||||
|
||||
105
src/index.css
105
src/index.css
@@ -5,14 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/* Inter unexpectedly contains various codepoints which collide with emoji, even
|
||||
when variation-16 is applied to request the emoji variant. From eyeballing
|
||||
the emoji picker, these are: 20e3, 23cf, 24c2, 25a0-25c1, 2665, 2764, 2b06, 2b1c.
|
||||
Therefore we define a unicode-range to load which excludes the glyphs
|
||||
(to avoid having to maintain a fork of Inter). */
|
||||
|
||||
@layer normalize, compound-legacy, compound;
|
||||
|
||||
@import url("@fontsource/inter/400.css");
|
||||
@import url("@fontsource/inter/500.css");
|
||||
@import url("@fontsource/inter/600.css");
|
||||
@import url("@fontsource/inter/700.css");
|
||||
@import url("@fontsource/inconsolata/400.css");
|
||||
@import url("@fontsource/inconsolata/700.css");
|
||||
|
||||
@import url("normalize.css/normalize.css") layer(normalize);
|
||||
@import url("@vector-im/compound-design-tokens/assets/web/css/compound-design-tokens.css")
|
||||
layer(compound);
|
||||
@@ -52,94 +53,6 @@ layer(compound);
|
||||
--stopgap-background-85: rgba(16, 19, 23, 0.85);
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-Regular.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-Regular.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-Italic.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-Italic.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-Medium.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-Medium.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-MediumItalic.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-MediumItalic.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-SemiBold.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-SemiBold.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-SemiBoldItalic.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-SemiBoldItalic.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-Bold.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-Bold.woff") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
unicode-range: var(--inter-unicode-range);
|
||||
src:
|
||||
url("/fonts/Inter/Inter-BoldItalic.woff2") format("woff2"),
|
||||
url("/fonts/Inter/Inter-BoldItalic.woff") format("woff");
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--cpd-color-bg-canvas-default);
|
||||
background-size: calc(max(1440px, 100vw)) calc(max(800px, 100vh));
|
||||
@@ -185,10 +98,6 @@ body[data-platform="ios"] {
|
||||
--cpd-font-family-sans: -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
|
||||
}
|
||||
|
||||
body[data-platform="desktop"] {
|
||||
--cpd-font-family-sans: "Inter", sans-serif;
|
||||
}
|
||||
|
||||
@layer compound-legacy {
|
||||
h1,
|
||||
h2,
|
||||
|
||||
@@ -9,9 +9,9 @@ import { expect, test } from "vitest";
|
||||
|
||||
import { Initializer } from "../src/initializer";
|
||||
|
||||
test("initBeforeReact sets font family from URL param", () => {
|
||||
test("initBeforeReact sets font family from URL param", async () => {
|
||||
window.location.hash = "#?font=DejaVu Sans";
|
||||
Initializer.initBeforeReact();
|
||||
await Initializer.initBeforeReact();
|
||||
expect(
|
||||
getComputedStyle(document.documentElement).getPropertyValue(
|
||||
"--font-family",
|
||||
@@ -19,9 +19,9 @@ test("initBeforeReact sets font family from URL param", () => {
|
||||
).toBe('"DejaVu Sans"');
|
||||
});
|
||||
|
||||
test("initBeforeReact sets font scale from URL param", () => {
|
||||
test("initBeforeReact sets font scale from URL param", async () => {
|
||||
window.location.hash = "#?fontScale=1.2";
|
||||
Initializer.initBeforeReact();
|
||||
await Initializer.initBeforeReact();
|
||||
expect(
|
||||
getComputedStyle(document.documentElement).getPropertyValue("--font-scale"),
|
||||
).toBe("1.2");
|
||||
|
||||
@@ -5,18 +5,85 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import i18n from "i18next";
|
||||
import i18n, {
|
||||
type BackendModule,
|
||||
type ReadCallback,
|
||||
type ResourceKey,
|
||||
} from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import LanguageDetector from "i18next-browser-languagedetector";
|
||||
import Backend from "i18next-http-backend";
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { shouldPolyfill as shouldPolyfillSegmenter } from "@formatjs/intl-segmenter/should-polyfill";
|
||||
import { shouldPolyfill as shouldPolyfillDurationFormat } from "@formatjs/intl-durationformat/should-polyfill";
|
||||
|
||||
import { getUrlParams } from "./UrlParams";
|
||||
import { Config } from "./config/Config";
|
||||
import { ElementCallOpenTelemetry } from "./otel/otel";
|
||||
import { platform } from "./Platform";
|
||||
|
||||
// This generates a map of locale names to their URL (based on import.meta.url), which looks like this:
|
||||
// {
|
||||
// "../locales/en-GB/app.json": "/whatever/assets/root/locales/en-aabbcc.json",
|
||||
// ...
|
||||
// }
|
||||
const locales = import.meta.glob<string>("../locales/*/*.json", {
|
||||
query: "?url",
|
||||
import: "default",
|
||||
eager: true,
|
||||
});
|
||||
|
||||
const getLocaleUrl = (
|
||||
language: string,
|
||||
namespace: string,
|
||||
): string | undefined => locales[`../locales/${language}/${namespace}.json`];
|
||||
|
||||
const supportedLngs = [
|
||||
...new Set(
|
||||
Object.keys(locales).map((url) => {
|
||||
// The URLs are of the form ../locales/en-GB/app.json
|
||||
// This extracts the language code from the URL
|
||||
const lang = url.match(/\/([^/]+)\/[^/]+\.json$/)?.[1];
|
||||
if (!lang) {
|
||||
throw new Error(`Could not parse locale URL ${url}`);
|
||||
}
|
||||
return lang;
|
||||
}),
|
||||
),
|
||||
];
|
||||
|
||||
// A backend that fetches the locale files from the URLs generated by the glob above
|
||||
const Backend = {
|
||||
type: "backend",
|
||||
init(): void {},
|
||||
read(language: string, namespace: string, callback: ReadCallback): void {
|
||||
(async (): Promise<ResourceKey> => {
|
||||
const url = getLocaleUrl(language, namespace);
|
||||
if (!url) {
|
||||
throw new Error(
|
||||
`Namespace ${namespace} for locale ${language} not found`,
|
||||
);
|
||||
}
|
||||
|
||||
const response = await fetch(url, {
|
||||
credentials: "omit",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw Error(`Failed to fetch ${url}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
})().then(
|
||||
(data) => callback(null, data),
|
||||
(error) => callback(error, null),
|
||||
);
|
||||
},
|
||||
} satisfies BackendModule;
|
||||
|
||||
enum LoadState {
|
||||
None,
|
||||
Loading,
|
||||
@@ -41,10 +108,17 @@ export class Initializer {
|
||||
return Initializer.internalInstance?.isInitialized;
|
||||
}
|
||||
|
||||
public static initBeforeReact(): void {
|
||||
// this maybe also needs to return a promise in the future,
|
||||
// if we have to do async inits before showing the loading screen
|
||||
// but this should be avoided if possible
|
||||
public static async initBeforeReact(): Promise<void> {
|
||||
const polyfills: Promise<unknown>[] = [];
|
||||
if (shouldPolyfillSegmenter()) {
|
||||
polyfills.push(import("@formatjs/intl-segmenter/polyfill-force"));
|
||||
}
|
||||
|
||||
if (shouldPolyfillDurationFormat()) {
|
||||
polyfills.push(import("@formatjs/intl-durationformat/polyfill-force"));
|
||||
}
|
||||
|
||||
await Promise.all(polyfills);
|
||||
|
||||
//i18n
|
||||
const languageDetector = new LanguageDetector();
|
||||
@@ -54,7 +128,7 @@ export class Initializer {
|
||||
lookup: () => getUrlParams().lang ?? undefined,
|
||||
});
|
||||
|
||||
i18n
|
||||
await i18n
|
||||
.use(Backend)
|
||||
.use(languageDetector)
|
||||
.use(initReactI18next)
|
||||
@@ -65,6 +139,7 @@ export class Initializer {
|
||||
nsSeparator: false,
|
||||
pluralSeparator: "_",
|
||||
contextSeparator: "|",
|
||||
supportedLngs,
|
||||
interpolation: {
|
||||
escapeValue: false, // React has built-in XSS protections
|
||||
},
|
||||
@@ -74,9 +149,6 @@ export class Initializer {
|
||||
order: ["urlFragment", "navigator"],
|
||||
caches: [],
|
||||
},
|
||||
})
|
||||
.catch((e) => {
|
||||
logger.error("Failed to initialize i18n", e);
|
||||
});
|
||||
|
||||
// Custom Themeing
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
audioInput as audioInputSetting,
|
||||
audioOutput as audioOutputSetting,
|
||||
videoInput as videoInputSetting,
|
||||
Setting,
|
||||
} from "../settings/settings";
|
||||
import { isFirefox } from "../Platform";
|
||||
|
||||
@@ -58,7 +59,7 @@ function useObservableState<T>(
|
||||
|
||||
function useMediaDevice(
|
||||
kind: MediaDeviceKind,
|
||||
fallbackDevice: string | undefined,
|
||||
setting: Setting<string | undefined>,
|
||||
usingNames: boolean,
|
||||
alwaysDefault: boolean = false,
|
||||
): MediaDevice {
|
||||
@@ -84,15 +85,21 @@ function useMediaDevice(
|
||||
[kind, requestPermissions],
|
||||
);
|
||||
const available = useObservableState(deviceObserver, []);
|
||||
const [selectedId, select] = useState(fallbackDevice);
|
||||
const [preferredId, select] = useSetting(setting);
|
||||
|
||||
return useMemo(() => {
|
||||
let devId;
|
||||
if (available) {
|
||||
devId = available.some((d) => d.deviceId === selectedId)
|
||||
? selectedId
|
||||
: available.some((d) => d.deviceId === fallbackDevice)
|
||||
? fallbackDevice
|
||||
let selectedId: string | undefined = undefined;
|
||||
if (!alwaysDefault && available) {
|
||||
// If the preferred device is available, use it. Or if every available
|
||||
// device ID is falsy, the browser is probably just being paranoid about
|
||||
// fingerprinting and we should still try using the preferred device.
|
||||
// Worst case it is not available and the browser will gracefully fall
|
||||
// back to some other device for us when requesting the media stream.
|
||||
// Otherwise, select the first available device.
|
||||
selectedId =
|
||||
available.some((d) => d.deviceId === preferredId) ||
|
||||
available.every((d) => d.deviceId === "")
|
||||
? preferredId
|
||||
: available.at(0)?.deviceId;
|
||||
}
|
||||
|
||||
@@ -102,10 +109,10 @@ function useMediaDevice(
|
||||
// device entries for the exact same device ID; deduplicate them
|
||||
[...new Map(available.map((d) => [d.deviceId, d])).values()]
|
||||
: [],
|
||||
selectedId: alwaysDefault ? undefined : devId,
|
||||
selectedId,
|
||||
select,
|
||||
};
|
||||
}, [available, selectedId, fallbackDevice, select, alwaysDefault]);
|
||||
}, [available, preferredId, select, alwaysDefault]);
|
||||
}
|
||||
|
||||
const deviceStub: MediaDevice = {
|
||||
@@ -141,36 +148,22 @@ export const MediaDevicesProvider: FC<Props> = ({ children }) => {
|
||||
// for ouput devices because the selector wont be shown on FF.
|
||||
const useOutputNames = usingNames && !isFirefox();
|
||||
|
||||
const [storedAudioInput, setStoredAudioInput] = useSetting(audioInputSetting);
|
||||
const [storedAudioOutput, setStoredAudioOutput] =
|
||||
useSetting(audioOutputSetting);
|
||||
const [storedVideoInput, setStoredVideoInput] = useSetting(videoInputSetting);
|
||||
|
||||
const audioInput = useMediaDevice("audioinput", storedAudioInput, usingNames);
|
||||
const audioInput = useMediaDevice(
|
||||
"audioinput",
|
||||
audioInputSetting,
|
||||
usingNames,
|
||||
);
|
||||
const audioOutput = useMediaDevice(
|
||||
"audiooutput",
|
||||
storedAudioOutput,
|
||||
audioOutputSetting,
|
||||
useOutputNames,
|
||||
alwaysUseDefaultAudio,
|
||||
);
|
||||
const videoInput = useMediaDevice("videoinput", storedVideoInput, usingNames);
|
||||
|
||||
useEffect(() => {
|
||||
if (audioInput.selectedId !== undefined)
|
||||
setStoredAudioInput(audioInput.selectedId);
|
||||
}, [setStoredAudioInput, audioInput.selectedId]);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip setting state for ff output. Redundent since it is set to always return 'undefined'
|
||||
// but makes it clear while debugging that this is not happening on FF. + perf ;)
|
||||
if (audioOutput.selectedId !== undefined && !isFirefox())
|
||||
setStoredAudioOutput(audioOutput.selectedId);
|
||||
}, [setStoredAudioOutput, audioOutput.selectedId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (videoInput.selectedId !== undefined)
|
||||
setStoredVideoInput(videoInput.selectedId);
|
||||
}, [setStoredVideoInput, videoInput.selectedId]);
|
||||
const videoInput = useMediaDevice(
|
||||
"videoinput",
|
||||
videoInputSetting,
|
||||
usingNames,
|
||||
);
|
||||
|
||||
const startUsingDeviceNames = useCallback(
|
||||
() => setNumCallersUsingNames((n) => n + 1),
|
||||
|
||||
21
src/main.tsx
21
src/main.tsx
@@ -55,12 +55,17 @@ if (fatalError !== null) {
|
||||
throw fatalError; // Stop the app early
|
||||
}
|
||||
|
||||
Initializer.initBeforeReact();
|
||||
Initializer.initBeforeReact()
|
||||
.then(() => {
|
||||
const history = createBrowserHistory();
|
||||
|
||||
const history = createBrowserHistory();
|
||||
|
||||
root.render(
|
||||
<StrictMode>
|
||||
<App history={history} />
|
||||
</StrictMode>,
|
||||
);
|
||||
root.render(
|
||||
<StrictMode>
|
||||
<App history={history} />
|
||||
</StrictMode>,
|
||||
);
|
||||
})
|
||||
.catch((e) => {
|
||||
logger.error("Failed to initialize app", e);
|
||||
root.render(e.message);
|
||||
});
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
.raisedHandWidget {
|
||||
display: flex;
|
||||
background-color: var(--cpd-color-bg-subtle-primary);
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
color: var(--cpd-color-icon-secondary);
|
||||
}
|
||||
|
||||
.button {
|
||||
display: contents;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.raisedHandWidget > p {
|
||||
padding: none;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
.raisedHandWidgetLarge > p {
|
||||
padding: var(--cpd-space-2x);
|
||||
}
|
||||
|
||||
.raisedHandLarge {
|
||||
margin: var(--cpd-space-2x);
|
||||
padding: var(--cpd-space-2x);
|
||||
padding-block: var(--cpd-space-2x);
|
||||
}
|
||||
|
||||
.raisedHand {
|
||||
margin: var(--cpd-space-1x);
|
||||
color: var(--cpd-color-icon-secondary);
|
||||
background-color: var(--cpd-color-icon-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
box-shadow: var(--small-drop-shadow);
|
||||
box-sizing: border-box;
|
||||
max-inline-size: 100%;
|
||||
max-width: fit-content;
|
||||
}
|
||||
|
||||
.raisedHand > span {
|
||||
width: var(--cpd-space-6x);
|
||||
height: var(--cpd-space-6x);
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.raisedHandLarge > span {
|
||||
width: var(--cpd-space-8x);
|
||||
height: var(--cpd-space-8x);
|
||||
font-size: 1.9em;
|
||||
}
|
||||
@@ -11,19 +11,11 @@ import {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useState,
|
||||
useMemo,
|
||||
} from "react";
|
||||
import classNames from "classnames";
|
||||
import "@formatjs/intl-durationformat/polyfill";
|
||||
import { DurationFormat } from "@formatjs/intl-durationformat";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import styles from "./RaisedHandIndicator.module.css";
|
||||
|
||||
const durationFormatter = new DurationFormat(undefined, {
|
||||
minutesDisplay: "always",
|
||||
secondsDisplay: "always",
|
||||
hoursDisplay: "auto",
|
||||
style: "digital",
|
||||
});
|
||||
import { ReactionIndicator } from "./ReactionIndicator";
|
||||
|
||||
export function RaisedHandIndicator({
|
||||
raisedHandTime,
|
||||
@@ -36,8 +28,20 @@ export function RaisedHandIndicator({
|
||||
showTimer?: boolean;
|
||||
onClick?: () => void;
|
||||
}): ReactNode {
|
||||
const { t } = useTranslation();
|
||||
const [raisedHandDuration, setRaisedHandDuration] = useState("");
|
||||
|
||||
const durationFormatter = useMemo(
|
||||
() =>
|
||||
new Intl.DurationFormat(undefined, {
|
||||
minutesDisplay: "always",
|
||||
secondsDisplay: "always",
|
||||
hoursDisplay: "auto",
|
||||
style: "digital",
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const clickCallback = useCallback<MouseEventHandler<HTMLButtonElement>>(
|
||||
(event) => {
|
||||
if (!onClick) {
|
||||
@@ -69,36 +73,26 @@ export function RaisedHandIndicator({
|
||||
calculateTime();
|
||||
const to = setInterval(calculateTime, 1000);
|
||||
return (): void => clearInterval(to);
|
||||
}, [setRaisedHandDuration, raisedHandTime, showTimer]);
|
||||
}, [setRaisedHandDuration, raisedHandTime, showTimer, durationFormatter]);
|
||||
|
||||
if (!raisedHandTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
const content = (
|
||||
<div
|
||||
className={classNames(styles.raisedHandWidget, {
|
||||
[styles.raisedHandWidgetLarge]: !miniature,
|
||||
})}
|
||||
>
|
||||
<div
|
||||
className={classNames(styles.raisedHand, {
|
||||
[styles.raisedHandLarge]: !miniature,
|
||||
})}
|
||||
>
|
||||
<span role="img" aria-label="raised hand">
|
||||
✋
|
||||
</span>
|
||||
</div>
|
||||
<ReactionIndicator emoji="✋" miniature={miniature}>
|
||||
{showTimer && <p>{raisedHandDuration}</p>}
|
||||
</div>
|
||||
</ReactionIndicator>
|
||||
);
|
||||
|
||||
if (onClick) {
|
||||
return (
|
||||
<button
|
||||
aria-label="lower raised hand"
|
||||
className={styles.button}
|
||||
aria-label={t("action.lower_hand")}
|
||||
style={{
|
||||
display: "contents",
|
||||
background: "none",
|
||||
}}
|
||||
onClick={clickCallback}
|
||||
>
|
||||
{content}
|
||||
|
||||
62
src/reactions/ReactionIndicator.module.css
Normal file
62
src/reactions/ReactionIndicator.module.css
Normal file
@@ -0,0 +1,62 @@
|
||||
.reactionIndicatorWidget {
|
||||
display: flex;
|
||||
/* background-color: var(--cpd-color-bg-subtle-primary); */
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
box-shadow: 0 0 var(--cpd-space-2x) #00000040;
|
||||
background: "ffffff40";
|
||||
backdrop-filter: blur(10px);
|
||||
outline: var(--cpd-border-width-1) solid var(--cpd-color-alpha-gray-400);
|
||||
outline-offset: calc(-1 * var(--cpd-border-width-1));
|
||||
}
|
||||
|
||||
.reactionIndicatorWidget > p {
|
||||
padding: none;
|
||||
margin-top: auto;
|
||||
margin-bottom: auto;
|
||||
width: 3em;
|
||||
}
|
||||
|
||||
.reactionIndicatorWidgetLarge > p {
|
||||
padding: var(--cpd-space-2x);
|
||||
padding-right: var(--cpd-space-4x);
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.reactionLarge {
|
||||
margin: var(--cpd-space-2x);
|
||||
padding: var(--cpd-space-4x);
|
||||
padding-block: var(--cpd-space-4x);
|
||||
}
|
||||
|
||||
.reaction {
|
||||
margin: var(--cpd-space-1x);
|
||||
color: var(--cpd-color-icon-secondary);
|
||||
/* background-color: var(--cpd-color-icon-secondary); */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
user-select: none;
|
||||
overflow: hidden;
|
||||
/* box-shadow: var(--small-drop-shadow); */
|
||||
box-sizing: border-box;
|
||||
max-inline-size: 100%;
|
||||
max-width: fit-content;
|
||||
padding: var(--cpd-space-1x);
|
||||
padding-block: var(--cpd-space-1x);
|
||||
}
|
||||
|
||||
.reaction > span {
|
||||
width: var(--cpd-space-6x);
|
||||
height: var(--cpd-space-6x);
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
font-size: 1.2em;
|
||||
/* Centralise */
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.reactionLarge > span {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
font-size: 25px;
|
||||
}
|
||||
41
src/reactions/ReactionIndicator.tsx
Normal file
41
src/reactions/ReactionIndicator.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { PropsWithChildren, ReactNode } from "react";
|
||||
import classNames from "classnames";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import styles from "./ReactionIndicator.module.css";
|
||||
|
||||
export function ReactionIndicator({
|
||||
emoji,
|
||||
miniature,
|
||||
children,
|
||||
}: PropsWithChildren<{
|
||||
miniature?: boolean;
|
||||
emoji: string;
|
||||
}>): ReactNode {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div
|
||||
className={classNames(styles.reactionIndicatorWidget, {
|
||||
[styles.reactionIndicatorWidgetLarge]: !miniature,
|
||||
})}
|
||||
>
|
||||
<div
|
||||
className={classNames(styles.reaction, {
|
||||
[styles.reactionLarge]: !miniature,
|
||||
})}
|
||||
>
|
||||
<span role="img" aria-label={t("common.reaction")}>
|
||||
{emoji}
|
||||
</span>
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
exports[`RaisedHandIndicator > renders a smaller indicator when miniature is specified 1`] = `
|
||||
<div
|
||||
class="raisedHandWidget"
|
||||
class="reactionIndicatorWidget"
|
||||
>
|
||||
<div
|
||||
class="raisedHand"
|
||||
class="reaction"
|
||||
>
|
||||
<span
|
||||
aria-label="raised hand"
|
||||
aria-label="common.reaction"
|
||||
role="img"
|
||||
>
|
||||
✋
|
||||
@@ -22,13 +22,13 @@ exports[`RaisedHandIndicator > renders a smaller indicator when miniature is spe
|
||||
|
||||
exports[`RaisedHandIndicator > renders an indicator when a hand has been raised 1`] = `
|
||||
<div
|
||||
class="raisedHandWidget raisedHandWidgetLarge"
|
||||
class="reactionIndicatorWidget reactionIndicatorWidgetLarge"
|
||||
>
|
||||
<div
|
||||
class="raisedHand raisedHandLarge"
|
||||
class="reaction reactionLarge"
|
||||
>
|
||||
<span
|
||||
aria-label="raised hand"
|
||||
aria-label="common.reaction"
|
||||
role="img"
|
||||
>
|
||||
✋
|
||||
@@ -42,13 +42,13 @@ exports[`RaisedHandIndicator > renders an indicator when a hand has been raised
|
||||
|
||||
exports[`RaisedHandIndicator > renders an indicator when a hand has been raised with the expected time 1`] = `
|
||||
<div
|
||||
class="raisedHandWidget raisedHandWidgetLarge"
|
||||
class="reactionIndicatorWidget reactionIndicatorWidgetLarge"
|
||||
>
|
||||
<div
|
||||
class="raisedHand raisedHandLarge"
|
||||
class="reaction reactionLarge"
|
||||
>
|
||||
<span
|
||||
aria-label="raised hand"
|
||||
aria-label="common.reaction"
|
||||
role="img"
|
||||
>
|
||||
✋
|
||||
|
||||
183
src/reactions/index.ts
Normal file
183
src/reactions/index.ts
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { RelationType } from "matrix-js-sdk/src/types";
|
||||
|
||||
import catSoundOgg from "../sound/reactions/cat.ogg?url";
|
||||
import catSoundMp3 from "../sound/reactions/cat.mp3?url";
|
||||
import clapSoundOgg from "../sound/reactions/clap.ogg?url";
|
||||
import clapSoundMp3 from "../sound/reactions/clap.mp3?url";
|
||||
import cricketsSoundOgg from "../sound/reactions/crickets.ogg?url";
|
||||
import cricketsSoundMp3 from "../sound/reactions/crickets.mp3?url";
|
||||
import dogSoundOgg from "../sound/reactions/dog.ogg?url";
|
||||
import dogSoundMp3 from "../sound/reactions/dog.mp3?url";
|
||||
import genericSoundOgg from "../sound/reactions/generic.ogg?url";
|
||||
import genericSoundMp3 from "../sound/reactions/generic.mp3?url";
|
||||
import lightbulbSoundOgg from "../sound/reactions/lightbulb.ogg?url";
|
||||
import lightbulbSoundMp3 from "../sound/reactions/lightbulb.mp3?url";
|
||||
import partySoundOgg from "../sound/reactions/party.ogg?url";
|
||||
import partySoundMp3 from "../sound/reactions/party.mp3?url";
|
||||
import deerSoundOgg from "../sound/reactions/deer.ogg?url";
|
||||
import deerSoundMp3 from "../sound/reactions/deer.mp3?url";
|
||||
import rockSoundOgg from "../sound/reactions/rock.ogg?url";
|
||||
import rockSoundMp3 from "../sound/reactions/rock.mp3?url";
|
||||
|
||||
export const ElementCallReactionEventType = "io.element.call.reaction";
|
||||
|
||||
export interface ReactionOption {
|
||||
/**
|
||||
* The emoji to display. This is always displayed even if no emoji is matched
|
||||
* from `ReactionSet`.
|
||||
*
|
||||
* @note Any excess characters are trimmed from this string.
|
||||
*/
|
||||
emoji: string;
|
||||
/**
|
||||
* The name of the emoji. This is the unique key used when looking for a local
|
||||
* effect in our `ReactionSet` array.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Optional aliases to look for when searching for an emoji in the interface.
|
||||
*/
|
||||
alias?: string[];
|
||||
/**
|
||||
* Optional sound to play. An ogg sound must always be provided.
|
||||
* If this sound isn't given, `GenericReaction` is used.
|
||||
*/
|
||||
sound?: {
|
||||
mp3?: string;
|
||||
ogg: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ECallReactionEventContent {
|
||||
"m.relates_to": {
|
||||
rel_type: RelationType.Reference;
|
||||
event_id: string;
|
||||
};
|
||||
emoji: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const GenericReaction: ReactionOption = {
|
||||
name: "generic",
|
||||
emoji: "", // Filled in by user
|
||||
sound: {
|
||||
mp3: genericSoundMp3,
|
||||
ogg: genericSoundOgg,
|
||||
},
|
||||
};
|
||||
|
||||
export const ReactionsRowSize = 5;
|
||||
|
||||
// The first {ReactionsRowSize} reactions are always visible.
|
||||
export const ReactionSet: ReactionOption[] = [
|
||||
{
|
||||
emoji: "👍",
|
||||
name: "thumbsup",
|
||||
// TODO: These need to be translated.
|
||||
alias: ["+1", "yes", "thumbs up"],
|
||||
},
|
||||
{
|
||||
emoji: "🎉",
|
||||
name: "party",
|
||||
alias: ["hurray", "success"],
|
||||
sound: {
|
||||
ogg: partySoundOgg,
|
||||
mp3: partySoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "👏",
|
||||
name: "clapping",
|
||||
alias: ["celebrate", "success"],
|
||||
sound: {
|
||||
ogg: clapSoundOgg,
|
||||
mp3: clapSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "🐶",
|
||||
name: "dog",
|
||||
alias: ["doggo", "pupper", "woofer", "bark"],
|
||||
sound: {
|
||||
ogg: dogSoundOgg,
|
||||
mp3: dogSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "🐱",
|
||||
name: "cat",
|
||||
alias: ["meow", "kitty"],
|
||||
sound: {
|
||||
ogg: catSoundOgg,
|
||||
mp3: catSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "💡",
|
||||
name: "lightbulb",
|
||||
alias: ["bulb", "light", "idea", "ping"],
|
||||
sound: {
|
||||
ogg: lightbulbSoundOgg,
|
||||
mp3: lightbulbSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "🦗",
|
||||
name: "crickets",
|
||||
alias: ["awkward", "silence"],
|
||||
sound: {
|
||||
ogg: cricketsSoundOgg,
|
||||
mp3: cricketsSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "👎",
|
||||
name: "thumbsdown",
|
||||
alias: ["-1", "no", "thumbs no"],
|
||||
},
|
||||
{
|
||||
emoji: "😵💫",
|
||||
name: "dizzy",
|
||||
alias: ["dazed", "confused"],
|
||||
},
|
||||
{
|
||||
emoji: "👌",
|
||||
name: "ok",
|
||||
alias: ["okay", "cool"],
|
||||
},
|
||||
{
|
||||
emoji: "🥰",
|
||||
name: "heart",
|
||||
alias: ["heart", "love", "smiling"],
|
||||
},
|
||||
{
|
||||
emoji: "😄",
|
||||
name: "laugh",
|
||||
alias: ["giggle", "joy", "smiling"],
|
||||
},
|
||||
{
|
||||
emoji: "🦌",
|
||||
name: "deer",
|
||||
alias: ["stag", "doe", "bleat"],
|
||||
sound: {
|
||||
ogg: deerSoundOgg,
|
||||
mp3: deerSoundMp3,
|
||||
},
|
||||
},
|
||||
{
|
||||
emoji: "🤘",
|
||||
name: "rock",
|
||||
alias: ["cool", "horns", "guitar"],
|
||||
sound: {
|
||||
ogg: rockSoundOgg,
|
||||
mp3: rockSoundMp3,
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
Copyright 2022-2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { MatrixClient } from "matrix-js-sdk/src/client";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { Heading, Text } from "@vector-im/compound-web";
|
||||
|
||||
import { Link } from "../button/Link";
|
||||
import {
|
||||
useLoadGroupCall,
|
||||
GroupCallStatus,
|
||||
CallTerminatedMessage,
|
||||
} from "./useLoadGroupCall";
|
||||
import { ErrorView, FullScreenView } from "../FullScreenView";
|
||||
|
||||
interface Props {
|
||||
client: MatrixClient;
|
||||
roomIdOrAlias: string;
|
||||
viaServers: string[];
|
||||
children: (groupCallState: GroupCallStatus) => JSX.Element;
|
||||
}
|
||||
|
||||
export function GroupCallLoader({
|
||||
client,
|
||||
roomIdOrAlias,
|
||||
viaServers,
|
||||
children,
|
||||
}: Props): JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const groupCallState = useLoadGroupCall(client, roomIdOrAlias, viaServers);
|
||||
|
||||
switch (groupCallState.kind) {
|
||||
case "loaded":
|
||||
case "waitForInvite":
|
||||
case "canKnock":
|
||||
return children(groupCallState);
|
||||
case "loading":
|
||||
return (
|
||||
<FullScreenView>
|
||||
<h1>{t("common.loading")}</h1>
|
||||
</FullScreenView>
|
||||
);
|
||||
case "failed":
|
||||
if ((groupCallState.error as MatrixError).errcode === "M_NOT_FOUND") {
|
||||
return (
|
||||
<FullScreenView>
|
||||
<Heading>{t("group_call_loader.failed_heading")}</Heading>
|
||||
<Text>{t("group_call_loader.failed_text")}</Text>
|
||||
{/* XXX: A 'create it for me' button would be the obvious UX here. Two screens already have
|
||||
dupes of this flow, let's make a common component and put it here. */}
|
||||
<Link to="/">{t("common.home")}</Link>
|
||||
</FullScreenView>
|
||||
);
|
||||
} else if (groupCallState.error instanceof CallTerminatedMessage) {
|
||||
return (
|
||||
<FullScreenView>
|
||||
<Heading>{groupCallState.error.message}</Heading>
|
||||
<Text>{groupCallState.error.messageBody}</Text>
|
||||
{groupCallState.error.reason && (
|
||||
<>
|
||||
{t("group_call_loader.reason")}:
|
||||
<Text size="sm">"{groupCallState.error.reason}"</Text>
|
||||
</>
|
||||
)}
|
||||
<Link to="/">{t("common.home")}</Link>
|
||||
</FullScreenView>
|
||||
);
|
||||
} else {
|
||||
return <ErrorView error={groupCallState.error} />;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,29 +177,37 @@ export const GroupCallView: FC<Props> = ({
|
||||
}
|
||||
};
|
||||
|
||||
if (widget && preload && skipLobby) {
|
||||
// In preload mode without lobby we wait for a join action before entering
|
||||
const onJoin = (ev: CustomEvent<IWidgetApiRequest>): void => {
|
||||
(async (): Promise<void> => {
|
||||
await defaultDeviceSetup(ev.detail.data as unknown as JoinCallData);
|
||||
await enterRTCSession(rtcSession, perParticipantE2EE);
|
||||
widget!.api.transport.reply(ev.detail, {});
|
||||
})().catch((e) => {
|
||||
logger.error("Error joining RTC session", e);
|
||||
});
|
||||
};
|
||||
widget.lazyActions.on(ElementWidgetActions.JoinCall, onJoin);
|
||||
return (): void => {
|
||||
widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
|
||||
};
|
||||
} else if (widget && !preload && skipLobby) {
|
||||
// No lobby and no preload: we enter the rtc session right away
|
||||
(async (): Promise<void> => {
|
||||
await defaultDeviceSetup({ audioInput: null, videoInput: null });
|
||||
await enterRTCSession(rtcSession, perParticipantE2EE);
|
||||
})().catch((e) => {
|
||||
logger.error("Error joining RTC session", e);
|
||||
});
|
||||
if (skipLobby) {
|
||||
if (widget) {
|
||||
if (preload) {
|
||||
// In preload mode without lobby we wait for a join action before entering
|
||||
const onJoin = (ev: CustomEvent<IWidgetApiRequest>): void => {
|
||||
(async (): Promise<void> => {
|
||||
await defaultDeviceSetup(
|
||||
ev.detail.data as unknown as JoinCallData,
|
||||
);
|
||||
await enterRTCSession(rtcSession, perParticipantE2EE);
|
||||
widget!.api.transport.reply(ev.detail, {});
|
||||
})().catch((e) => {
|
||||
logger.error("Error joining RTC session", e);
|
||||
});
|
||||
};
|
||||
widget.lazyActions.on(ElementWidgetActions.JoinCall, onJoin);
|
||||
return (): void => {
|
||||
widget!.lazyActions.off(ElementWidgetActions.JoinCall, onJoin);
|
||||
};
|
||||
} else {
|
||||
// No lobby and no preload: we enter the rtc session right away
|
||||
(async (): Promise<void> => {
|
||||
await defaultDeviceSetup({ audioInput: null, videoInput: null });
|
||||
await enterRTCSession(rtcSession, perParticipantE2EE);
|
||||
})().catch((e) => {
|
||||
logger.error("Error joining RTC session", e);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
void enterRTCSession(rtcSession, perParticipantE2EE);
|
||||
}
|
||||
}
|
||||
}, [rtcSession, preload, skipLobby, perParticipantE2EE]);
|
||||
|
||||
|
||||
@@ -36,12 +36,14 @@ Please see LICENSE in the repository root for full details.
|
||||
inset-block-end: 0;
|
||||
z-index: 1;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
grid-template-areas: "logo buttons layout";
|
||||
grid-template-columns: minmax(0, var(--inline-content-inset)) 1fr auto 1fr minmax(
|
||||
0,
|
||||
var(--inline-content-inset)
|
||||
);
|
||||
grid-template-areas: ". logo buttons layout .";
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-3x);
|
||||
padding-block: var(--cpd-space-4x);
|
||||
padding-inline: var(--inline-content-inset);
|
||||
padding-block: var(--cpd-space-10x);
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
@@ -64,7 +66,6 @@ Please see LICENSE in the repository root for full details.
|
||||
.footer.overlay.hidden {
|
||||
display: grid;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.footer.overlay:has(:focus-visible) {
|
||||
@@ -83,6 +84,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
.buttons {
|
||||
grid-area: buttons;
|
||||
justify-self: center;
|
||||
display: flex;
|
||||
gap: var(--cpd-space-3x);
|
||||
}
|
||||
@@ -92,15 +94,49 @@ Please see LICENSE in the repository root for full details.
|
||||
justify-self: end;
|
||||
}
|
||||
|
||||
@media (min-height: 400px) {
|
||||
@media (max-width: 660px) {
|
||||
.footer {
|
||||
padding-block: var(--cpd-space-8x);
|
||||
grid-template-areas: ". buttons buttons buttons .";
|
||||
}
|
||||
|
||||
.logo {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.layout {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-height: 800px) {
|
||||
@media (max-width: 370px) {
|
||||
.raiseHand {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 340px) {
|
||||
.invite,
|
||||
.switchCamera,
|
||||
.shareScreen {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-height: 400px) {
|
||||
.footer {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-height: 400px) {
|
||||
.footer {
|
||||
padding-block: var(--cpd-space-10x);
|
||||
padding-block: var(--cpd-space-4x);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-height: 800px) {
|
||||
.footer {
|
||||
padding-block: var(--cpd-space-8x);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
VideoButton,
|
||||
ShareScreenButton,
|
||||
SettingsButton,
|
||||
RaiseHandToggleButton,
|
||||
ReactionToggleButton,
|
||||
SwitchCameraButton,
|
||||
} from "../button";
|
||||
import { Header, LeftNav, RightNav, RoomHeaderInfo } from "../Header";
|
||||
@@ -83,7 +83,10 @@ import { GridTileViewModel, TileViewModel } from "../state/TileViewModel";
|
||||
import { ReactionsProvider, useReactions } from "../useReactions";
|
||||
import handSoundOgg from "../sound/raise_hand.ogg?url";
|
||||
import handSoundMp3 from "../sound/raise_hand.mp3?url";
|
||||
import { ReactionsAudioRenderer } from "./ReactionAudioRenderer";
|
||||
import { useSwitchCamera } from "./useSwitchCamera";
|
||||
import { soundEffectVolumeSetting, useSetting } from "../settings/settings";
|
||||
import { ReactionsOverlay } from "./ReactionsOverlay";
|
||||
|
||||
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
|
||||
|
||||
@@ -179,7 +182,9 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
connState,
|
||||
onShareClick,
|
||||
}) => {
|
||||
const { supportsReactions, raisedHands } = useReactions();
|
||||
const [soundEffectVolume] = useSetting(soundEffectVolumeSetting);
|
||||
const { supportsReactions, raisedHands, sendReaction, toggleRaisedHand } =
|
||||
useReactions();
|
||||
const raisedHandCount = useMemo(
|
||||
() => Object.keys(raisedHands).length,
|
||||
[raisedHands],
|
||||
@@ -198,7 +203,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
|
||||
const containerRef1 = useRef<HTMLDivElement | null>(null);
|
||||
const [containerRef2, bounds] = useMeasure();
|
||||
const boundsValid = bounds.height > 0;
|
||||
// Merge the refs so they can attach to the same element
|
||||
const containerRef = useMergedRefs(containerRef1, containerRef2);
|
||||
|
||||
@@ -224,12 +228,10 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
toggleMicrophone,
|
||||
toggleCamera,
|
||||
(muted) => muteStates.audio.setEnabled?.(!muted),
|
||||
(reaction) => void sendReaction(reaction),
|
||||
() => void toggleRaisedHand(),
|
||||
);
|
||||
|
||||
const mobile = boundsValid && bounds.width <= 660;
|
||||
const reducedControls = boundsValid && bounds.width <= 340;
|
||||
const noControls = reducedControls && bounds.height <= 400;
|
||||
|
||||
const windowMode = useObservableEagerState(vm.windowMode);
|
||||
const layout = useObservableEagerState(vm.layout);
|
||||
const gridMode = useObservableEagerState(vm.gridMode);
|
||||
@@ -251,12 +253,22 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
}, [vm]);
|
||||
const onTouchCancel = useCallback(() => (touchStart.current = null), []);
|
||||
|
||||
// We also need to tell the layout toggle to prevent touch events from
|
||||
// bubbling up, or else the controls will be dismissed before a change event
|
||||
// can be registered on the toggle
|
||||
const onLayoutToggleTouchEnd = useCallback(
|
||||
(e: TouchEvent) => e.stopPropagation(),
|
||||
[],
|
||||
// We also need to tell the footer controls to prevent touch events from
|
||||
// bubbling up, or else the footer will be dismissed before a click/change
|
||||
// event can be registered on the control
|
||||
const onControlsTouchEnd = useCallback(
|
||||
(e: TouchEvent) => {
|
||||
// Somehow applying pointer-events: none to the controls when the footer
|
||||
// is hidden is not enough to stop clicks from happening as the footer
|
||||
// becomes visible, so we check manually whether the footer is shown
|
||||
if (showFooter) {
|
||||
e.stopPropagation();
|
||||
vm.tapControls();
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
[vm, showFooter],
|
||||
);
|
||||
|
||||
const onPointerMove = useCallback(
|
||||
@@ -334,11 +346,17 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
return;
|
||||
}
|
||||
if (previousRaisedHandCount < raisedHandCount) {
|
||||
handRaisePlayer.current.volume = soundEffectVolume;
|
||||
handRaisePlayer.current.play().catch((ex) => {
|
||||
logger.warn("Failed to play raise hand sound", ex);
|
||||
});
|
||||
}
|
||||
}, [raisedHandCount, handRaisePlayer, previousRaisedHandCount]);
|
||||
}, [
|
||||
raisedHandCount,
|
||||
handRaisePlayer,
|
||||
previousRaisedHandCount,
|
||||
soundEffectVolume,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
widget?.api.transport
|
||||
@@ -511,95 +529,105 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
.catch(logger.error);
|
||||
}, [localParticipant, isScreenShareEnabled]);
|
||||
|
||||
let footer: JSX.Element | null;
|
||||
|
||||
if (noControls) {
|
||||
footer = null;
|
||||
} else {
|
||||
const buttons: JSX.Element[] = [];
|
||||
const buttons: JSX.Element[] = [];
|
||||
|
||||
buttons.push(
|
||||
<MicButton
|
||||
key="audio"
|
||||
muted={!muteStates.audio.enabled}
|
||||
onClick={toggleMicrophone}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
disabled={muteStates.audio.setEnabled === null}
|
||||
data-testid="incall_mute"
|
||||
/>,
|
||||
<VideoButton
|
||||
key="video"
|
||||
muted={!muteStates.video.enabled}
|
||||
onClick={toggleCamera}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
disabled={muteStates.video.setEnabled === null}
|
||||
data-testid="incall_videomute"
|
||||
/>,
|
||||
);
|
||||
if (switchCamera !== null)
|
||||
buttons.push(
|
||||
<MicButton
|
||||
key="audio"
|
||||
muted={!muteStates.audio.enabled}
|
||||
onClick={toggleMicrophone}
|
||||
disabled={muteStates.audio.setEnabled === null}
|
||||
data-testid="incall_mute"
|
||||
/>,
|
||||
<VideoButton
|
||||
key="video"
|
||||
muted={!muteStates.video.enabled}
|
||||
onClick={toggleCamera}
|
||||
disabled={muteStates.video.setEnabled === null}
|
||||
data-testid="incall_videomute"
|
||||
<SwitchCameraButton
|
||||
key="switch_camera"
|
||||
className={styles.switchCamera}
|
||||
onClick={switchCamera}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
/>,
|
||||
);
|
||||
if (!reducedControls) {
|
||||
if (switchCamera !== null)
|
||||
buttons.push(
|
||||
<SwitchCameraButton key="switch_camera" onClick={switchCamera} />,
|
||||
);
|
||||
if (canScreenshare && !hideScreensharing) {
|
||||
buttons.push(
|
||||
<ShareScreenButton
|
||||
key="share_screen"
|
||||
enabled={isScreenShareEnabled}
|
||||
onClick={toggleScreensharing}
|
||||
data-testid="incall_screenshare"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
if (supportsReactions) {
|
||||
buttons.push(
|
||||
<RaiseHandToggleButton
|
||||
client={client}
|
||||
rtcSession={rtcSession}
|
||||
key="4"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
buttons.push(<SettingsButton key="settings" onClick={openSettings} />);
|
||||
}
|
||||
|
||||
if (canScreenshare && !hideScreensharing) {
|
||||
buttons.push(
|
||||
<EndCallButton
|
||||
key="end_call"
|
||||
onClick={function (): void {
|
||||
onLeave();
|
||||
}}
|
||||
data-testid="incall_leave"
|
||||
<ShareScreenButton
|
||||
key="share_screen"
|
||||
className={styles.shareScreen}
|
||||
enabled={isScreenShareEnabled}
|
||||
onClick={toggleScreensharing}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
data-testid="incall_screenshare"
|
||||
/>,
|
||||
);
|
||||
footer = (
|
||||
<div
|
||||
ref={footerRef}
|
||||
className={classNames(styles.footer, {
|
||||
[styles.overlay]: windowMode === "flat",
|
||||
[styles.hidden]: !showFooter || (!showControls && hideHeader),
|
||||
})}
|
||||
>
|
||||
{!mobile && !hideHeader && (
|
||||
<div className={styles.logo}>
|
||||
<LogoMark width={24} height={24} aria-hidden />
|
||||
<LogoType
|
||||
width={80}
|
||||
height={11}
|
||||
aria-label={import.meta.env.VITE_PRODUCT_NAME || "Element Call"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{showControls && <div className={styles.buttons}>{buttons}</div>}
|
||||
{!mobile && showControls && (
|
||||
<LayoutToggle
|
||||
className={styles.layout}
|
||||
layout={gridMode}
|
||||
setLayout={setGridMode}
|
||||
onTouchEnd={onLayoutToggleTouchEnd}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (supportsReactions) {
|
||||
buttons.push(
|
||||
<ReactionToggleButton
|
||||
key="raise_hand"
|
||||
className={styles.raiseHand}
|
||||
userId={client.getUserId()!}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
if (layout.type !== "pip")
|
||||
buttons.push(
|
||||
<SettingsButton
|
||||
key="settings"
|
||||
onClick={openSettings}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
/>,
|
||||
);
|
||||
|
||||
buttons.push(
|
||||
<EndCallButton
|
||||
key="end_call"
|
||||
onClick={function (): void {
|
||||
onLeave();
|
||||
}}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
data-testid="incall_leave"
|
||||
/>,
|
||||
);
|
||||
const footer = (
|
||||
<div
|
||||
ref={footerRef}
|
||||
className={classNames(styles.footer, {
|
||||
[styles.overlay]: windowMode === "flat",
|
||||
[styles.hidden]: !showFooter || (!showControls && hideHeader),
|
||||
})}
|
||||
>
|
||||
{!hideHeader && (
|
||||
<div className={styles.logo}>
|
||||
<LogoMark width={24} height={24} aria-hidden />
|
||||
<LogoType
|
||||
width={80}
|
||||
height={11}
|
||||
aria-label={import.meta.env.VITE_PRODUCT_NAME || "Element Call"}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{showControls && <div className={styles.buttons}>{buttons}</div>}
|
||||
{showControls && (
|
||||
<LayoutToggle
|
||||
className={styles.layout}
|
||||
layout={gridMode}
|
||||
setLayout={setGridMode}
|
||||
onTouchEnd={onControlsTouchEnd}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -631,28 +659,37 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
/>
|
||||
</LeftNav>
|
||||
<RightNav>
|
||||
{!reducedControls && showControls && onShareClick !== null && (
|
||||
<InviteButton onClick={onShareClick} />
|
||||
{showControls && onShareClick !== null && (
|
||||
<InviteButton
|
||||
className={styles.invite}
|
||||
onClick={onShareClick}
|
||||
/>
|
||||
)}
|
||||
</RightNav>
|
||||
</Header>
|
||||
))}
|
||||
<RoomAudioRenderer />
|
||||
{renderContent()}
|
||||
<audio ref={handRaisePlayer} hidden>
|
||||
<audio ref={handRaisePlayer} preload="auto" hidden>
|
||||
<source src={handSoundOgg} type="audio/ogg; codecs=vorbis" />
|
||||
<source src={handSoundMp3} type="audio/mpeg" />
|
||||
</audio>
|
||||
<ReactionsAudioRenderer />
|
||||
<ReactionsOverlay />
|
||||
{footer}
|
||||
{!noControls && <RageshakeRequestModal {...rageshakeRequestModalProps} />}
|
||||
<SettingsModal
|
||||
client={client}
|
||||
roomId={rtcSession.room.roomId}
|
||||
open={settingsModalOpen}
|
||||
onDismiss={closeSettings}
|
||||
tab={settingsTab}
|
||||
onTabChange={setSettingsTab}
|
||||
/>
|
||||
{layout.type !== "pip" && (
|
||||
<>
|
||||
<RageshakeRequestModal {...rageshakeRequestModalProps} />
|
||||
<SettingsModal
|
||||
client={client}
|
||||
roomId={rtcSession.room.roomId}
|
||||
open={settingsModalOpen}
|
||||
onDismiss={closeSettings}
|
||||
tab={settingsTab}
|
||||
onTabChange={setSettingsTab}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
181
src/room/ReactionAudioRenderer.test.tsx
Normal file
181
src/room/ReactionAudioRenderer.test.tsx
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { render } from "@testing-library/react";
|
||||
import { afterAll, expect, test } from "vitest";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
import { act, ReactNode } from "react";
|
||||
|
||||
import {
|
||||
MockRoom,
|
||||
MockRTCSession,
|
||||
TestReactionsWrapper,
|
||||
} from "../utils/testReactions";
|
||||
import { ReactionsAudioRenderer } from "./ReactionAudioRenderer";
|
||||
import { GenericReaction, ReactionSet } from "../reactions";
|
||||
import {
|
||||
playReactionsSound,
|
||||
soundEffectVolumeSetting,
|
||||
} from "../settings/settings";
|
||||
|
||||
const memberUserIdAlice = "@alice:example.org";
|
||||
const memberUserIdBob = "@bob:example.org";
|
||||
const memberUserIdCharlie = "@charlie:example.org";
|
||||
const memberEventAlice = "$membership-alice:example.org";
|
||||
const memberEventBob = "$membership-bob:example.org";
|
||||
const memberEventCharlie = "$membership-charlie:example.org";
|
||||
|
||||
const membership: Record<string, string> = {
|
||||
[memberEventAlice]: memberUserIdAlice,
|
||||
[memberEventBob]: memberUserIdBob,
|
||||
[memberEventCharlie]: memberUserIdCharlie,
|
||||
};
|
||||
|
||||
function TestComponent({
|
||||
rtcSession,
|
||||
}: {
|
||||
rtcSession: MockRTCSession;
|
||||
}): ReactNode {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<TestReactionsWrapper rtcSession={rtcSession}>
|
||||
<ReactionsAudioRenderer />
|
||||
</TestReactionsWrapper>
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
const originalPlayFn = window.HTMLMediaElement.prototype.play;
|
||||
afterAll(() => {
|
||||
playReactionsSound.setValue(playReactionsSound.defaultValue);
|
||||
soundEffectVolumeSetting.setValue(soundEffectVolumeSetting.defaultValue);
|
||||
window.HTMLMediaElement.prototype.play = originalPlayFn;
|
||||
});
|
||||
|
||||
test("preloads all audio elements", () => {
|
||||
playReactionsSound.setValue(true);
|
||||
const rtcSession = new MockRTCSession(
|
||||
new MockRoom(memberUserIdAlice),
|
||||
membership,
|
||||
);
|
||||
const { container } = render(<TestComponent rtcSession={rtcSession} />);
|
||||
expect(container.getElementsByTagName("audio")).toHaveLength(
|
||||
// All reactions plus the generic sound
|
||||
ReactionSet.filter((r) => r.sound).length + 1,
|
||||
);
|
||||
});
|
||||
|
||||
test("loads no audio elements when disabled in settings", () => {
|
||||
playReactionsSound.setValue(false);
|
||||
const rtcSession = new MockRTCSession(
|
||||
new MockRoom(memberUserIdAlice),
|
||||
membership,
|
||||
);
|
||||
const { container } = render(<TestComponent rtcSession={rtcSession} />);
|
||||
expect(container.getElementsByTagName("audio")).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("will play an audio sound when there is a reaction", () => {
|
||||
const audioIsPlaying: string[] = [];
|
||||
window.HTMLMediaElement.prototype.play = async function (): Promise<void> {
|
||||
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
||||
return Promise.resolve();
|
||||
};
|
||||
playReactionsSound.setValue(true);
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
render(<TestComponent rtcSession={rtcSession} />);
|
||||
|
||||
// Find the first reaction with a sound effect
|
||||
const chosenReaction = ReactionSet.find((r) => !!r.sound);
|
||||
if (!chosenReaction) {
|
||||
throw Error(
|
||||
"No reactions have sounds configured, this test cannot succeed",
|
||||
);
|
||||
}
|
||||
act(() => {
|
||||
room.testSendReaction(memberEventAlice, chosenReaction, membership);
|
||||
});
|
||||
expect(audioIsPlaying).toHaveLength(1);
|
||||
expect(audioIsPlaying[0]).toContain(chosenReaction.sound?.ogg);
|
||||
});
|
||||
|
||||
test("will play the generic audio sound when there is soundless reaction", () => {
|
||||
const audioIsPlaying: string[] = [];
|
||||
window.HTMLMediaElement.prototype.play = async function (): Promise<void> {
|
||||
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
||||
return Promise.resolve();
|
||||
};
|
||||
playReactionsSound.setValue(true);
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
render(<TestComponent rtcSession={rtcSession} />);
|
||||
|
||||
// Find the first reaction with a sound effect
|
||||
const chosenReaction = ReactionSet.find((r) => !r.sound);
|
||||
if (!chosenReaction) {
|
||||
throw Error(
|
||||
"No reactions have sounds configured, this test cannot succeed",
|
||||
);
|
||||
}
|
||||
act(() => {
|
||||
room.testSendReaction(memberEventAlice, chosenReaction, membership);
|
||||
});
|
||||
expect(audioIsPlaying).toHaveLength(1);
|
||||
expect(audioIsPlaying[0]).toContain(GenericReaction.sound?.ogg);
|
||||
});
|
||||
|
||||
test("will play an audio sound with the correct volume", () => {
|
||||
playReactionsSound.setValue(true);
|
||||
soundEffectVolumeSetting.setValue(0.5);
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
const { getByTestId } = render(<TestComponent rtcSession={rtcSession} />);
|
||||
|
||||
// Find the first reaction with a sound effect
|
||||
const chosenReaction = ReactionSet.find((r) => !!r.sound);
|
||||
if (!chosenReaction) {
|
||||
throw Error(
|
||||
"No reactions have sounds configured, this test cannot succeed",
|
||||
);
|
||||
}
|
||||
act(() => {
|
||||
room.testSendReaction(memberEventAlice, chosenReaction, membership);
|
||||
});
|
||||
expect((getByTestId(chosenReaction.name) as HTMLAudioElement).volume).toEqual(
|
||||
0.5,
|
||||
);
|
||||
});
|
||||
|
||||
test("will play multiple audio sounds when there are multiple different reactions", () => {
|
||||
const audioIsPlaying: string[] = [];
|
||||
window.HTMLMediaElement.prototype.play = async function (): Promise<void> {
|
||||
audioIsPlaying.push((this.children[0] as HTMLSourceElement).src);
|
||||
return Promise.resolve();
|
||||
};
|
||||
playReactionsSound.setValue(true);
|
||||
|
||||
const room = new MockRoom(memberUserIdAlice);
|
||||
const rtcSession = new MockRTCSession(room, membership);
|
||||
render(<TestComponent rtcSession={rtcSession} />);
|
||||
|
||||
// Find the first reaction with a sound effect
|
||||
const [reaction1, reaction2] = ReactionSet.filter((r) => !!r.sound);
|
||||
if (!reaction1 || !reaction2) {
|
||||
throw Error(
|
||||
"No reactions have sounds configured, this test cannot succeed",
|
||||
);
|
||||
}
|
||||
act(() => {
|
||||
room.testSendReaction(memberEventAlice, reaction1, membership);
|
||||
room.testSendReaction(memberEventBob, reaction2, membership);
|
||||
room.testSendReaction(memberEventCharlie, reaction1, membership);
|
||||
});
|
||||
expect(audioIsPlaying).toHaveLength(2);
|
||||
expect(audioIsPlaying[0]).toContain(reaction1.sound?.ogg);
|
||||
expect(audioIsPlaying[1]).toContain(reaction2.sound?.ogg);
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user