mirror of
https://github.com/suitenumerique/meet.git
synced 2026-07-27 12:19:10 +00:00
Compare commits
133 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc9dedb91b | |||
| 3da3641a19 | |||
| 21626b4c4c | |||
| f16cedf5a5 | |||
| 00e4679dc5 | |||
| f76e7f0e51 | |||
| b9ffbd179c | |||
| a3ef1d4a26 | |||
| d11bcc5de9 | |||
| 412914cf01 | |||
| d511aedd39 | |||
| 7edf7d194b | |||
| 6324608a4a | |||
| a402c2f46f | |||
| e21858febe | |||
| 3d615fa582 | |||
| 4293444d3e | |||
| a55a4d5b5d | |||
| dd9a87a33b | |||
| 24242ef01a | |||
| b537cdfd93 | |||
| 80cc7c723f | |||
| e9210213b1 | |||
| 634f1924be | |||
| 4e175a8361 | |||
| c5ce32ef79 | |||
| aaf6b03a25 | |||
| 66bc739411 | |||
| 1b48fa256e | |||
| 053c4a40e9 | |||
| 53d732d802 | |||
| 26ca81db40 | |||
| e6e6a3bde7 | |||
| 26fdaac589 | |||
| 1fd1cb71ba | |||
| c8023573c6 | |||
| 584be7e65b | |||
| 59ec88e84a | |||
| 1b2e0ad431 | |||
| 20464a2845 | |||
| ece6284de2 | |||
| 82e994e5b1 | |||
| 85aa7a7251 | |||
| c4ececd03a | |||
| 57bba04cf3 | |||
| 11e162dbd4 | |||
| e06e9d1496 | |||
| c8cc9909ba | |||
| c218a1f7a2 | |||
| 490aaba30a | |||
| 790d37569c | |||
| 1e140a01b5 | |||
| 4ecb7202ec | |||
| 4b7419fe4a | |||
| 44d3c738d7 | |||
| 888c66a218 | |||
| 86641bd160 | |||
| 3d91af23cc | |||
| 2d0d30ce01 | |||
| 98ae9af84a | |||
| 3dda12ada6 | |||
| 8b2750c413 | |||
| c16c27fa50 | |||
| b3ef57e1b6 | |||
| b554a6a542 | |||
| 574fd6dc89 | |||
| 8d77332a0a | |||
| 0e2c805b41 | |||
| 9782eb8c7c | |||
| f6bc57ba91 | |||
| 4d5aec9a49 | |||
| 74b296aa37 | |||
| 88fadd1d61 | |||
| cac58f49d3 | |||
| 12c27eedac | |||
| 6a7ec95493 | |||
| e41656a760 | |||
| eb90c0f28c | |||
| f3c4b0ac40 | |||
| 038e6368e4 | |||
| 028f20375f | |||
| ccc23ff46a | |||
| e3b7a1f77b | |||
| 69a8eea1ce | |||
| 20493edd07 | |||
| 79f7fcab6e | |||
| ce3a6dab12 | |||
| 1b57dd0ecf | |||
| c6318910c2 | |||
| 03b3630611 | |||
| 5b8c8d493a | |||
| b12fb6bf48 | |||
| a8f64f5a36 | |||
| 6ab5b3300a | |||
| 6189e6454d | |||
| a8b2c56f4b | |||
| b472220151 | |||
| 223cee3828 | |||
| 101be503bf | |||
| 47e2d85471 | |||
| 16321b3cb0 | |||
| 144cb56cda | |||
| e6a15e36b4 | |||
| 3541af5992 | |||
| 68f0ea3639 | |||
| 925eb92c60 | |||
| d965ee7060 | |||
| aef85bb1ab | |||
| 8f59b08088 | |||
| 366998b3d6 | |||
| c8ad0ab24f | |||
| d2bbcb0f51 | |||
| 40457bd68a | |||
| c21c5f604b | |||
| 66350b8fb5 | |||
| 378cc3a651 | |||
| 28f43fb2c0 | |||
| 37eea16a50 | |||
| fe8ed43aae | |||
| 671aa68804 | |||
| 6449aaf7ea | |||
| f8fff3dbdf | |||
| 1715ec10dd | |||
| 8c7aed4b00 | |||
| 217b19e42a | |||
| bd26a0abc1 | |||
| abb708aa49 | |||
| 5d35161ae3 | |||
| 0b6f58bf9c | |||
| 79519fef26 | |||
| d7b1fbaf28 | |||
| 26bc67d1b4 | |||
| b783a8bac6 |
@@ -160,6 +160,21 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ~/.local/bin/pytest -n 2
|
run: ~/.local/bin/pytest -n 2
|
||||||
|
|
||||||
|
lint-front:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: cd src/frontend/ && npm ci
|
||||||
|
|
||||||
|
- name: Check linting
|
||||||
|
run: cd src/frontend/ && npm run lint
|
||||||
|
|
||||||
|
- name: Check format
|
||||||
|
run: cd src/frontend/ && npm run check
|
||||||
|
|
||||||
i18n-crowdin:
|
i18n-crowdin:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ WAIT_DB = @$(COMPOSE_RUN) dockerize -wait tcp://$(DB_HOST):$(DB_PORT
|
|||||||
|
|
||||||
# -- Backend
|
# -- Backend
|
||||||
MANAGE = $(COMPOSE_RUN_APP) python manage.py
|
MANAGE = $(COMPOSE_RUN_APP) python manage.py
|
||||||
MAIL_YARN = $(COMPOSE_RUN) -w /app/src/mail node yarn # FIXME : use npm
|
MAIL_NPM = $(COMPOSE_RUN) -w /app/src/mail node npm
|
||||||
|
|
||||||
# -- Frontend
|
# -- Frontend
|
||||||
PATH_FRONT = ./src/frontend
|
PATH_FRONT = ./src/frontend
|
||||||
@@ -259,19 +259,19 @@ i18n-generate-and-upload: \
|
|||||||
# -- Mail generator
|
# -- Mail generator
|
||||||
|
|
||||||
mails-build: ## Convert mjml files to html and text
|
mails-build: ## Convert mjml files to html and text
|
||||||
@$(MAIL_YARN) build
|
@$(MAIL_NPM) run build
|
||||||
.PHONY: mails-build
|
.PHONY: mails-build
|
||||||
|
|
||||||
mails-build-html-to-plain-text: ## Convert html files to text
|
mails-build-html-to-plain-text: ## Convert html files to text
|
||||||
@$(MAIL_YARN) build-html-to-plain-text
|
@$(MAIL_NPM) run build-html-to-plain-text
|
||||||
.PHONY: mails-build-html-to-plain-text
|
.PHONY: mails-build-html-to-plain-text
|
||||||
|
|
||||||
mails-build-mjml-to-html: ## Convert mjml files to html and text
|
mails-build-mjml-to-html: ## Convert mjml files to html and text
|
||||||
@$(MAIL_YARN) build-mjml-to-html
|
@$(MAIL_NPM) run build-mjml-to-html
|
||||||
.PHONY: mails-build-mjml-to-html
|
.PHONY: mails-build-mjml-to-html
|
||||||
|
|
||||||
mails-install: ## install the mail generator
|
mails-install: ## install the mail generator
|
||||||
@$(MAIL_YARN) install
|
@$(MAIL_NPM) install
|
||||||
.PHONY: mails-install
|
.PHONY: mails-install
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ set -eo pipefail
|
|||||||
REPO_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)"
|
REPO_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd)"
|
||||||
UNSET_USER=0
|
UNSET_USER=0
|
||||||
|
|
||||||
TERRAFORM_DIRECTORY="./env.d/terraform"
|
|
||||||
COMPOSE_FILE="${REPO_DIR}/docker-compose.yml"
|
COMPOSE_FILE="${REPO_DIR}/docker-compose.yml"
|
||||||
COMPOSE_PROJECT="meet"
|
COMPOSE_PROJECT="meet"
|
||||||
|
|
||||||
@@ -92,66 +91,3 @@ function _dc_exec() {
|
|||||||
function _django_manage() {
|
function _django_manage() {
|
||||||
_dc_run "app-dev" python manage.py "$@"
|
_dc_run "app-dev" python manage.py "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# _set_openstack_project: select an OpenStack project from the openrc files defined in the
|
|
||||||
# terraform directory.
|
|
||||||
#
|
|
||||||
# usage: _set_openstack_project
|
|
||||||
#
|
|
||||||
# If necessary the script will prompt the user to choose a project from those available
|
|
||||||
function _set_openstack_project() {
|
|
||||||
|
|
||||||
declare prompt
|
|
||||||
declare -a projects
|
|
||||||
declare -i default=1
|
|
||||||
declare -i choice=0
|
|
||||||
declare -i n_projects
|
|
||||||
|
|
||||||
# List projects by looking in the "./env.d/terraform" directory
|
|
||||||
# and store them in an array
|
|
||||||
read -r -a projects <<< "$(
|
|
||||||
find "${TERRAFORM_DIRECTORY}" -maxdepth 1 -mindepth 1 -type d |
|
|
||||||
sed 's|'"${TERRAFORM_DIRECTORY}\/"'||' |
|
|
||||||
xargs
|
|
||||||
)"
|
|
||||||
nb_projects=${#projects[@]}
|
|
||||||
|
|
||||||
if [[ ${nb_projects} -le 0 ]]; then
|
|
||||||
echo "There are no OpenStack projects defined..." >&2
|
|
||||||
echo "To add one, create a subdirectory in \"${TERRAFORM_DIRECTORY}\" with the name" \
|
|
||||||
"of your project and copy your \"openrc.sh\" file into it." >&2
|
|
||||||
exit 10
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${nb_projects} -gt 1 ]]; then
|
|
||||||
prompt="Select an OpenStack project to target:\\n"
|
|
||||||
for (( i=0; i<nb_projects; i++ )); do
|
|
||||||
prompt+="[$((i+1))] ${projects[$i]}"
|
|
||||||
if [[ $((i+1)) -eq ${default} ]]; then
|
|
||||||
prompt+=" (default)"
|
|
||||||
fi
|
|
||||||
prompt+="\\n"
|
|
||||||
done
|
|
||||||
prompt+="If your OpenStack project is not listed, add it to the \"env.d/terraform\" directory.\\n"
|
|
||||||
prompt+="Your choice: "
|
|
||||||
read -r -p "$(echo -e "${prompt}")" choice
|
|
||||||
|
|
||||||
if [[ ${choice} -gt nb_projects ]]; then
|
|
||||||
(>&2 echo "Invalid choice ${choice} (should be <= ${nb_projects})")
|
|
||||||
exit 11
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${choice} -le 0 ]]; then
|
|
||||||
choice=${default}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
project=${projects[$((choice-1))]}
|
|
||||||
# Check that the openrc.sh file exists for this project
|
|
||||||
if [ ! -f "${TERRAFORM_DIRECTORY}/${project}/openrc.sh" ]; then
|
|
||||||
(>&2 echo "Missing \"openrc.sh\" file in \"${TERRAFORM_DIRECTORY}/${project}\". Check documentation.")
|
|
||||||
exit 12
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "${project}"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/_config.sh"
|
|
||||||
|
|
||||||
project=$(_set_openstack_project)
|
|
||||||
echo "Using \"${project}\" project..."
|
|
||||||
|
|
||||||
source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh"
|
|
||||||
|
|
||||||
# Run Terraform commands in the Hashicorp docker container via docker compose
|
|
||||||
# shellcheck disable=SC2068
|
|
||||||
DOCKER_USER="$(id -u):$(id -g)" \
|
|
||||||
PROJECT="${project}" \
|
|
||||||
docker compose run --rm \
|
|
||||||
-e OS_AUTH_URL \
|
|
||||||
-e OS_IDENTITY_API_VERSION \
|
|
||||||
-e OS_USER_DOMAIN_NAME \
|
|
||||||
-e OS_PROJECT_DOMAIN_NAME \
|
|
||||||
-e OS_TENANT_ID \
|
|
||||||
-e OS_TENANT_NAME \
|
|
||||||
-e OS_USERNAME \
|
|
||||||
-e OS_PASSWORD \
|
|
||||||
-e OS_REGION_NAME \
|
|
||||||
terraform-state "$@"
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
source "$(dirname "${BASH_SOURCE[0]}")/_config.sh"
|
|
||||||
|
|
||||||
project=$(_set_openstack_project)
|
|
||||||
echo "Using \"${project}\" project..."
|
|
||||||
|
|
||||||
source "${TERRAFORM_DIRECTORY}/${project}/openrc.sh"
|
|
||||||
|
|
||||||
# Run Terraform commands in the Hashicorp docker container via docker compose
|
|
||||||
# shellcheck disable=SC2068
|
|
||||||
DOCKER_USER="$(id -u):$(id -g)" \
|
|
||||||
PROJECT="${project}" \
|
|
||||||
docker compose run --rm \
|
|
||||||
-e OS_AUTH_URL \
|
|
||||||
-e OS_IDENTITY_API_VERSION \
|
|
||||||
-e OS_USER_DOMAIN_NAME \
|
|
||||||
-e OS_PROJECT_DOMAIN_NAME \
|
|
||||||
-e OS_TENANT_ID \
|
|
||||||
-e OS_TENANT_NAME \
|
|
||||||
-e OS_USERNAME \
|
|
||||||
-e OS_PASSWORD \
|
|
||||||
-e OS_REGION_NAME \
|
|
||||||
-e TF_VAR_user_name \
|
|
||||||
terraform "$@"
|
|
||||||
+19
-11
@@ -3,20 +3,28 @@
|
|||||||
Whenever we are cooking a new release (e.g. `4.18.1`) we should follow a standard procedure described below:
|
Whenever we are cooking a new release (e.g. `4.18.1`) we should follow a standard procedure described below:
|
||||||
|
|
||||||
1. Create a new branch named: `release/4.18.1`.
|
1. Create a new branch named: `release/4.18.1`.
|
||||||
2. Bump the release number for backend project, frontend projects, and Helm files:
|
2. Bump the release number for backend project, frontend projects, and Helm files:
|
||||||
|
|
||||||
- for backend, update the version number by hand in `pyproject.toml`,
|
- for backend, update the version number by hand in `pyproject.toml`,
|
||||||
- for each frontend projects (`src/frontend`, `src/mail`), run `npm version 4.18.1` in their directory. This will update both their `package.json` and `package-lock.json` for you,
|
- for each frontend projects (`src/frontend`, `src/mail`), run `npm version 4.18.1` in their directory. This will update both their `package.json` and `package-lock.json` for you,
|
||||||
- for Helm, update Docker image tag in files located at `src/helm/env.d` for both `preprod` and `production` environments:
|
- for Helm, update Docker image tag in files located at `src/helm/env.d` for both `preprod` and `production` environments:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
image:
|
image:
|
||||||
repository: lasuite/meet-backend
|
repository: lasuite/meet-backend
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
tag: "v4.18.1" # Replace with your new version number, without forgetting the "v" prefix
|
tag: "v4.18.1" # Replace with your new version number, without forgetting the "v" prefix
|
||||||
```
|
|
||||||
|
...
|
||||||
|
|
||||||
|
frontend:
|
||||||
|
image:
|
||||||
|
repository: lasuite/meet-frontend
|
||||||
|
pullPolicy: Always
|
||||||
|
tag: "v4.18.1" # Replace with your new version number, without forgetting the "v" prefix
|
||||||
|
```
|
||||||
|
|
||||||
The new images don't exist _yet_: they will be created automatically later in the process.
|
The new images don't exist _yet_: they will be created automatically later in the process.
|
||||||
|
|
||||||
3. ~~Update the project's `Changelog` following the [keepachangelog](https://keepachangelog.com/en/0.3.0/) recommendations~~ _we don't keep a changelog yet for now as the project is still in its infancy. Soon™!_
|
3. ~~Update the project's `Changelog` following the [keepachangelog](https://keepachangelog.com/en/0.3.0/) recommendations~~ _we don't keep a changelog yet for now as the project is still in its infancy. Soon™!_
|
||||||
4. Commit your changes with the following format: the 🔖 release emoji, the type of release (patch/minor/patch) and the release version:
|
4. Commit your changes with the following format: the 🔖 release emoji, the type of release (patch/minor/patch) and the release version:
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
find . -name "*.enc.*" -exec sops updatekeys -y {} \;
|
|
||||||
+1
-1
Submodule secrets updated: 9da011f5c2...f5fbc16e6e
@@ -123,7 +123,7 @@ class RoomSerializer(serializers.ModelSerializer):
|
|||||||
if role is not None or instance.is_public:
|
if role is not None or instance.is_public:
|
||||||
slug = f"{instance.id!s}".replace("-", "")
|
slug = f"{instance.id!s}".replace("-", "")
|
||||||
|
|
||||||
username = request.GET.get("username", None)
|
username = request.query_params.get("username", None)
|
||||||
|
|
||||||
output["livekit"] = {
|
output["livekit"] = {
|
||||||
"url": settings.LIVEKIT_CONFIGURATION["url"],
|
"url": settings.LIVEKIT_CONFIGURATION["url"],
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.7 on 2024-08-07 14:38
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0002_create_pg_trgm_extension'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='room',
|
||||||
|
name='configuration',
|
||||||
|
field=models.JSONField(blank=True, default=dict, help_text='Values for Visio parameters to configure the room.', verbose_name='Visio room configuration'),
|
||||||
|
)
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.7 on 2024-08-07 14:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0003_alter_room_configuration'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='user',
|
||||||
|
name='language',
|
||||||
|
field=models.CharField(choices="(('en-us', 'English'), ('fr-fr', 'French'))", default='en-us', help_text='The language in which the user wants to see the interface.', max_length=10, verbose_name='language'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -296,7 +296,7 @@ class Room(Resource):
|
|||||||
|
|
||||||
configuration = models.JSONField(
|
configuration = models.JSONField(
|
||||||
blank=True,
|
blank=True,
|
||||||
default={},
|
default=dict,
|
||||||
verbose_name=_("Visio room configuration"),
|
verbose_name=_("Visio room configuration"),
|
||||||
help_text=_("Values for Visio parameters to configure the room."),
|
help_text=_("Values for Visio parameters to configure the room."),
|
||||||
)
|
)
|
||||||
|
|||||||
+43
-10
@@ -2,6 +2,11 @@
|
|||||||
Utils functions used in the core app
|
Utils functions used in the core app
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# ruff: noqa:S311
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import random
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
@@ -10,8 +15,30 @@ from django.conf import settings
|
|||||||
from livekit.api import AccessToken, VideoGrants
|
from livekit.api import AccessToken, VideoGrants
|
||||||
|
|
||||||
|
|
||||||
|
def generate_color(identity: str) -> str:
|
||||||
|
"""Generates a consistent HSL color based on a given identity string.
|
||||||
|
|
||||||
|
The function seeds the random generator with the identity's hash,
|
||||||
|
ensuring consistent color output. The HSL format allows fine-tuned control
|
||||||
|
over saturation and lightness, empirically adjusted to produce visually
|
||||||
|
appealing and distinct colors. HSL is preferred over hex to constrain the color
|
||||||
|
range and ensure predictability.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# ruff: noqa:S324
|
||||||
|
identity_hash = hashlib.sha1(identity.encode("utf-8"))
|
||||||
|
# Keep only hash's last 16 bits, collisions are not a concern
|
||||||
|
seed = int(identity_hash.hexdigest(), 16) & 0xFFFF
|
||||||
|
random.seed(seed)
|
||||||
|
hue = random.randint(0, 360)
|
||||||
|
saturation = random.randint(50, 75)
|
||||||
|
lightness = random.randint(25, 60)
|
||||||
|
|
||||||
|
return f"hsl({hue}, {saturation}%, {lightness}%)"
|
||||||
|
|
||||||
|
|
||||||
def generate_token(room: str, user, username: Optional[str] = None) -> str:
|
def generate_token(room: str, user, username: Optional[str] = None) -> str:
|
||||||
"""Generate a Livekit access token for a user in a specific room.
|
"""Generate a LiveKit access token for a user in a specific room.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
room (str): The name of the room.
|
room (str): The name of the room.
|
||||||
@@ -22,10 +49,12 @@ def generate_token(room: str, user, username: Optional[str] = None) -> str:
|
|||||||
Returns:
|
Returns:
|
||||||
str: The LiveKit JWT access token.
|
str: The LiveKit JWT access token.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
video_grants = VideoGrants(
|
video_grants = VideoGrants(
|
||||||
room=room,
|
room=room,
|
||||||
room_join=True,
|
room_join=True,
|
||||||
|
room_admin=True,
|
||||||
|
room_record=True,
|
||||||
|
can_update_own_metadata=True,
|
||||||
can_publish_sources=[
|
can_publish_sources=[
|
||||||
"camera",
|
"camera",
|
||||||
"microphone",
|
"microphone",
|
||||||
@@ -34,18 +63,22 @@ def generate_token(room: str, user, username: Optional[str] = None) -> str:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
token = AccessToken(
|
|
||||||
api_key=settings.LIVEKIT_CONFIGURATION["api_key"],
|
|
||||||
api_secret=settings.LIVEKIT_CONFIGURATION["api_secret"],
|
|
||||||
).with_grants(video_grants)
|
|
||||||
|
|
||||||
if user.is_anonymous:
|
if user.is_anonymous:
|
||||||
token.with_identity(str(uuid4()))
|
identity = str(uuid4())
|
||||||
default_username = "Anonymous"
|
default_username = "Anonymous"
|
||||||
else:
|
else:
|
||||||
token.with_identity(user.sub)
|
identity = str(user.sub)
|
||||||
default_username = str(user)
|
default_username = str(user)
|
||||||
|
|
||||||
token.with_name(username or default_username)
|
token = (
|
||||||
|
AccessToken(
|
||||||
|
api_key=settings.LIVEKIT_CONFIGURATION["api_key"],
|
||||||
|
api_secret=settings.LIVEKIT_CONFIGURATION["api_secret"],
|
||||||
|
)
|
||||||
|
.with_grants(video_grants)
|
||||||
|
.with_identity(identity)
|
||||||
|
.with_name(username or default_username)
|
||||||
|
.with_metadata(json.dumps({"color": generate_color(identity)}))
|
||||||
|
)
|
||||||
|
|
||||||
return token.to_jwt()
|
return token.to_jwt()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
from socket import gethostbyname, gethostname
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ class Base(Configuration):
|
|||||||
# Security
|
# Security
|
||||||
ALLOWED_HOSTS = values.ListValue([])
|
ALLOWED_HOSTS = values.ListValue([])
|
||||||
SECRET_KEY = values.Value(None)
|
SECRET_KEY = values.Value(None)
|
||||||
|
SILENCED_SYSTEM_CHECKS = values.ListValue([])
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
ROOT_URLCONF = "meet.urls"
|
ROOT_URLCONF = "meet.urls"
|
||||||
@@ -273,6 +275,7 @@ class Base(Configuration):
|
|||||||
# Easy thumbnails
|
# Easy thumbnails
|
||||||
THUMBNAIL_EXTENSION = "webp"
|
THUMBNAIL_EXTENSION = "webp"
|
||||||
THUMBNAIL_TRANSPARENCY_EXTENSION = "webp"
|
THUMBNAIL_TRANSPARENCY_EXTENSION = "webp"
|
||||||
|
THUMBNAIL_DEFAULT_STORAGE_ALIAS = "default"
|
||||||
THUMBNAIL_ALIASES = {}
|
THUMBNAIL_ALIASES = {}
|
||||||
|
|
||||||
# Celery
|
# Celery
|
||||||
@@ -513,7 +516,11 @@ class Production(Base):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Security
|
# Security
|
||||||
ALLOWED_HOSTS = values.ListValue(None)
|
ALLOWED_HOSTS = [
|
||||||
|
*values.ListValue([], environ_name="ALLOWED_HOSTS"),
|
||||||
|
gethostbyname(gethostname()),
|
||||||
|
]
|
||||||
|
|
||||||
CSRF_TRUSTED_ORIGINS = values.ListValue([])
|
CSRF_TRUSTED_ORIGINS = values.ListValue([])
|
||||||
SECURE_BROWSER_XSS_FILTER = True
|
SECURE_BROWSER_XSS_FILTER = True
|
||||||
SECURE_CONTENT_TYPE_NOSNIFF = True
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
||||||
|
|||||||
+11
-11
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "meet"
|
name = "meet"
|
||||||
version = "0.1.3"
|
version = "0.1.5"
|
||||||
authors = [{ "name" = "DINUM", "email" = "dev@mail.numerique.gouv.fr" }]
|
authors = [{ "name" = "DINUM", "email" = "dev@mail.numerique.gouv.fr" }]
|
||||||
classifiers = [
|
classifiers = [
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
@@ -25,7 +25,7 @@ license = { file = "LICENSE" }
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"boto3==1.34.153",
|
"boto3==1.35.10",
|
||||||
"Brotli==1.1.0",
|
"Brotli==1.1.0",
|
||||||
"celery[redis]==5.4.0",
|
"celery[redis]==5.4.0",
|
||||||
"django-configurations==2.5.1",
|
"django-configurations==2.5.1",
|
||||||
@@ -36,28 +36,28 @@ dependencies = [
|
|||||||
"django-redis==5.4.0",
|
"django-redis==5.4.0",
|
||||||
"django-storages[s3]==1.14.4",
|
"django-storages[s3]==1.14.4",
|
||||||
"django-timezone-field>=5.1",
|
"django-timezone-field>=5.1",
|
||||||
"django==5.0.7",
|
"django==5.1",
|
||||||
"djangorestframework==3.15.2",
|
"djangorestframework==3.15.2",
|
||||||
"drf_spectacular==0.27.2",
|
"drf_spectacular==0.27.2",
|
||||||
"dockerflow==2024.4.2",
|
"dockerflow==2024.4.2",
|
||||||
"easy_thumbnails==2.9",
|
"easy_thumbnails==2.9",
|
||||||
"factory_boy==3.3.0",
|
"factory_boy==3.3.1",
|
||||||
"freezegun==1.5.1",
|
"freezegun==1.5.1",
|
||||||
"gunicorn==22.0.0",
|
"gunicorn==23.0.0",
|
||||||
"jsonschema==4.23.0",
|
"jsonschema==4.23.0",
|
||||||
"june-analytics-python==2.3.0",
|
"june-analytics-python==2.3.0",
|
||||||
"markdown==3.6",
|
"markdown==3.7",
|
||||||
"nested-multipart-parser==1.5.0",
|
"nested-multipart-parser==1.5.0",
|
||||||
"psycopg[binary]==3.2.1",
|
"psycopg[binary]==3.2.1",
|
||||||
"PyJWT==2.9.0",
|
"PyJWT==2.9.0",
|
||||||
"python-frontmatter==1.1.0",
|
"python-frontmatter==1.1.0",
|
||||||
"requests==2.32.3",
|
"requests==2.32.3",
|
||||||
"sentry-sdk==2.12.0",
|
"sentry-sdk==2.13.0",
|
||||||
"url-normalize==1.4.3",
|
"url-normalize==1.4.3",
|
||||||
"WeasyPrint>=60.2",
|
"WeasyPrint>=60.2",
|
||||||
"whitenoise==6.7.0",
|
"whitenoise==6.7.0",
|
||||||
"mozilla-django-oidc==4.0.1",
|
"mozilla-django-oidc==4.0.1",
|
||||||
"livekit-api==0.6.0",
|
"livekit-api==0.7.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
@@ -71,17 +71,17 @@ dev = [
|
|||||||
"django-extensions==3.2.3",
|
"django-extensions==3.2.3",
|
||||||
"drf-spectacular-sidecar==2024.7.1",
|
"drf-spectacular-sidecar==2024.7.1",
|
||||||
"ipdb==0.13.13",
|
"ipdb==0.13.13",
|
||||||
"ipython==8.26.0",
|
"ipython==8.27.0",
|
||||||
"pyfakefs==5.6.0",
|
"pyfakefs==5.6.0",
|
||||||
"pylint-django==2.5.5",
|
"pylint-django==2.5.5",
|
||||||
"pylint==3.2.6",
|
"pylint==3.2.7",
|
||||||
"pytest-cov==5.0.0",
|
"pytest-cov==5.0.0",
|
||||||
"pytest-django==4.8.0",
|
"pytest-django==4.8.0",
|
||||||
"pytest==8.3.2",
|
"pytest==8.3.2",
|
||||||
"pytest-icdiff==0.9",
|
"pytest-icdiff==0.9",
|
||||||
"pytest-xdist==3.6.1",
|
"pytest-xdist==3.6.1",
|
||||||
"responses==0.25.3",
|
"responses==0.25.3",
|
||||||
"ruff==0.5.6",
|
"ruff==0.6.3",
|
||||||
"types-requests==2.32.0.20240712",
|
"types-requests==2.32.0.20240712",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ module.exports = {
|
|||||||
'plugin:react-hooks/recommended',
|
'plugin:react-hooks/recommended',
|
||||||
'plugin:@tanstack/eslint-plugin-query/recommended',
|
'plugin:@tanstack/eslint-plugin-query/recommended',
|
||||||
'plugin:jsx-a11y/recommended',
|
'plugin:jsx-a11y/recommended',
|
||||||
|
'prettier'
|
||||||
],
|
],
|
||||||
ignorePatterns: ['dist', '.eslintrc.cjs', 'styled-system'],
|
ignorePatterns: ['dist', '.eslintrc.cjs', 'styled-system'],
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
|
|||||||
Generated
+138
-47
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "meet",
|
"name": "meet",
|
||||||
"version": "0.1.3",
|
"version": "0.1.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "meet",
|
"name": "meet",
|
||||||
"version": "0.1.3",
|
"version": "0.1.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@livekit/components-react": "2.3.3",
|
"@livekit/components-react": "2.3.3",
|
||||||
"@livekit/components-styles": "1.0.12",
|
"@livekit/components-styles": "1.0.12",
|
||||||
"@pandacss/preset-panda": "0.41.0",
|
"@pandacss/preset-panda": "0.41.0",
|
||||||
|
"@react-aria/toast": "3.0.0-beta.15",
|
||||||
"@remixicon/react": "4.2.0",
|
"@remixicon/react": "4.2.0",
|
||||||
"@tanstack/react-query": "5.49.2",
|
"@tanstack/react-query": "5.49.2",
|
||||||
"hoofd": "1.7.1",
|
"hoofd": "1.7.1",
|
||||||
@@ -23,6 +24,7 @@
|
|||||||
"react-aria-components": "1.2.1",
|
"react-aria-components": "1.2.1",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-i18next": "14.1.3",
|
"react-i18next": "14.1.3",
|
||||||
|
"use-sound": "^4.0.3",
|
||||||
"valtio": "1.13.2",
|
"valtio": "1.13.2",
|
||||||
"wouter": "3.3.0"
|
"wouter": "3.3.0"
|
||||||
},
|
},
|
||||||
@@ -37,10 +39,12 @@
|
|||||||
"@typescript-eslint/parser": "7.13.1",
|
"@typescript-eslint/parser": "7.13.1",
|
||||||
"@vitejs/plugin-react": "4.3.1",
|
"@vitejs/plugin-react": "4.3.1",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
|
"eslint-config-prettier": "9.1.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.9.0",
|
"eslint-plugin-jsx-a11y": "6.9.0",
|
||||||
"eslint-plugin-react-hooks": "4.6.2",
|
"eslint-plugin-react-hooks": "4.6.2",
|
||||||
"eslint-plugin-react-refresh": "0.4.7",
|
"eslint-plugin-react-refresh": "0.4.7",
|
||||||
"postcss": "8.4.39",
|
"postcss": "8.4.39",
|
||||||
|
"prettier": "3.3.3",
|
||||||
"typescript": "5.5.2",
|
"typescript": "5.5.2",
|
||||||
"vite": "5.3.1",
|
"vite": "5.3.1",
|
||||||
"vite-tsconfig-paths": "4.3.2"
|
"vite-tsconfig-paths": "4.3.2"
|
||||||
@@ -1105,9 +1109,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@internationalized/date": {
|
"node_modules/@internationalized/date": {
|
||||||
"version": "3.5.4",
|
"version": "3.5.5",
|
||||||
"resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.5.5.tgz",
|
||||||
"integrity": "sha512-qoVJVro+O0rBaw+8HPjUB1iH8Ihf8oziEnqMnvhJUSuVIrHOuZ6eNLHNvzXJKUvAtaDiqMnRlg8Z2mgh09BlUw==",
|
"integrity": "sha512-H+CfYvOZ0LTJeeLOqm19E3uj/4YjrmOFtBufDHPfvtI80hFAMqtrp7oCACpe4Cil5l8S0Qu/9dYfZc/5lY8WQQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/helpers": "^0.5.0"
|
"@swc/helpers": "^0.5.0"
|
||||||
}
|
}
|
||||||
@@ -1588,6 +1592,21 @@
|
|||||||
"node": "^10 || ^12 || >=14"
|
"node": "^10 || ^12 || >=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@pandacss/node/node_modules/prettier": {
|
||||||
|
"version": "3.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
||||||
|
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"prettier": "bin/prettier.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@pandacss/parser": {
|
"node_modules/@pandacss/parser": {
|
||||||
"version": "0.41.0",
|
"version": "0.41.0",
|
||||||
"resolved": "https://registry.npmjs.org/@pandacss/parser/-/parser-0.41.0.tgz",
|
"resolved": "https://registry.npmjs.org/@pandacss/parser/-/parser-0.41.0.tgz",
|
||||||
@@ -1954,35 +1973,35 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/i18n": {
|
"node_modules/@react-aria/i18n": {
|
||||||
"version": "3.11.1",
|
"version": "3.12.2",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/i18n/-/i18n-3.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/i18n/-/i18n-3.12.2.tgz",
|
||||||
"integrity": "sha512-vuiBHw1kZruNMYeKkTGGnmPyMnM5T+gT8bz97H1FqIq1hQ6OPzmtBZ6W6l6OIMjeHI5oJo4utTwfZl495GALFQ==",
|
"integrity": "sha512-PvEyC6JWylTpe8dQEWqQwV6GiA+pbTxHQd//BxtMSapRW3JT9obObAnb/nFhj3HthkUvqHyj0oO1bfeN+mtD8A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@internationalized/date": "^3.5.4",
|
"@internationalized/date": "^3.5.5",
|
||||||
"@internationalized/message": "^3.1.4",
|
"@internationalized/message": "^3.1.4",
|
||||||
"@internationalized/number": "^3.5.3",
|
"@internationalized/number": "^3.5.3",
|
||||||
"@internationalized/string": "^3.2.3",
|
"@internationalized/string": "^3.2.3",
|
||||||
"@react-aria/ssr": "^3.9.4",
|
"@react-aria/ssr": "^3.9.5",
|
||||||
"@react-aria/utils": "^3.24.1",
|
"@react-aria/utils": "^3.25.2",
|
||||||
"@react-types/shared": "^3.23.1",
|
"@react-types/shared": "^3.24.1",
|
||||||
"@swc/helpers": "^0.5.0"
|
"@swc/helpers": "^0.5.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/interactions": {
|
"node_modules/@react-aria/interactions": {
|
||||||
"version": "3.21.3",
|
"version": "3.22.2",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.21.3.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/interactions/-/interactions-3.22.2.tgz",
|
||||||
"integrity": "sha512-BWIuf4qCs5FreDJ9AguawLVS0lV9UU+sK4CCnbCNNmYqOWY+1+gRXCsnOM32K+oMESBxilAjdHW5n1hsMqYMpA==",
|
"integrity": "sha512-xE/77fRVSlqHp2sfkrMeNLrqf2amF/RyuAS6T5oDJemRSgYM3UoxTbWjucPhfnoW7r32pFPHHgz4lbdX8xqD/g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-aria/ssr": "^3.9.4",
|
"@react-aria/ssr": "^3.9.5",
|
||||||
"@react-aria/utils": "^3.24.1",
|
"@react-aria/utils": "^3.25.2",
|
||||||
"@react-types/shared": "^3.23.1",
|
"@react-types/shared": "^3.24.1",
|
||||||
"@swc/helpers": "^0.5.0"
|
"@swc/helpers": "^0.5.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/label": {
|
"node_modules/@react-aria/label": {
|
||||||
@@ -1998,6 +2017,20 @@
|
|||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@react-aria/landmark": {
|
||||||
|
"version": "3.0.0-beta.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@react-aria/landmark/-/landmark-3.0.0-beta.15.tgz",
|
||||||
|
"integrity": "sha512-EEABy0IFzqoS7r11HoD2YwiGR5LFw4kWDFTFUFwJkRP5tHEzsrEgkKPSPJXScQr5m7tenV6j0/Zzl1+w1ki3lA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@react-aria/utils": "^3.25.2",
|
||||||
|
"@react-types/shared": "^3.24.1",
|
||||||
|
"@swc/helpers": "^0.5.0",
|
||||||
|
"use-sync-external-store": "^1.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-aria/link": {
|
"node_modules/@react-aria/link": {
|
||||||
"version": "3.7.1",
|
"version": "3.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/link/-/link-3.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/link/-/link-3.7.1.tgz",
|
||||||
@@ -2271,9 +2304,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/ssr": {
|
"node_modules/@react-aria/ssr": {
|
||||||
"version": "3.9.4",
|
"version": "3.9.5",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/ssr/-/ssr-3.9.5.tgz",
|
||||||
"integrity": "sha512-4jmAigVq409qcJvQyuorsmBR4+9r3+JEC60wC+Y0MZV0HCtTmm8D9guYXlJMdx0SSkgj0hHAyFm/HvPNFofCoQ==",
|
"integrity": "sha512-xEwGKoysu+oXulibNUSkXf8itW0npHHTa6c4AyYeZIJyRoegeteYuFpZUBPtIDE8RfHdNsSmE1ssOkxRnwbkuQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/helpers": "^0.5.0"
|
"@swc/helpers": "^0.5.0"
|
||||||
},
|
},
|
||||||
@@ -2281,7 +2314,7 @@
|
|||||||
"node": ">= 12"
|
"node": ">= 12"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/switch": {
|
"node_modules/@react-aria/switch": {
|
||||||
@@ -2384,6 +2417,24 @@
|
|||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@react-aria/toast": {
|
||||||
|
"version": "3.0.0-beta.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@react-aria/toast/-/toast-3.0.0-beta.15.tgz",
|
||||||
|
"integrity": "sha512-bg6ZXq4B5JYVt3GXVlf075tQOakcfumbDLnUMaijez4BhacuxF01+IvBPzAVEsARVNXfELoXa7Frb2K54Wgvtw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@react-aria/i18n": "^3.12.2",
|
||||||
|
"@react-aria/interactions": "^3.22.2",
|
||||||
|
"@react-aria/landmark": "3.0.0-beta.15",
|
||||||
|
"@react-aria/utils": "^3.25.2",
|
||||||
|
"@react-stately/toast": "3.0.0-beta.5",
|
||||||
|
"@react-types/button": "^3.9.6",
|
||||||
|
"@react-types/shared": "^3.24.1",
|
||||||
|
"@swc/helpers": "^0.5.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-aria/toggle": {
|
"node_modules/@react-aria/toggle": {
|
||||||
"version": "3.10.4",
|
"version": "3.10.4",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/toggle/-/toggle-3.10.4.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/toggle/-/toggle-3.10.4.tgz",
|
||||||
@@ -2452,18 +2503,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/utils": {
|
"node_modules/@react-aria/utils": {
|
||||||
"version": "3.24.1",
|
"version": "3.25.2",
|
||||||
"resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.24.1.tgz",
|
"resolved": "https://registry.npmjs.org/@react-aria/utils/-/utils-3.25.2.tgz",
|
||||||
"integrity": "sha512-O3s9qhPMd6n42x9sKeJ3lhu5V1Tlnzhu6Yk8QOvDuXf7UGuUjXf9mzfHJt1dYzID4l9Fwm8toczBzPM9t0jc8Q==",
|
"integrity": "sha512-GdIvG8GBJJZygB4L2QJP1Gabyn2mjFsha73I2wSe+o4DYeGWoJiMZRM06PyTIxLH4S7Sn7eVDtsSBfkc2VY/NA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-aria/ssr": "^3.9.4",
|
"@react-aria/ssr": "^3.9.5",
|
||||||
"@react-stately/utils": "^3.10.1",
|
"@react-stately/utils": "^3.10.3",
|
||||||
"@react-types/shared": "^3.23.1",
|
"@react-types/shared": "^3.24.1",
|
||||||
"@swc/helpers": "^0.5.0",
|
"@swc/helpers": "^0.5.0",
|
||||||
"clsx": "^2.0.0"
|
"clsx": "^2.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-aria/visually-hidden": {
|
"node_modules/@react-aria/visually-hidden": {
|
||||||
@@ -2809,6 +2860,18 @@
|
|||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@react-stately/toast": {
|
||||||
|
"version": "3.0.0-beta.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@react-stately/toast/-/toast-3.0.0-beta.5.tgz",
|
||||||
|
"integrity": "sha512-MEdQwcKsexlcJ4YQZ9cN5QSIqTlGGdgC5auzSKXXoq15DHuo4mtHfLzXPgcMDYOhOdmyphMto8Vt+21UL2FOrw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@swc/helpers": "^0.5.0",
|
||||||
|
"use-sync-external-store": "^1.2.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@react-stately/toggle": {
|
"node_modules/@react-stately/toggle": {
|
||||||
"version": "3.7.4",
|
"version": "3.7.4",
|
||||||
"resolved": "https://registry.npmjs.org/@react-stately/toggle/-/toggle-3.7.4.tgz",
|
"resolved": "https://registry.npmjs.org/@react-stately/toggle/-/toggle-3.7.4.tgz",
|
||||||
@@ -2851,14 +2914,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-stately/utils": {
|
"node_modules/@react-stately/utils": {
|
||||||
"version": "3.10.1",
|
"version": "3.10.3",
|
||||||
"resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.1.tgz",
|
"resolved": "https://registry.npmjs.org/@react-stately/utils/-/utils-3.10.3.tgz",
|
||||||
"integrity": "sha512-VS/EHRyicef25zDZcM/ClpzYMC5i2YGN6uegOeQawmgfGjb02yaCX0F0zR69Pod9m2Hr3wunTbtpgVXvYbZItg==",
|
"integrity": "sha512-moClv7MlVSHpbYtQIkm0Cx+on8Pgt1XqtPx6fy9rQFb2DNc9u1G3AUVnqA17buOkH1vLxAtX4MedlxMWyRCYYA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/helpers": "^0.5.0"
|
"@swc/helpers": "^0.5.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-stately/virtualizer": {
|
"node_modules/@react-stately/virtualizer": {
|
||||||
@@ -2887,14 +2950,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-types/button": {
|
"node_modules/@react-types/button": {
|
||||||
"version": "3.9.4",
|
"version": "3.9.6",
|
||||||
"resolved": "https://registry.npmjs.org/@react-types/button/-/button-3.9.4.tgz",
|
"resolved": "https://registry.npmjs.org/@react-types/button/-/button-3.9.6.tgz",
|
||||||
"integrity": "sha512-raeQBJUxBp0axNF74TXB8/H50GY8Q3eV6cEKMbZFP1+Dzr09Ngv0tJBeW0ewAxAguNH5DRoMUAUGIXtSXskVdA==",
|
"integrity": "sha512-8lA+D5JLbNyQikf8M/cPP2cji91aVTcqjrGpDqI7sQnaLFikM8eFR6l1ZWGtZS5MCcbfooko77ha35SYplSQvw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-types/shared": "^3.23.1"
|
"@react-types/shared": "^3.24.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-types/calendar": {
|
"node_modules/@react-types/calendar": {
|
||||||
@@ -3104,11 +3167,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-types/shared": {
|
"node_modules/@react-types/shared": {
|
||||||
"version": "3.23.1",
|
"version": "3.24.1",
|
||||||
"resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.23.1.tgz",
|
"resolved": "https://registry.npmjs.org/@react-types/shared/-/shared-3.24.1.tgz",
|
||||||
"integrity": "sha512-5d+3HbFDxGZjhbMBeFHRQhexMFt4pUce3okyRtUVKbbedQFUrtXSBg9VszgF2RTeQDKDkMCIQDtz5ccP/Lk1gw==",
|
"integrity": "sha512-AUQeGYEm/zDTN6zLzdXolDxz3Jk5dDL7f506F07U8tBwxNNI3WRdhU84G0/AaFikOZzDXhOZDr3MhQMzyE7Ydw==",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@react-types/slider": {
|
"node_modules/@react-types/slider": {
|
||||||
@@ -5700,6 +5763,18 @@
|
|||||||
"url": "https://opencollective.com/eslint"
|
"url": "https://opencollective.com/eslint"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-config-prettier": {
|
||||||
|
"version": "9.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz",
|
||||||
|
"integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"eslint-config-prettier": "bin/cli.js"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=7.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-jsx-a11y": {
|
"node_modules/eslint-plugin-jsx-a11y": {
|
||||||
"version": "6.9.0",
|
"version": "6.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.9.0.tgz",
|
||||||
@@ -6621,6 +6696,11 @@
|
|||||||
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
|
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/howler": {
|
||||||
|
"version": "2.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/howler/-/howler-2.2.4.tgz",
|
||||||
|
"integrity": "sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w=="
|
||||||
|
},
|
||||||
"node_modules/html-parse-stringify": {
|
"node_modules/html-parse-stringify": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz",
|
||||||
@@ -8919,9 +8999,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.2.5",
|
"version": "3.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz",
|
||||||
"integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==",
|
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"prettier": "bin/prettier.cjs"
|
"prettier": "bin/prettier.cjs"
|
||||||
@@ -10088,6 +10168,17 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/use-sound": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/use-sound/-/use-sound-4.0.3.tgz",
|
||||||
|
"integrity": "sha512-L205pEUFIrLsGYsCUKHQVCt0ajs//YQOFbEQeNwaWaqQj3y3st4SuR+rvpMHLmv8hgTcfUFlvMQawZNI3OE18w==",
|
||||||
|
"dependencies": {
|
||||||
|
"howler": "^2.1.3"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/use-sync-external-store": {
|
"node_modules/use-sync-external-store": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz",
|
||||||
|
|||||||
@@ -1,19 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "meet",
|
"name": "meet",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.3",
|
"version": "0.1.5",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "panda codegen && vite",
|
"dev": "panda codegen && vite",
|
||||||
"build": "panda codegen && tsc -b && vite build",
|
"build": "panda codegen && tsc -b && vite build",
|
||||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"i18n:extract": "npx i18next -c i18next-parser.config.json"
|
"i18n:extract": "npx i18next -c i18next-parser.config.json",
|
||||||
|
"format": "prettier --write ./src",
|
||||||
|
"check": "prettier --check ./src"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@livekit/components-react": "2.3.3",
|
"@livekit/components-react": "2.3.3",
|
||||||
"@livekit/components-styles": "1.0.12",
|
"@livekit/components-styles": "1.0.12",
|
||||||
"@pandacss/preset-panda": "0.41.0",
|
"@pandacss/preset-panda": "0.41.0",
|
||||||
|
"@react-aria/toast": "3.0.0-beta.15",
|
||||||
"@remixicon/react": "4.2.0",
|
"@remixicon/react": "4.2.0",
|
||||||
"@tanstack/react-query": "5.49.2",
|
"@tanstack/react-query": "5.49.2",
|
||||||
"hoofd": "1.7.1",
|
"hoofd": "1.7.1",
|
||||||
@@ -26,6 +29,7 @@
|
|||||||
"react-aria-components": "1.2.1",
|
"react-aria-components": "1.2.1",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-i18next": "14.1.3",
|
"react-i18next": "14.1.3",
|
||||||
|
"use-sound": "4.0.3",
|
||||||
"valtio": "1.13.2",
|
"valtio": "1.13.2",
|
||||||
"wouter": "3.3.0"
|
"wouter": "3.3.0"
|
||||||
},
|
},
|
||||||
@@ -40,10 +44,12 @@
|
|||||||
"@typescript-eslint/parser": "7.13.1",
|
"@typescript-eslint/parser": "7.13.1",
|
||||||
"@vitejs/plugin-react": "4.3.1",
|
"@vitejs/plugin-react": "4.3.1",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
|
"eslint-config-prettier": "9.1.0",
|
||||||
"eslint-plugin-jsx-a11y": "6.9.0",
|
"eslint-plugin-jsx-a11y": "6.9.0",
|
||||||
"eslint-plugin-react-hooks": "4.6.2",
|
"eslint-plugin-react-hooks": "4.6.2",
|
||||||
"eslint-plugin-react-refresh": "0.4.7",
|
"eslint-plugin-react-refresh": "0.4.7",
|
||||||
"postcss": "8.4.39",
|
"postcss": "8.4.39",
|
||||||
|
"prettier": "3.3.3",
|
||||||
"typescript": "5.5.2",
|
"typescript": "5.5.2",
|
||||||
"vite": "5.3.1",
|
"vite": "5.3.1",
|
||||||
"vite-tsconfig-paths": "4.3.2"
|
"vite-tsconfig-paths": "4.3.2"
|
||||||
|
|||||||
@@ -58,6 +58,34 @@ const config: Config = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
fade: { from: { opacity: 0 }, to: { opacity: 1 } },
|
fade: { from: { opacity: 0 }, to: { opacity: 1 } },
|
||||||
|
pulse: {
|
||||||
|
'0%': { boxShadow: '0 0 0 0 rgba(255, 255, 255, 0.7)' },
|
||||||
|
'75%': { boxShadow: '0 0 0 30px rgba(255, 255, 255, 0)' },
|
||||||
|
'100%': { boxShadow: '0 0 0 0 rgba(255, 255, 255, 0)' },
|
||||||
|
},
|
||||||
|
active_speaker: {
|
||||||
|
'0%': { height: '4px' },
|
||||||
|
'25%': { height: '8px' },
|
||||||
|
'50%': { height: '6px' },
|
||||||
|
'100%': { height: '16px' },
|
||||||
|
},
|
||||||
|
active_speake_small: {
|
||||||
|
'0%': { height: '4px' },
|
||||||
|
'25%': { height: '6px' },
|
||||||
|
'50%': { height: '4px' },
|
||||||
|
'100%': { height: '8px' },
|
||||||
|
},
|
||||||
|
wave_hand: {
|
||||||
|
'0%': { transform: 'rotate(0deg)' },
|
||||||
|
'20%': { transform: 'rotate(-20deg)' },
|
||||||
|
'80%': { transform: 'rotate(20deg)' },
|
||||||
|
'100%': { transform: 'rotate(0)' },
|
||||||
|
},
|
||||||
|
pulse_mic: {
|
||||||
|
'0%': { color: 'primary', opacity: '1' },
|
||||||
|
'50%': { color: 'primary', opacity: '0.8' },
|
||||||
|
'100%': { color: 'primary', opacity: '1' },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
tokens: defineTokens({
|
tokens: defineTokens({
|
||||||
/* we take a few things from the panda preset but for now we clear out some stuff.
|
/* we take a few things from the panda preset but for now we clear out some stuff.
|
||||||
@@ -199,6 +227,7 @@ const config: Config = {
|
|||||||
text: { value: '{colors.white}' },
|
text: { value: '{colors.white}' },
|
||||||
subtle: { value: '{colors.red.100}' },
|
subtle: { value: '{colors.red.100}' },
|
||||||
'subtle-text': { value: '{colors.red.700}' },
|
'subtle-text': { value: '{colors.red.700}' },
|
||||||
|
...pandaPreset.theme.tokens.colors.red,
|
||||||
},
|
},
|
||||||
success: {
|
success: {
|
||||||
DEFAULT: { value: '{colors.green.700}' },
|
DEFAULT: { value: '{colors.green.700}' },
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+14
-12
@@ -6,13 +6,13 @@ import { QueryClientProvider } from '@tanstack/react-query'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useLang } from 'hoofd'
|
import { useLang } from 'hoofd'
|
||||||
import { Switch, Route } from 'wouter'
|
import { Switch, Route } from 'wouter'
|
||||||
|
import { I18nProvider } from 'react-aria-components'
|
||||||
import { Layout } from './layout/Layout'
|
import { Layout } from './layout/Layout'
|
||||||
import { NotFoundScreen } from './components/NotFoundScreen'
|
import { NotFoundScreen } from './components/NotFoundScreen'
|
||||||
import { routes } from './routes'
|
import { routes } from './routes'
|
||||||
import './i18n/init'
|
import './i18n/init'
|
||||||
import { silenceLiveKitLogs } from "@/utils/livekit.ts";
|
import { silenceLiveKitLogs } from '@/utils/livekit.ts'
|
||||||
import { queryClient } from "@/api/queryClient";
|
import { queryClient } from '@/api/queryClient'
|
||||||
|
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const { i18n } = useTranslation()
|
const { i18n } = useTranslation()
|
||||||
@@ -24,15 +24,17 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<Suspense fallback={null}>
|
<Suspense fallback={null}>
|
||||||
<Layout>
|
<I18nProvider locale={i18n.language}>
|
||||||
<Switch>
|
<Layout>
|
||||||
{Object.entries(routes).map(([, route], i) => (
|
<Switch>
|
||||||
<Route key={i} path={route.path} component={route.Component} />
|
{Object.entries(routes).map(([, route], i) => (
|
||||||
))}
|
<Route key={i} path={route.path} component={route.Component} />
|
||||||
<Route component={NotFoundScreen} />
|
))}
|
||||||
</Switch>
|
<Route component={NotFoundScreen} />
|
||||||
</Layout>
|
</Switch>
|
||||||
<ReactQueryDevtools initialIsOpen={false} />
|
</Layout>
|
||||||
|
<ReactQueryDevtools initialIsOpen={false} />
|
||||||
|
</I18nProvider>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
import { QueryClient } from "@tanstack/react-query";
|
import { QueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
export const queryClient = new QueryClient()
|
export const queryClient = new QueryClient()
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { cva, RecipeVariantProps } from '@/styled-system/css'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
const avatar = cva({
|
||||||
|
base: {
|
||||||
|
backgroundColor: 'transparent',
|
||||||
|
color: 'white',
|
||||||
|
display: 'flex',
|
||||||
|
borderRadius: '50%',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
userSelect: 'none',
|
||||||
|
cursor: 'default',
|
||||||
|
flexGrow: 0,
|
||||||
|
flexShrink: 0,
|
||||||
|
},
|
||||||
|
variants: {
|
||||||
|
context: {
|
||||||
|
list: {
|
||||||
|
width: '32px',
|
||||||
|
height: '32px',
|
||||||
|
fontSize: '1.25rem',
|
||||||
|
},
|
||||||
|
placeholder: {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
context: 'list',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export type AvatarProps = React.HTMLAttributes<HTMLDivElement> & {
|
||||||
|
name?: string
|
||||||
|
bgColor?: string
|
||||||
|
} & RecipeVariantProps<typeof avatar>
|
||||||
|
|
||||||
|
export const Avatar = ({ name, bgColor, context, ...props }: AvatarProps) => {
|
||||||
|
const initial = name?.trim()?.charAt(0) || ''
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: bgColor,
|
||||||
|
}}
|
||||||
|
className={avatar({ context })}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{initial}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,7 +4,10 @@ import { useTranslation } from 'react-i18next'
|
|||||||
import { Center } from '@/styled-system/jsx'
|
import { Center } from '@/styled-system/jsx'
|
||||||
import { Text } from '@/primitives'
|
import { Text } from '@/primitives'
|
||||||
|
|
||||||
export const ErrorScreen = ({ title, body }: {
|
export const ErrorScreen = ({
|
||||||
|
title,
|
||||||
|
body,
|
||||||
|
}: {
|
||||||
title?: string
|
title?: string
|
||||||
body?: string
|
body?: string
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { Button } from '@/primitives'
|
||||||
|
import { useEffect, useRef, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useMediaDeviceSelect } from '@livekit/components-react'
|
||||||
|
|
||||||
|
export const SoundTester = () => {
|
||||||
|
const { t } = useTranslation('settings')
|
||||||
|
const [isPlaying, setIsPlaying] = useState(false)
|
||||||
|
const audioRef = useRef<HTMLAudioElement>(null)
|
||||||
|
|
||||||
|
const { activeDeviceId } = useMediaDeviceSelect({ kind: 'audiooutput' })
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateActiveId = async (deviceId: string) => {
|
||||||
|
try {
|
||||||
|
await audioRef?.current?.setSinkId(deviceId)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error setting sinkId: ${error}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateActiveId(activeDeviceId)
|
||||||
|
}, [activeDeviceId])
|
||||||
|
|
||||||
|
// prevent pausing the sound
|
||||||
|
navigator.mediaSession.setActionHandler('pause', function () {})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
invisible
|
||||||
|
onPress={() => {
|
||||||
|
audioRef?.current?.play()
|
||||||
|
setIsPlaying(true)
|
||||||
|
}}
|
||||||
|
size="sm"
|
||||||
|
isDisabled={isPlaying}
|
||||||
|
fullWidth
|
||||||
|
style={{
|
||||||
|
color: isPlaying ? 'var(--colors-primary)' : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isPlaying ? t('audio.speakers.ongoingTest') : t('audio.speakers.test')}
|
||||||
|
</Button>
|
||||||
|
{/* eslint-disable jsx-a11y/media-has-caption */}
|
||||||
|
<audio
|
||||||
|
ref={audioRef}
|
||||||
|
src="sounds/uprise.mp3"
|
||||||
|
onEnded={() => setIsPlaying(false)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,5 +4,7 @@ export const authUrl = ({
|
|||||||
silent = false,
|
silent = false,
|
||||||
returnTo = window.location.href,
|
returnTo = window.location.href,
|
||||||
} = {}) => {
|
} = {}) => {
|
||||||
return apiUrl(`/authenticate?silent=${encodeURIComponent(silent)}&returnTo=${encodeURIComponent(returnTo)}`)
|
return apiUrl(
|
||||||
|
`/authenticate?silent=${encodeURIComponent(silent)}&returnTo=${encodeURIComponent(returnTo)}`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
import { authUrl } from "@/features/auth";
|
import { authUrl } from '@/features/auth'
|
||||||
|
|
||||||
const SILENT_LOGIN_RETRY_KEY = 'silent-login-retry'
|
const SILENT_LOGIN_RETRY_KEY = 'silent-login-retry'
|
||||||
|
|
||||||
const isRetryAllowed = () => {
|
const isRetryAllowed = () => {
|
||||||
const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY);
|
const lastRetryDate = localStorage.getItem(SILENT_LOGIN_RETRY_KEY)
|
||||||
if (!lastRetryDate) {
|
if (!lastRetryDate) {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
const now = new Date();
|
const now = new Date()
|
||||||
return now.getTime() > Number(lastRetryDate)
|
return now.getTime() > Number(lastRetryDate)
|
||||||
}
|
}
|
||||||
|
|
||||||
const setNextRetryTime = (retryIntervalInSeconds: number) => {
|
const setNextRetryTime = (retryIntervalInSeconds: number) => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const nextRetryTime = now.getTime() + (retryIntervalInSeconds * 1000);
|
const nextRetryTime = now.getTime() + retryIntervalInSeconds * 1000
|
||||||
localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime));
|
localStorage.setItem(SILENT_LOGIN_RETRY_KEY, String(nextRetryTime))
|
||||||
}
|
}
|
||||||
|
|
||||||
const initiateSilentLogin = () => {
|
const initiateSilentLogin = () => {
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { getRouteUrl } from '@/navigation/getRouteUrl'
|
||||||
|
import { Button, Dialog, type DialogProps, P, Text } from '@/primitives'
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { RiCheckLine, RiFileCopyLine, RiSpam2Fill } from '@remixicon/react'
|
||||||
|
|
||||||
|
// fixme - duplication with the InviteDialog
|
||||||
|
export const LaterMeetingDialog = ({
|
||||||
|
roomId,
|
||||||
|
...dialogProps
|
||||||
|
}: { roomId: string } & Omit<DialogProps, 'title'>) => {
|
||||||
|
const { t } = useTranslation('home')
|
||||||
|
const roomUrl = getRouteUrl('room', roomId)
|
||||||
|
|
||||||
|
const [isCopied, setIsCopied] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isCopied) {
|
||||||
|
const timeout = setTimeout(() => setIsCopied(false), 3000)
|
||||||
|
return () => clearTimeout(timeout)
|
||||||
|
}
|
||||||
|
}, [isCopied])
|
||||||
|
|
||||||
|
const [isHovered, setIsHovered] = useState(false)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
isOpen={!!roomId}
|
||||||
|
{...dialogProps}
|
||||||
|
title={t('laterMeetingDialog.heading')}
|
||||||
|
>
|
||||||
|
<P>{t('laterMeetingDialog.description')}</P>
|
||||||
|
<Button
|
||||||
|
variant={isCopied ? 'success' : 'primary'}
|
||||||
|
size="sm"
|
||||||
|
fullWidth
|
||||||
|
aria-label={t('laterMeetingDialog.copy')}
|
||||||
|
style={{
|
||||||
|
justifyContent: 'start',
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
navigator.clipboard.writeText(roomUrl)
|
||||||
|
setIsCopied(true)
|
||||||
|
}}
|
||||||
|
onHoverChange={setIsHovered}
|
||||||
|
>
|
||||||
|
{isCopied ? (
|
||||||
|
<>
|
||||||
|
<RiCheckLine size={18} style={{ marginRight: '8px' }} />
|
||||||
|
{t('laterMeetingDialog.copied')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<RiFileCopyLine
|
||||||
|
size={18}
|
||||||
|
style={{ marginRight: '8px', minWidth: '18px' }}
|
||||||
|
/>
|
||||||
|
{isHovered ? (
|
||||||
|
t('laterMeetingDialog.copy')
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
overflow: 'hidden',
|
||||||
|
userSelect: 'none',
|
||||||
|
textWrap: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{roomUrl.replace(/^https?:\/\//, '')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
<HStack>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
backgroundColor: '#d9e5ff',
|
||||||
|
borderRadius: '50%',
|
||||||
|
padding: '4px',
|
||||||
|
marginTop: '1rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RiSpam2Fill size={22} style={{ fill: '#4c84fc' }} />
|
||||||
|
</div>
|
||||||
|
<Text variant="sm" style={{ marginTop: '1rem' }}>
|
||||||
|
{t('laterMeetingDialog.permissions')}
|
||||||
|
</Text>
|
||||||
|
</HStack>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { DialogTrigger } from 'react-aria-components'
|
import { DialogTrigger } from 'react-aria-components'
|
||||||
import { Button, Text } from '@/primitives'
|
import { Button, Menu, Text } from '@/primitives'
|
||||||
import { HStack } from '@/styled-system/jsx'
|
import { HStack } from '@/styled-system/jsx'
|
||||||
import { navigateTo } from '@/navigation/navigateTo'
|
import { navigateTo } from '@/navigation/navigateTo'
|
||||||
import { Screen } from '@/layout/Screen'
|
import { Screen } from '@/layout/Screen'
|
||||||
@@ -9,18 +9,23 @@ import { generateRoomId } from '@/features/rooms'
|
|||||||
import { authUrl, useUser, UserAware } from '@/features/auth'
|
import { authUrl, useUser, UserAware } from '@/features/auth'
|
||||||
import { JoinMeetingDialog } from '../components/JoinMeetingDialog'
|
import { JoinMeetingDialog } from '../components/JoinMeetingDialog'
|
||||||
import { useCreateRoom } from '@/features/rooms'
|
import { useCreateRoom } from '@/features/rooms'
|
||||||
|
import { usePersistentUserChoices } from '@livekit/components-react'
|
||||||
|
import { menuItemRecipe } from '@/primitives/menuItemRecipe'
|
||||||
|
import { RiAddLine, RiLink } from '@remixicon/react'
|
||||||
|
import { MenuItem, Menu as RACMenu } from 'react-aria-components'
|
||||||
|
import { LaterMeetingDialog } from '@/features/home/components/LaterMeetingDialog'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
export const Home = () => {
|
export const Home = () => {
|
||||||
const { t } = useTranslation('home')
|
const { t } = useTranslation('home')
|
||||||
const { isLoggedIn } = useUser()
|
const { isLoggedIn } = useUser()
|
||||||
|
|
||||||
const { mutateAsync: createRoom } = useCreateRoom({
|
const {
|
||||||
onSuccess: (data) => {
|
userChoices: { username },
|
||||||
navigateTo('room', data.slug, {
|
} = usePersistentUserChoices()
|
||||||
state: { create: true, initialRoomData: data },
|
|
||||||
})
|
const { mutateAsync: createRoom } = useCreateRoom()
|
||||||
}
|
const [laterRoomId, setLaterRoomId] = useState<null | string>(null)
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UserAware>
|
<UserAware>
|
||||||
@@ -38,21 +43,43 @@ export const Home = () => {
|
|||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<HStack gap="gutter">
|
<HStack gap="gutter">
|
||||||
<Button
|
{isLoggedIn ? (
|
||||||
variant="primary"
|
<Menu>
|
||||||
onPress={
|
<Button variant="primary">{t('createMeeting')}</Button>
|
||||||
isLoggedIn
|
<RACMenu>
|
||||||
? async () => {
|
<MenuItem
|
||||||
const slug = generateRoomId()
|
className={menuItemRecipe({ icon: true })}
|
||||||
await createRoom({slug})
|
onAction={async () => {
|
||||||
}
|
const slug = generateRoomId()
|
||||||
: undefined
|
createRoom({ slug, username }).then((data) =>
|
||||||
}
|
navigateTo('room', data.slug, {
|
||||||
href={isLoggedIn ? undefined : authUrl()}
|
state: { create: true, initialRoomData: data },
|
||||||
>
|
})
|
||||||
{isLoggedIn ? t('createMeeting') : t('login', { ns: 'global' })}
|
)
|
||||||
</Button>
|
}}
|
||||||
|
>
|
||||||
|
<RiAddLine size={18} />
|
||||||
|
{t('createMenu.instantOption')}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
className={menuItemRecipe({ icon: true })}
|
||||||
|
onAction={() => {
|
||||||
|
const slug = generateRoomId()
|
||||||
|
createRoom({ slug, username }).then((data) =>
|
||||||
|
setLaterRoomId(data.slug)
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RiLink size={18} />
|
||||||
|
{t('createMenu.laterOption')}
|
||||||
|
</MenuItem>
|
||||||
|
</RACMenu>
|
||||||
|
</Menu>
|
||||||
|
) : (
|
||||||
|
<Button variant="primary" href={authUrl()}>
|
||||||
|
{t('login', { ns: 'global' })}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<DialogTrigger>
|
<DialogTrigger>
|
||||||
<Button variant="primary" outline>
|
<Button variant="primary" outline>
|
||||||
{t('joinMeeting')}
|
{t('joinMeeting')}
|
||||||
@@ -61,6 +88,10 @@ export const Home = () => {
|
|||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
</HStack>
|
</HStack>
|
||||||
</Centered>
|
</Centered>
|
||||||
|
<LaterMeetingDialog
|
||||||
|
roomId={laterRoomId || ''}
|
||||||
|
onOpenChange={() => setLaterRoomId(null)}
|
||||||
|
/>
|
||||||
</Screen>
|
</Screen>
|
||||||
</UserAware>
|
</UserAware>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
import { useEffect } from 'react'
|
||||||
|
import { useRoomContext } from '@livekit/components-react'
|
||||||
|
import { Participant, RemoteParticipant, RoomEvent } from 'livekit-client'
|
||||||
|
import { ToastProvider, toastQueue } from './components/ToastProvider'
|
||||||
|
import { NotificationType } from './NotificationType'
|
||||||
|
import { Div } from '@/primitives'
|
||||||
|
import { isMobileBrowser } from '@livekit/components-core'
|
||||||
|
import { useNotificationSound } from '@/features/notifications/hooks/useSoundNotification'
|
||||||
|
|
||||||
|
export const MainNotificationToast = () => {
|
||||||
|
const room = useRoomContext()
|
||||||
|
const { triggerNotificationSound } = useNotificationSound()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const showJoinNotification = (participant: Participant) => {
|
||||||
|
if (isMobileBrowser()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
triggerNotificationSound(NotificationType.Joined)
|
||||||
|
toastQueue.add(
|
||||||
|
{
|
||||||
|
participant,
|
||||||
|
type: NotificationType.Joined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
room.on(RoomEvent.ParticipantConnected, showJoinNotification)
|
||||||
|
return () => {
|
||||||
|
room.off(RoomEvent.ParticipantConnected, showJoinNotification)
|
||||||
|
}
|
||||||
|
}, [room, triggerNotificationSound])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const removeJoinNotification = (participant: Participant) => {
|
||||||
|
const existingToast = toastQueue.visibleToasts.find(
|
||||||
|
(toast) =>
|
||||||
|
toast.content.participant === participant &&
|
||||||
|
toast.content.type === NotificationType.Joined
|
||||||
|
)
|
||||||
|
if (existingToast) {
|
||||||
|
toastQueue.close(existingToast.key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
room.on(RoomEvent.ParticipantDisconnected, removeJoinNotification)
|
||||||
|
return () => {
|
||||||
|
room.off(RoomEvent.ParticipantConnected, removeJoinNotification)
|
||||||
|
}
|
||||||
|
}, [room])
|
||||||
|
|
||||||
|
// fixme - close all related toasters when hands are lowered remotely
|
||||||
|
useEffect(() => {
|
||||||
|
const decoder = new TextDecoder()
|
||||||
|
|
||||||
|
const handleNotificationReceived = (
|
||||||
|
payload: Uint8Array,
|
||||||
|
participant?: RemoteParticipant
|
||||||
|
) => {
|
||||||
|
if (!participant) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (isMobileBrowser()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const notification = decoder.decode(payload)
|
||||||
|
const existingToast = toastQueue.visibleToasts.find(
|
||||||
|
(toast) =>
|
||||||
|
toast.content.participant === participant &&
|
||||||
|
toast.content.type === NotificationType.Raised
|
||||||
|
)
|
||||||
|
if (existingToast && notification === NotificationType.Lowered) {
|
||||||
|
toastQueue.close(existingToast.key)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!existingToast && notification === NotificationType.Raised) {
|
||||||
|
triggerNotificationSound(NotificationType.Raised)
|
||||||
|
toastQueue.add(
|
||||||
|
{
|
||||||
|
participant,
|
||||||
|
type: NotificationType.Raised,
|
||||||
|
},
|
||||||
|
{ timeout: 5000 }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
room.on(RoomEvent.DataReceived, handleNotificationReceived)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
room.off(RoomEvent.DataReceived, handleNotificationReceived)
|
||||||
|
}
|
||||||
|
}, [room, triggerNotificationSound])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Div position="absolute" bottom={20} right={5} zIndex={1000}>
|
||||||
|
<ToastProvider />
|
||||||
|
</Div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export enum NotificationType {
|
||||||
|
Joined = 'joined',
|
||||||
|
Default = 'default',
|
||||||
|
Raised = 'raised',
|
||||||
|
Lowered = 'lowered',
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { useToast } from '@react-aria/toast'
|
||||||
|
import { Button } from '@/primitives'
|
||||||
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
|
import { ToastState } from '@react-stately/toast'
|
||||||
|
import { styled } from '@/styled-system/jsx'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
import { ToastData } from './ToastProvider'
|
||||||
|
import type { QueuedToast } from '@react-stately/toast'
|
||||||
|
|
||||||
|
export const StyledToastContainer = styled('div', {
|
||||||
|
base: {
|
||||||
|
margin: 0.5,
|
||||||
|
boxShadow:
|
||||||
|
'rgba(0, 0, 0, 0.5) 0px 4px 8px 0px, rgba(0, 0, 0, 0.3) 0px 6px 20px 4px',
|
||||||
|
backgroundColor: '#494c4f',
|
||||||
|
color: 'white',
|
||||||
|
borderRadius: '8px',
|
||||||
|
'&[data-entering]': { animation: 'fade 200ms' },
|
||||||
|
'&[data-exiting]': { animation: 'fade 150ms reverse ease-in' },
|
||||||
|
width: 'fit-content',
|
||||||
|
marginLeft: 'auto',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const StyledToast = styled('div', {
|
||||||
|
base: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '1rem',
|
||||||
|
padding: '10px',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export interface ToastProps {
|
||||||
|
key: string
|
||||||
|
toast: QueuedToast<ToastData>
|
||||||
|
state: ToastState<ToastData>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Toast({ state, ...props }: ToastProps) {
|
||||||
|
const ref = useRef(null)
|
||||||
|
const { toastProps, contentProps, closeButtonProps } = useToast(
|
||||||
|
props,
|
||||||
|
state,
|
||||||
|
ref
|
||||||
|
)
|
||||||
|
return (
|
||||||
|
<StyledToastContainer {...toastProps} ref={ref}>
|
||||||
|
<StyledToast>
|
||||||
|
<div {...contentProps}>{props.toast.content?.message} machine a</div>
|
||||||
|
<Button square size="sm" invisible {...closeButtonProps}>
|
||||||
|
<RiCloseLine color="white" />
|
||||||
|
</Button>
|
||||||
|
</StyledToast>
|
||||||
|
</StyledToastContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import { useToast } from '@react-aria/toast'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
import { Button as RACButton } from 'react-aria-components'
|
||||||
|
import { Track } from 'livekit-client'
|
||||||
|
import Source = Track.Source
|
||||||
|
|
||||||
|
import { useMaybeLayoutContext } from '@livekit/components-react'
|
||||||
|
import { ParticipantTile } from '@/features/rooms/livekit/components/ParticipantTile'
|
||||||
|
import { StyledToastContainer, ToastProps } from './Toast'
|
||||||
|
import { HStack, styled } from '@/styled-system/jsx'
|
||||||
|
import { Div } from '@/primitives'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
const ClickableToast = styled(RACButton, {
|
||||||
|
base: {
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
borderRadius: 'inherit',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export function ToastJoined({ state, ...props }: ToastProps) {
|
||||||
|
const { t } = useTranslation('notifications')
|
||||||
|
const ref = useRef(null)
|
||||||
|
const { toastProps, contentProps, titleProps, closeButtonProps } = useToast(
|
||||||
|
props,
|
||||||
|
state,
|
||||||
|
ref
|
||||||
|
)
|
||||||
|
const layoutContext = useMaybeLayoutContext()
|
||||||
|
const participant = props.toast.content.participant
|
||||||
|
const trackReference = {
|
||||||
|
participant,
|
||||||
|
publication: participant.getTrackPublication(Source.Camera),
|
||||||
|
source: Source.Camera,
|
||||||
|
}
|
||||||
|
const pinParticipant = () => {
|
||||||
|
layoutContext?.pin.dispatch?.({
|
||||||
|
msg: 'set_pin',
|
||||||
|
trackReference,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<StyledToastContainer {...toastProps} ref={ref}>
|
||||||
|
<ClickableToast
|
||||||
|
ref={ref}
|
||||||
|
onPress={(e) => {
|
||||||
|
pinParticipant()
|
||||||
|
closeButtonProps.onPress?.(e)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HStack justify="center" alignItems="center" {...contentProps}>
|
||||||
|
<Div display="flex" overflow="hidden" width="128" height="72">
|
||||||
|
<ParticipantTile
|
||||||
|
trackRef={trackReference}
|
||||||
|
disableSpeakingIndicator={true}
|
||||||
|
disableMetadata={true}
|
||||||
|
style={{
|
||||||
|
borderRadius: '7px 0 0 7px',
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Div>
|
||||||
|
<Div padding={20} {...titleProps}>
|
||||||
|
{t('joined.description', {
|
||||||
|
name: participant.name || t('defaultName'),
|
||||||
|
})}
|
||||||
|
</Div>
|
||||||
|
</HStack>
|
||||||
|
</ClickableToast>
|
||||||
|
</StyledToastContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/* eslint-disable react-refresh/only-export-components */
|
||||||
|
import { ToastQueue, useToastQueue } from '@react-stately/toast'
|
||||||
|
import { ToastRegion } from './ToastRegion'
|
||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { NotificationType } from '../NotificationType'
|
||||||
|
|
||||||
|
export interface ToastData {
|
||||||
|
participant: Participant
|
||||||
|
type: NotificationType
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using a global queue for toasts allows for centralized management and queuing of notifications
|
||||||
|
// from anywhere in the app, providing greater flexibility in complex scenarios.
|
||||||
|
export const toastQueue = new ToastQueue<ToastData>({
|
||||||
|
maxVisibleToasts: 5,
|
||||||
|
})
|
||||||
|
|
||||||
|
export const ToastProvider = ({ ...props }) => {
|
||||||
|
const state = useToastQueue<ToastData>(toastQueue)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{state.visibleToasts.length > 0 && (
|
||||||
|
<ToastRegion {...props} state={state} />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
import { useToast } from '@react-aria/toast'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
|
||||||
|
import { StyledToastContainer, ToastProps } from './Toast'
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { Button, Div } from '@/primitives'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiCloseLine, RiHand } from '@remixicon/react'
|
||||||
|
import { useWidgetInteraction } from '@/features/rooms/livekit/hooks/useWidgetInteraction'
|
||||||
|
|
||||||
|
export function ToastRaised({ state, ...props }: ToastProps) {
|
||||||
|
const { t } = useTranslation('notifications')
|
||||||
|
const ref = useRef(null)
|
||||||
|
const { toastProps, contentProps, titleProps, closeButtonProps } = useToast(
|
||||||
|
props,
|
||||||
|
state,
|
||||||
|
ref
|
||||||
|
)
|
||||||
|
const participant = props.toast.content.participant
|
||||||
|
const { isParticipantsOpen, toggleParticipants } = useWidgetInteraction()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledToastContainer {...toastProps} ref={ref}>
|
||||||
|
<HStack
|
||||||
|
justify="center"
|
||||||
|
alignItems="center"
|
||||||
|
{...contentProps}
|
||||||
|
padding={14}
|
||||||
|
gap={0}
|
||||||
|
>
|
||||||
|
<RiHand
|
||||||
|
color="white"
|
||||||
|
style={{
|
||||||
|
marginRight: '1rem',
|
||||||
|
animationDuration: '300ms',
|
||||||
|
animationName: 'wave_hand',
|
||||||
|
animationIterationCount: '2',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Div {...titleProps} marginRight={0.5}>
|
||||||
|
{t('raised.description', {
|
||||||
|
name: participant.name || t('defaultName'),
|
||||||
|
})}
|
||||||
|
</Div>
|
||||||
|
{!isParticipantsOpen && (
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="text"
|
||||||
|
style={{
|
||||||
|
color: '#60a5fa',
|
||||||
|
}}
|
||||||
|
onPress={(e) => {
|
||||||
|
toggleParticipants()
|
||||||
|
closeButtonProps.onPress?.(e)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('raised.cta')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button square size="sm" invisible {...closeButtonProps}>
|
||||||
|
<RiCloseLine size={18} color="white" />
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
</StyledToastContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { AriaToastRegionProps, useToastRegion } from '@react-aria/toast'
|
||||||
|
import type { ToastState } from '@react-stately/toast'
|
||||||
|
import { Toast } from './Toast'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
import { NotificationType } from '../NotificationType'
|
||||||
|
import { ToastJoined } from './ToastJoined'
|
||||||
|
import { ToastData } from './ToastProvider'
|
||||||
|
import { ToastRaised } from '@/features/notifications/components/ToastRaised.tsx'
|
||||||
|
|
||||||
|
interface ToastRegionProps extends AriaToastRegionProps {
|
||||||
|
state: ToastState<ToastData>
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ToastRegion({ state, ...props }: ToastRegionProps) {
|
||||||
|
const ref = useRef(null)
|
||||||
|
const { regionProps } = useToastRegion(props, state, ref)
|
||||||
|
return (
|
||||||
|
<div {...regionProps} ref={ref} className="toast-region">
|
||||||
|
{state.visibleToasts.map((toast) => {
|
||||||
|
if (toast.content?.type === NotificationType.Joined) {
|
||||||
|
return <ToastJoined key={toast.key} toast={toast} state={state} />
|
||||||
|
}
|
||||||
|
if (toast.content?.type === NotificationType.Raised) {
|
||||||
|
return <ToastRaised key={toast.key} toast={toast} state={state} />
|
||||||
|
}
|
||||||
|
return <Toast key={toast.key} toast={toast} state={state} />
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import useSound from 'use-sound'
|
||||||
|
|
||||||
|
// fixme - handle dynamic audio output changes
|
||||||
|
export const useNotificationSound = () => {
|
||||||
|
const [play] = useSound('./sounds/notifications.mp3', {
|
||||||
|
sprite: {
|
||||||
|
joined: [0, 1150],
|
||||||
|
raised: [1400, 180],
|
||||||
|
message: [1580, 300],
|
||||||
|
waiting: [2039, 710],
|
||||||
|
success: [2740, 1304],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const triggerNotificationSound = (type: string) => {
|
||||||
|
play({ id: type })
|
||||||
|
}
|
||||||
|
return { triggerNotificationSound }
|
||||||
|
}
|
||||||
@@ -9,6 +9,6 @@ export type ApiRoom = {
|
|||||||
token: string
|
token: string
|
||||||
}
|
}
|
||||||
configuration?: {
|
configuration?: {
|
||||||
[key: string]: string | number | boolean;
|
[key: string]: string | number | boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,30 @@
|
|||||||
import { useMutation, UseMutationOptions } from "@tanstack/react-query";
|
import { useMutation, UseMutationOptions } from '@tanstack/react-query'
|
||||||
import { fetchApi } from '@/api/fetchApi';
|
import { fetchApi } from '@/api/fetchApi'
|
||||||
import { ApiError } from "@/api/ApiError";
|
import { ApiError } from '@/api/ApiError'
|
||||||
import { ApiRoom } from "./ApiRoom";
|
import { ApiRoom } from './ApiRoom'
|
||||||
|
|
||||||
export interface CreateRoomParams {
|
export interface CreateRoomParams {
|
||||||
slug: string;
|
slug: string
|
||||||
|
username?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const createRoom = ({slug}: CreateRoomParams): Promise<ApiRoom> => {
|
const createRoom = ({
|
||||||
return fetchApi(`rooms/`, {
|
slug,
|
||||||
|
username = '',
|
||||||
|
}: CreateRoomParams): Promise<ApiRoom> => {
|
||||||
|
return fetchApi(`rooms/?username=${encodeURIComponent(username)}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: slug,
|
name: slug,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
|
export function useCreateRoom(
|
||||||
export function useCreateRoom(options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>) {
|
options?: UseMutationOptions<ApiRoom, ApiError, CreateRoomParams>
|
||||||
|
) {
|
||||||
return useMutation<ApiRoom, ApiError, CreateRoomParams>({
|
return useMutation<ApiRoom, ApiError, CreateRoomParams>({
|
||||||
mutationFn: createRoom,
|
mutationFn: createRoom,
|
||||||
onSuccess: options?.onSuccess,
|
onSuccess: options?.onSuccess,
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import { styled } from '@/styled-system/jsx'
|
||||||
|
|
||||||
|
const StyledContainer = styled('div', {
|
||||||
|
base: {
|
||||||
|
width: '24px',
|
||||||
|
height: '24px',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
backgroundColor: 'primary',
|
||||||
|
borderRadius: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: '2px',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const StyledChild = styled('div', {
|
||||||
|
base: {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
width: '4px',
|
||||||
|
height: '4px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
animationDuration: '400ms',
|
||||||
|
animationName: 'active_speaker',
|
||||||
|
animationIterationCount: 'infinite',
|
||||||
|
animationDirection: 'alternate',
|
||||||
|
},
|
||||||
|
variants: {
|
||||||
|
active: {
|
||||||
|
true: {
|
||||||
|
animationIterationCount: 'infinite',
|
||||||
|
},
|
||||||
|
false: {
|
||||||
|
animationIterationCount: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
small: {
|
||||||
|
animationName: 'active_speake_small',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export const ActiveSpeaker = ({ isSpeaking }: { isSpeaking: boolean }) => {
|
||||||
|
return (
|
||||||
|
<StyledContainer>
|
||||||
|
<StyledChild
|
||||||
|
active={isSpeaking}
|
||||||
|
size="small"
|
||||||
|
style={{
|
||||||
|
animationDelay: '300ms',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<StyledChild
|
||||||
|
active={isSpeaking}
|
||||||
|
style={{
|
||||||
|
animationDelay: '100ms',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<StyledChild
|
||||||
|
active={isSpeaking}
|
||||||
|
size="small"
|
||||||
|
style={{
|
||||||
|
animationDelay: '500ms',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</StyledContainer>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next'
|
|||||||
import {
|
import {
|
||||||
formatChatMessageLinks,
|
formatChatMessageLinks,
|
||||||
LiveKitRoom,
|
LiveKitRoom,
|
||||||
VideoConference,
|
|
||||||
type LocalUserChoices,
|
type LocalUserChoices,
|
||||||
} from '@livekit/components-react'
|
} from '@livekit/components-react'
|
||||||
import { Room, RoomOptions } from 'livekit-client'
|
import { Room, RoomOptions } from 'livekit-client'
|
||||||
@@ -19,6 +18,8 @@ import { ApiRoom } from '../api/ApiRoom'
|
|||||||
import { useCreateRoom } from '../api/createRoom'
|
import { useCreateRoom } from '../api/createRoom'
|
||||||
import { InviteDialog } from './InviteDialog'
|
import { InviteDialog } from './InviteDialog'
|
||||||
|
|
||||||
|
import { VideoConference } from '../livekit/prefabs/VideoConference'
|
||||||
|
|
||||||
export const Conference = ({
|
export const Conference = ({
|
||||||
roomId,
|
roomId,
|
||||||
userConfig,
|
userConfig,
|
||||||
@@ -32,15 +33,23 @@ export const Conference = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const fetchKey = [keys.room, roomId, userConfig.username]
|
const fetchKey = [keys.room, roomId, userConfig.username]
|
||||||
|
|
||||||
const { mutateAsync: createRoom, status: createStatus, isError: isCreateError} = useCreateRoom({
|
const {
|
||||||
|
mutateAsync: createRoom,
|
||||||
|
status: createStatus,
|
||||||
|
isError: isCreateError,
|
||||||
|
} = useCreateRoom({
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
queryClient.setQueryData(fetchKey, data)
|
queryClient.setQueryData(fetchKey, data)
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
|
||||||
const { status: fetchStatus, isError: isFetchError, data } = useQuery({
|
const {
|
||||||
|
status: fetchStatus,
|
||||||
|
isError: isFetchError,
|
||||||
|
data,
|
||||||
|
} = useQuery({
|
||||||
queryKey: fetchKey,
|
queryKey: fetchKey,
|
||||||
enabled: !initialRoomData,
|
staleTime: 6 * 60 * 60 * 1000, // By default, LiveKit access tokens expire 6 hours after generation
|
||||||
initialData: initialRoomData,
|
initialData: initialRoomData,
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
fetchRoom({
|
fetchRoom({
|
||||||
@@ -48,7 +57,7 @@ export const Conference = ({
|
|||||||
username: userConfig.username,
|
username: userConfig.username,
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.statusCode == '404') {
|
if (error.statusCode == '404') {
|
||||||
createRoom({slug: roomId})
|
createRoom({ slug: roomId, username: userConfig.username })
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
retry: false,
|
retry: false,
|
||||||
@@ -92,12 +101,17 @@ export const Conference = ({
|
|||||||
const { t } = useTranslation('rooms')
|
const { t } = useTranslation('rooms')
|
||||||
if (isCreateError) {
|
if (isCreateError) {
|
||||||
// this error screen should be replaced by a proper waiting room for anonymous user.
|
// this error screen should be replaced by a proper waiting room for anonymous user.
|
||||||
return <ErrorScreen title={t('error.createRoom.heading')} body={t('error.createRoom.body')} />
|
return (
|
||||||
|
<ErrorScreen
|
||||||
|
title={t('error.createRoom.heading')}
|
||||||
|
body={t('error.createRoom.body')}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryAware status={isFetchError ? createStatus : fetchStatus}>
|
<QueryAware status={isFetchError ? createStatus : fetchStatus}>
|
||||||
<Screen>
|
<Screen header={false}>
|
||||||
<LiveKitRoom
|
<LiveKitRoom
|
||||||
room={room}
|
room={room}
|
||||||
serverUrl={data?.livekit?.url}
|
serverUrl={data?.livekit?.url}
|
||||||
@@ -106,9 +120,7 @@ export const Conference = ({
|
|||||||
audio={userConfig.audioEnabled}
|
audio={userConfig.audioEnabled}
|
||||||
video={userConfig.videoEnabled}
|
video={userConfig.videoEnabled}
|
||||||
>
|
>
|
||||||
<VideoConference
|
<VideoConference chatMessageFormatter={formatChatMessageLinks} />
|
||||||
chatMessageFormatter={formatChatMessageLinks}
|
|
||||||
/>
|
|
||||||
{showInviteDialog && (
|
{showInviteDialog && (
|
||||||
<InviteDialog
|
<InviteDialog
|
||||||
isOpen={showInviteDialog}
|
isOpen={showInviteDialog}
|
||||||
|
|||||||
@@ -1,8 +1,37 @@
|
|||||||
import { useEffect, useState } from 'react'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { getRouteUrl } from '@/navigation/getRouteUrl'
|
import { getRouteUrl } from '@/navigation/getRouteUrl'
|
||||||
import { Div, Button, Dialog, Input, type DialogProps } from '@/primitives'
|
import { Div, Button, type DialogProps, P } from '@/primitives'
|
||||||
import { HStack } from '@/styled-system/jsx'
|
import { HStack, styled, VStack } from '@/styled-system/jsx'
|
||||||
|
import { Heading, Dialog } from 'react-aria-components'
|
||||||
|
import { Text, text } from '@/primitives/Text'
|
||||||
|
import {
|
||||||
|
RiCheckLine,
|
||||||
|
RiCloseLine,
|
||||||
|
RiFileCopyLine,
|
||||||
|
RiSpam2Fill,
|
||||||
|
} from '@remixicon/react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
|
// fixme - extract in a proper primitive this dialog without overlay
|
||||||
|
const StyledRACDialog = styled(Dialog, {
|
||||||
|
base: {
|
||||||
|
position: 'fixed',
|
||||||
|
left: '0.75rem',
|
||||||
|
bottom: 80,
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
zIndex: 1000,
|
||||||
|
width: '24.5rem',
|
||||||
|
borderRadius: '8px',
|
||||||
|
padding: '1.5rem',
|
||||||
|
boxShadow:
|
||||||
|
'0 1px 2px 0 rgba(60, 64, 67, .3), 0 2px 6px 2px rgba(60, 64, 67, .15)',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
'&[data-entering]': { animation: 'fade 200ms' },
|
||||||
|
'&[data-exiting]': { animation: 'fade 150ms reverse ease-in' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export const InviteDialog = ({
|
export const InviteDialog = ({
|
||||||
roomId,
|
roomId,
|
||||||
@@ -11,48 +40,102 @@ export const InviteDialog = ({
|
|||||||
const { t } = useTranslation('rooms')
|
const { t } = useTranslation('rooms')
|
||||||
const roomUrl = getRouteUrl('room', roomId)
|
const roomUrl = getRouteUrl('room', roomId)
|
||||||
|
|
||||||
const copyLabel = t('shareDialog.copy')
|
const [isCopied, setIsCopied] = useState(false)
|
||||||
const copiedLabel = t('shareDialog.copied')
|
|
||||||
const [copyLinkLabel, setCopyLinkLabel] = useState(copyLabel)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (copyLinkLabel == copiedLabel) {
|
if (isCopied) {
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => setIsCopied(false), 3000)
|
||||||
setCopyLinkLabel(copyLabel)
|
return () => clearTimeout(timeout)
|
||||||
}, 5000)
|
|
||||||
return () => {
|
|
||||||
clearTimeout(timeout)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [copyLinkLabel, copyLabel, copiedLabel])
|
}, [isCopied])
|
||||||
|
|
||||||
|
const [isHovered, setIsHovered] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog {...dialogProps} title={t('shareDialog.heading')}>
|
<StyledRACDialog {...dialogProps}>
|
||||||
<HStack alignItems="stretch" gap="gutter">
|
{({ close }) => (
|
||||||
<Div flex="1">
|
<VStack
|
||||||
<Input
|
alignItems="left"
|
||||||
type="text"
|
justify="start"
|
||||||
aria-label={t('shareDialog.inputLabel')}
|
gap={0}
|
||||||
value={roomUrl}
|
style={{ maxWidth: '100%', overflow: 'hidden' }}
|
||||||
readOnly
|
>
|
||||||
onClick={(e) => {
|
<Heading slot="title" level={3} className={text({ variant: 'h2' })}>
|
||||||
e.currentTarget.select()
|
{t('shareDialog.heading')}
|
||||||
}}
|
</Heading>
|
||||||
/>
|
<Div position="absolute" top="5" right="5">
|
||||||
</Div>
|
<Button
|
||||||
<Div minWidth="8rem">
|
invisible
|
||||||
|
size="xs"
|
||||||
|
onPress={() => {
|
||||||
|
dialogProps.onClose?.()
|
||||||
|
close()
|
||||||
|
}}
|
||||||
|
aria-label={t('closeDialog')}
|
||||||
|
>
|
||||||
|
<RiCloseLine />
|
||||||
|
</Button>
|
||||||
|
</Div>
|
||||||
|
<P>{t('shareDialog.description')}</P>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant={isCopied ? 'success' : 'primary'}
|
||||||
size="sm"
|
size="sm"
|
||||||
fullWidth
|
fullWidth
|
||||||
|
aria-label={t('shareDialog.copy')}
|
||||||
|
style={{
|
||||||
|
justifyContent: 'start',
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
navigator.clipboard.writeText(roomUrl)
|
navigator.clipboard.writeText(roomUrl)
|
||||||
setCopyLinkLabel(copiedLabel)
|
setIsCopied(true)
|
||||||
}}
|
}}
|
||||||
|
onHoverChange={setIsHovered}
|
||||||
>
|
>
|
||||||
{copyLinkLabel}
|
{isCopied ? (
|
||||||
|
<>
|
||||||
|
<RiCheckLine size={18} style={{ marginRight: '8px' }} />
|
||||||
|
{t('shareDialog.copied')}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<RiFileCopyLine
|
||||||
|
size={18}
|
||||||
|
style={{ marginRight: '8px', minWidth: '18px' }}
|
||||||
|
/>
|
||||||
|
{isHovered ? (
|
||||||
|
t('shareDialog.copy')
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
overflow: 'hidden',
|
||||||
|
userSelect: 'none',
|
||||||
|
textWrap: 'nowrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{roomUrl.replace(/^https?:\/\//, '')}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</Div>
|
<HStack>
|
||||||
</HStack>
|
<div
|
||||||
</Dialog>
|
style={{
|
||||||
|
backgroundColor: '#d9e5ff',
|
||||||
|
borderRadius: '50%',
|
||||||
|
padding: '4px',
|
||||||
|
marginTop: '1rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RiSpam2Fill size={22} style={{ fill: '#4c84fc' }} />
|
||||||
|
</div>
|
||||||
|
<Text variant="sm" style={{ marginTop: '1rem' }}>
|
||||||
|
{t('shareDialog.permissions')}
|
||||||
|
</Text>
|
||||||
|
</HStack>
|
||||||
|
</VStack>
|
||||||
|
)}
|
||||||
|
</StyledRACDialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export const buildServerApiUrl = (origin: string, path: string) => {
|
||||||
|
const sanitizedOrigin = origin.replace(/\/$/, '')
|
||||||
|
const sanitizedPath = path.replace(/^\//, '')
|
||||||
|
return `${sanitizedOrigin}/${sanitizedPath}`
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { ApiError } from '@/api/ApiError'
|
||||||
|
|
||||||
|
export const fetchServerApi = async <T = Record<string, unknown>>(
|
||||||
|
url: string,
|
||||||
|
token: string,
|
||||||
|
options?: RequestInit
|
||||||
|
): Promise<T> => {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
...options,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
...options?.headers,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
const result = await response.json()
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new ApiError(response.status, result)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { fetchServerApi } from './fetchServerApi'
|
||||||
|
import { buildServerApiUrl } from './buildServerApiUrl'
|
||||||
|
import { useRoomData } from '../hooks/useRoomData'
|
||||||
|
|
||||||
|
export const useLowerHandParticipant = () => {
|
||||||
|
const data = useRoomData()
|
||||||
|
|
||||||
|
const lowerHandParticipant = (participant: Participant) => {
|
||||||
|
if (!data || !data?.livekit) {
|
||||||
|
throw new Error('Room data is not available')
|
||||||
|
}
|
||||||
|
const newMetadata = JSON.parse(participant.metadata || '{}')
|
||||||
|
newMetadata.raised = !newMetadata.raised
|
||||||
|
return fetchServerApi(
|
||||||
|
buildServerApiUrl(
|
||||||
|
data.livekit.url,
|
||||||
|
'twirp/livekit.RoomService/UpdateParticipant'
|
||||||
|
),
|
||||||
|
data.livekit.token,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
room: data.livekit.room,
|
||||||
|
identity: participant.identity,
|
||||||
|
metadata: JSON.stringify(newMetadata),
|
||||||
|
permission: participant.permissions,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return { lowerHandParticipant }
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { useLowerHandParticipant } from '@/features/rooms/livekit/api/lowerHandParticipant'
|
||||||
|
|
||||||
|
export const useLowerHandParticipants = () => {
|
||||||
|
const { lowerHandParticipant } = useLowerHandParticipant()
|
||||||
|
|
||||||
|
const lowerHandParticipants = (participants: Array<Participant>) => {
|
||||||
|
try {
|
||||||
|
const promises = participants.map((participant) =>
|
||||||
|
lowerHandParticipant(participant)
|
||||||
|
)
|
||||||
|
return Promise.all(promises)
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error('An error occurred while lowering hands.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { lowerHandParticipants }
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { Participant, Track } from 'livekit-client'
|
||||||
|
import Source = Track.Source
|
||||||
|
import { fetchServerApi } from './fetchServerApi'
|
||||||
|
import { buildServerApiUrl } from './buildServerApiUrl'
|
||||||
|
import { useRoomData } from '../hooks/useRoomData'
|
||||||
|
|
||||||
|
export const useMuteParticipant = () => {
|
||||||
|
const data = useRoomData()
|
||||||
|
|
||||||
|
const muteParticipant = (participant: Participant) => {
|
||||||
|
if (!data || !data?.livekit) {
|
||||||
|
throw new Error('Room data is not available')
|
||||||
|
}
|
||||||
|
const trackSid = participant.getTrackPublication(
|
||||||
|
Source.Microphone
|
||||||
|
)?.trackSid
|
||||||
|
|
||||||
|
if (!trackSid) {
|
||||||
|
throw new Error('Missing audio track')
|
||||||
|
}
|
||||||
|
return fetchServerApi(
|
||||||
|
buildServerApiUrl(
|
||||||
|
data.livekit.url,
|
||||||
|
'twirp/livekit.RoomService/MutePublishedTrack'
|
||||||
|
),
|
||||||
|
data.livekit.token,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
room: data.livekit.room,
|
||||||
|
identity: participant.identity,
|
||||||
|
muted: true,
|
||||||
|
track_sid: trackSid,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return { muteParticipant }
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { fetchServerApi } from './fetchServerApi'
|
||||||
|
import { buildServerApiUrl } from './buildServerApiUrl'
|
||||||
|
import { useRoomData } from '../hooks/useRoomData'
|
||||||
|
import { useParams } from 'wouter'
|
||||||
|
|
||||||
|
export const useRecordRoom = () => {
|
||||||
|
const data = useRoomData()
|
||||||
|
const { roomId: roomSlug } = useParams()
|
||||||
|
|
||||||
|
const recordRoom = () => {
|
||||||
|
if (!data || !data?.livekit) {
|
||||||
|
throw new Error('Room data is not available')
|
||||||
|
}
|
||||||
|
if (!roomSlug) {
|
||||||
|
throw new Error('Room ID is not available')
|
||||||
|
}
|
||||||
|
return fetchServerApi(
|
||||||
|
buildServerApiUrl(
|
||||||
|
data.livekit.url,
|
||||||
|
'/twirp/livekit.Egress/StartRoomCompositeEgress'
|
||||||
|
),
|
||||||
|
data.livekit.token,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
room_name: data.livekit.room,
|
||||||
|
audio_only: true,
|
||||||
|
file_outputs: [
|
||||||
|
{
|
||||||
|
file_extension: 'ogg',
|
||||||
|
filepath: `{room_name}_{time}_${roomSlug}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const stopRecordingRoom = (egressId: string) => {
|
||||||
|
if (!data || !data?.livekit) {
|
||||||
|
throw new Error('Room data is not available')
|
||||||
|
}
|
||||||
|
return fetchServerApi(
|
||||||
|
buildServerApiUrl(data.livekit.url, '/twirp/livekit.Egress/StopEgress'),
|
||||||
|
data.livekit.token,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
|
egressId,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return { recordRoom, stopRecordingRoom }
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { ParticipantTile } from './ParticipantTile'
|
||||||
|
import { FocusLayoutProps } from '@livekit/components-react'
|
||||||
|
|
||||||
|
export function FocusLayout({ trackRef, ...htmlProps }: FocusLayoutProps) {
|
||||||
|
return <ParticipantTile trackRef={trackRef} {...htmlProps} />
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { useTrackMutedIndicator } from '@livekit/components-react'
|
||||||
|
import { Participant, Track } from 'livekit-client'
|
||||||
|
import Source = Track.Source
|
||||||
|
import { Div } from '@/primitives'
|
||||||
|
import { RiMicOffFill } from '@remixicon/react'
|
||||||
|
|
||||||
|
export const MutedMicIndicator = ({
|
||||||
|
participant,
|
||||||
|
}: {
|
||||||
|
participant: Participant
|
||||||
|
}) => {
|
||||||
|
const { isMuted } = useTrackMutedIndicator({
|
||||||
|
participant: participant,
|
||||||
|
source: Source.Microphone,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!isMuted) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Div padding={0.25} backgroundColor="red" borderRadius="4px">
|
||||||
|
<RiMicOffFill size={16} color="white" />
|
||||||
|
</Div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { styled } from '@/styled-system/jsx'
|
||||||
|
import { Avatar } from '@/components/Avatar'
|
||||||
|
import { useIsSpeaking } from '@livekit/components-react'
|
||||||
|
import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'
|
||||||
|
import { useSize } from '@/features/rooms/livekit/hooks/useResizeObserver'
|
||||||
|
import { useMemo, useRef } from 'react'
|
||||||
|
|
||||||
|
const StyledParticipantPlaceHolder = styled('div', {
|
||||||
|
base: {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
backgroundColor: '#3d4043', // fixme - copied from gmeet
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
type ParticipantPlaceholderProps = {
|
||||||
|
participant: Participant
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ParticipantPlaceholder = ({
|
||||||
|
participant,
|
||||||
|
}: ParticipantPlaceholderProps) => {
|
||||||
|
const isSpeaking = useIsSpeaking(participant)
|
||||||
|
const participantColor = getParticipantColor(participant)
|
||||||
|
|
||||||
|
const placeholderEl = useRef<HTMLDivElement>(null)
|
||||||
|
const { width, height } = useSize(placeholderEl)
|
||||||
|
|
||||||
|
const minDimension = Math.min(width, height)
|
||||||
|
const avatarSize = useMemo(
|
||||||
|
() => Math.min(Math.round(minDimension * 0.9), 160),
|
||||||
|
[minDimension]
|
||||||
|
)
|
||||||
|
|
||||||
|
const initialSize = useMemo(() => Math.round(avatarSize * 0.3), [avatarSize])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledParticipantPlaceHolder ref={placeholderEl}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
borderRadius: '50%',
|
||||||
|
animation: isSpeaking ? 'pulse 1s infinite' : undefined,
|
||||||
|
height: 'auto',
|
||||||
|
aspectRatio: '1/1',
|
||||||
|
width: '80%',
|
||||||
|
maxWidth: `${avatarSize}px`,
|
||||||
|
fontSize: `${initialSize}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/*fixme - participant doesn't update on ParticipantNameChanged event */}
|
||||||
|
<Avatar
|
||||||
|
name={participant.name}
|
||||||
|
bgColor={participantColor}
|
||||||
|
context="placeholder"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</StyledParticipantPlaceHolder>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
import {
|
||||||
|
AudioTrack,
|
||||||
|
ConnectionQualityIndicator,
|
||||||
|
FocusToggle,
|
||||||
|
LockLockedIcon,
|
||||||
|
ParticipantName,
|
||||||
|
ParticipantTileProps,
|
||||||
|
ScreenShareIcon,
|
||||||
|
useEnsureTrackRef,
|
||||||
|
useFeatureContext,
|
||||||
|
useIsEncrypted,
|
||||||
|
useMaybeLayoutContext,
|
||||||
|
useMaybeTrackRefContext,
|
||||||
|
useParticipantTile,
|
||||||
|
VideoTrack,
|
||||||
|
TrackRefContext,
|
||||||
|
ParticipantContextIfNeeded,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
import React from 'react'
|
||||||
|
import {
|
||||||
|
isTrackReference,
|
||||||
|
isTrackReferencePinned,
|
||||||
|
TrackReferenceOrPlaceholder,
|
||||||
|
} from '@livekit/components-core'
|
||||||
|
import { Track } from 'livekit-client'
|
||||||
|
import { ParticipantPlaceholder } from '@/features/rooms/livekit/components/ParticipantPlaceholder'
|
||||||
|
import { RiHand } from '@remixicon/react'
|
||||||
|
import { useRaisedHand } from '@/features/rooms/livekit/hooks/useRaisedHand'
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { MutedMicIndicator } from '@/features/rooms/livekit/components/MutedMicIndicator'
|
||||||
|
|
||||||
|
export function TrackRefContextIfNeeded(
|
||||||
|
props: React.PropsWithChildren<{
|
||||||
|
trackRef?: TrackReferenceOrPlaceholder
|
||||||
|
}>
|
||||||
|
) {
|
||||||
|
const hasContext = !!useMaybeTrackRefContext()
|
||||||
|
return props.trackRef && !hasContext ? (
|
||||||
|
<TrackRefContext.Provider value={props.trackRef}>
|
||||||
|
{props.children}
|
||||||
|
</TrackRefContext.Provider>
|
||||||
|
) : (
|
||||||
|
<>{props.children}</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ParticipantTileExtendedProps extends ParticipantTileProps {
|
||||||
|
disableMetadata?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ParticipantTile: (
|
||||||
|
props: ParticipantTileExtendedProps & React.RefAttributes<HTMLDivElement>
|
||||||
|
) => React.ReactNode = /* @__PURE__ */ React.forwardRef<
|
||||||
|
HTMLDivElement,
|
||||||
|
ParticipantTileExtendedProps
|
||||||
|
>(function ParticipantTile(
|
||||||
|
{
|
||||||
|
trackRef,
|
||||||
|
children,
|
||||||
|
onParticipantClick,
|
||||||
|
disableSpeakingIndicator,
|
||||||
|
disableMetadata,
|
||||||
|
...htmlProps
|
||||||
|
}: ParticipantTileExtendedProps,
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
const trackReference = useEnsureTrackRef(trackRef)
|
||||||
|
|
||||||
|
const { elementProps } = useParticipantTile<HTMLDivElement>({
|
||||||
|
htmlProps,
|
||||||
|
disableSpeakingIndicator,
|
||||||
|
onParticipantClick,
|
||||||
|
trackRef: trackReference,
|
||||||
|
})
|
||||||
|
const isEncrypted = useIsEncrypted(trackReference.participant)
|
||||||
|
const layoutContext = useMaybeLayoutContext()
|
||||||
|
|
||||||
|
const autoManageSubscription = useFeatureContext()?.autoSubscription
|
||||||
|
|
||||||
|
const handleSubscribe = React.useCallback(
|
||||||
|
(subscribed: boolean) => {
|
||||||
|
if (
|
||||||
|
trackReference.source &&
|
||||||
|
!subscribed &&
|
||||||
|
layoutContext &&
|
||||||
|
layoutContext.pin.dispatch &&
|
||||||
|
isTrackReferencePinned(trackReference, layoutContext.pin.state)
|
||||||
|
) {
|
||||||
|
layoutContext.pin.dispatch({ msg: 'clear_pin' })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[trackReference, layoutContext]
|
||||||
|
)
|
||||||
|
|
||||||
|
const { isHandRaised } = useRaisedHand({
|
||||||
|
participant: trackReference.participant,
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div ref={ref} style={{ position: 'relative' }} {...elementProps}>
|
||||||
|
<TrackRefContextIfNeeded trackRef={trackReference}>
|
||||||
|
<ParticipantContextIfNeeded participant={trackReference.participant}>
|
||||||
|
{children ?? (
|
||||||
|
<>
|
||||||
|
{isTrackReference(trackReference) &&
|
||||||
|
(trackReference.publication?.kind === 'video' ||
|
||||||
|
trackReference.source === Track.Source.Camera ||
|
||||||
|
trackReference.source === Track.Source.ScreenShare) ? (
|
||||||
|
<VideoTrack
|
||||||
|
trackRef={trackReference}
|
||||||
|
onSubscriptionStatusChanged={handleSubscribe}
|
||||||
|
manageSubscription={autoManageSubscription}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
isTrackReference(trackReference) && (
|
||||||
|
<AudioTrack
|
||||||
|
trackRef={trackReference}
|
||||||
|
onSubscriptionStatusChanged={handleSubscribe}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
<div className="lk-participant-placeholder">
|
||||||
|
<ParticipantPlaceholder
|
||||||
|
participant={trackReference.participant}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{!disableMetadata && (
|
||||||
|
<div className="lk-participant-metadata">
|
||||||
|
<HStack gap={0.25}>
|
||||||
|
<MutedMicIndicator
|
||||||
|
participant={trackReference.participant}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
className="lk-participant-metadata-item"
|
||||||
|
style={{
|
||||||
|
minHeight: '24px',
|
||||||
|
backgroundColor: isHandRaised ? 'white' : undefined,
|
||||||
|
color: isHandRaised ? 'black' : undefined,
|
||||||
|
transition: 'background 200ms ease, color 400ms ease',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{trackReference.source === Track.Source.Camera ? (
|
||||||
|
<>
|
||||||
|
{isHandRaised && (
|
||||||
|
<RiHand
|
||||||
|
color="black"
|
||||||
|
size={16}
|
||||||
|
style={{
|
||||||
|
marginInlineEnd: '.25rem', // fixme - match TrackMutedIndicator styling
|
||||||
|
animationDuration: '300ms',
|
||||||
|
animationName: 'wave_hand',
|
||||||
|
animationIterationCount: '2',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{isEncrypted && (
|
||||||
|
<LockLockedIcon
|
||||||
|
style={{ marginRight: '0.25rem' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<ParticipantName />
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<ScreenShareIcon style={{ marginRight: '0.25rem' }} />
|
||||||
|
<ParticipantName>'s screen</ParticipantName>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</HStack>
|
||||||
|
<ConnectionQualityIndicator className="lk-participant-metadata-item" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{!disableMetadata && <FocusToggle trackRef={trackReference} />}
|
||||||
|
</ParticipantContextIfNeeded>
|
||||||
|
</TrackRefContextIfNeeded>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { useRoomContext } from '@livekit/components-react'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { RoomEvent } from 'livekit-client'
|
||||||
|
|
||||||
|
export const RecordingIndicator = () => {
|
||||||
|
const room = useRoomContext()
|
||||||
|
const [isRecording, setIsRecording] = useState(room.isRecording)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleRecordingStatusChanges = (isRecording: boolean) => {
|
||||||
|
setIsRecording(isRecording)
|
||||||
|
}
|
||||||
|
room.on(RoomEvent.RecordingStatusChanged, handleRecordingStatusChanges)
|
||||||
|
return () => {
|
||||||
|
room.off(RoomEvent.RecordingStatusChanged, handleRecordingStatusChanges)
|
||||||
|
}
|
||||||
|
}, [room])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexDirection: 'column',
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Room is recording: {isRecording ? 'yes' : 'no'}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiChat1Line } from '@remixicon/react'
|
||||||
|
import { ToggleButton } from '@/primitives'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useWidgetInteraction } from '../../hooks/useWidgetInteraction'
|
||||||
|
|
||||||
|
export const ChatToggle = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
const { isChatOpen, unreadMessages, toggleChat } = useWidgetInteraction()
|
||||||
|
const tooltipLabel = isChatOpen ? 'open' : 'closed'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'relative',
|
||||||
|
display: 'inline-block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<ToggleButton
|
||||||
|
square
|
||||||
|
legacyStyle
|
||||||
|
aria-label={t(`controls.chat.${tooltipLabel}`)}
|
||||||
|
tooltip={t(`controls.chat.${tooltipLabel}`)}
|
||||||
|
isSelected={isChatOpen}
|
||||||
|
onPress={() => toggleChat()}
|
||||||
|
>
|
||||||
|
<RiChat1Line />
|
||||||
|
</ToggleButton>
|
||||||
|
{!!unreadMessages && (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'absolute',
|
||||||
|
top: '-.25rem',
|
||||||
|
right: '-.25rem',
|
||||||
|
width: '1rem',
|
||||||
|
height: '1rem',
|
||||||
|
backgroundColor: 'red',
|
||||||
|
borderRadius: '50%',
|
||||||
|
zIndex: 1,
|
||||||
|
border: '2px solid #d1d5db',
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiHand } from '@remixicon/react'
|
||||||
|
import { ToggleButton } from '@/primitives'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useRoomContext } from '@livekit/components-react'
|
||||||
|
import { useRaisedHand } from '@/features/rooms/livekit/hooks/useRaisedHand'
|
||||||
|
import { NotificationType } from '@/features/notifications/NotificationType'
|
||||||
|
|
||||||
|
export const HandToggle = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
const room = useRoomContext()
|
||||||
|
const { isHandRaised, toggleRaisedHand } = useRaisedHand({
|
||||||
|
participant: room.localParticipant,
|
||||||
|
})
|
||||||
|
|
||||||
|
const label = isHandRaised
|
||||||
|
? t('controls.hand.lower')
|
||||||
|
: t('controls.hand.raise')
|
||||||
|
|
||||||
|
const notifyOtherParticipants = (isHandRaised: boolean) => {
|
||||||
|
room.localParticipant.publishData(
|
||||||
|
new TextEncoder().encode(
|
||||||
|
!isHandRaised ? NotificationType.Raised : NotificationType.Lowered
|
||||||
|
),
|
||||||
|
{
|
||||||
|
reliable: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'relative',
|
||||||
|
display: 'inline-block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<ToggleButton
|
||||||
|
square
|
||||||
|
legacyStyle
|
||||||
|
aria-label={label}
|
||||||
|
tooltip={label}
|
||||||
|
isSelected={isHandRaised}
|
||||||
|
onPress={() => {
|
||||||
|
notifyOtherParticipants(isHandRaised)
|
||||||
|
toggleRaisedHand()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<RiHand />
|
||||||
|
</ToggleButton>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiMore2Line } from '@remixicon/react'
|
||||||
|
import { Button, Menu } from '@/primitives'
|
||||||
|
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { OptionsMenuItems } from '@/features/rooms/livekit/components/controls/Options/OptionsMenuItems'
|
||||||
|
import { SettingsDialogExtended } from '@/features/settings/components/SettingsDialogExtended'
|
||||||
|
|
||||||
|
export type DialogState = 'username' | 'settings' | null
|
||||||
|
|
||||||
|
export const OptionsButton = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const [dialogOpen, setDialogOpen] = useState<DialogState>(null)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Menu>
|
||||||
|
<Button
|
||||||
|
square
|
||||||
|
legacyStyle
|
||||||
|
aria-label={t('options.buttonLabel')}
|
||||||
|
tooltip={t('options.buttonLabel')}
|
||||||
|
>
|
||||||
|
<RiMore2Line />
|
||||||
|
</Button>
|
||||||
|
<OptionsMenuItems onOpenDialog={setDialogOpen} />
|
||||||
|
</Menu>
|
||||||
|
<SettingsDialogExtended
|
||||||
|
isOpen={dialogOpen === 'settings'}
|
||||||
|
onOpenChange={(v) => !v && setDialogOpen(null)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
import { menuItemRecipe } from '@/primitives/menuItemRecipe'
|
||||||
|
import {
|
||||||
|
RiFeedbackLine,
|
||||||
|
RiQuestionLine,
|
||||||
|
RiSettings3Line,
|
||||||
|
} from '@remixicon/react'
|
||||||
|
import { MenuItem, Menu as RACMenu } from 'react-aria-components'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Dispatch, SetStateAction } from 'react'
|
||||||
|
import { DialogState } from '@/features/rooms/livekit/components/controls/Options/OptionsButton'
|
||||||
|
import { RecordingMenuItem } from './RecordingMenuItem.tsx'
|
||||||
|
|
||||||
|
// @todo try refactoring it to use MenuList component
|
||||||
|
export const OptionsMenuItems = ({
|
||||||
|
onOpenDialog,
|
||||||
|
}: {
|
||||||
|
onOpenDialog: Dispatch<SetStateAction<DialogState>>
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<RACMenu
|
||||||
|
style={{
|
||||||
|
minWidth: '150px',
|
||||||
|
width: '300px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem
|
||||||
|
href="https://tchap.gouv.fr/#/room/!aGImQayAgBLjSBycpm:agent.dinum.tchap.gouv.fr?via=agent.dinum.tchap.gouv.fr"
|
||||||
|
target="_blank"
|
||||||
|
className={menuItemRecipe({ icon: true })}
|
||||||
|
>
|
||||||
|
<RiQuestionLine size={18} />
|
||||||
|
{t('options.items.support')}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
href="https://grist.incubateur.net/o/docs/forms/1YrfNP1QSSy8p2gCxMFnSf/4"
|
||||||
|
target="_blank"
|
||||||
|
className={menuItemRecipe({ icon: true })}
|
||||||
|
>
|
||||||
|
<RiFeedbackLine size={18} />
|
||||||
|
{t('options.items.feedbacks')}
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
className={menuItemRecipe({ icon: true })}
|
||||||
|
onAction={() => onOpenDialog('settings')}
|
||||||
|
>
|
||||||
|
<RiSettings3Line size={18} />
|
||||||
|
{t('options.items.settings')}
|
||||||
|
</MenuItem>
|
||||||
|
<RecordingMenuItem />
|
||||||
|
</RACMenu>
|
||||||
|
)
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
import { MenuItem } from 'react-aria-components'
|
||||||
|
import { menuItemRecipe } from '@/primitives/menuItemRecipe.ts'
|
||||||
|
import { RiPauseCircleLine, RiRecordCircleLine } from '@remixicon/react'
|
||||||
|
import { useRecordRoom } from '@/features/rooms/livekit/api/recordRoom.ts'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { egressStore } from '@/stores/egress.tsx'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
|
||||||
|
export const RecordingMenuItem = () => {
|
||||||
|
const { recordRoom, stopRecordingRoom } = useRecordRoom()
|
||||||
|
|
||||||
|
const egressSnap = useSnapshot(egressStore)
|
||||||
|
const egressId = egressSnap.egressId
|
||||||
|
|
||||||
|
const [isPending, setIsPending] = useState(false)
|
||||||
|
|
||||||
|
const handleAction = async () => {
|
||||||
|
if (egressId) {
|
||||||
|
setIsPending(true)
|
||||||
|
const response = await stopRecordingRoom(egressId)
|
||||||
|
console.log(response)
|
||||||
|
egressStore.egressId = undefined
|
||||||
|
setIsPending(false)
|
||||||
|
} else {
|
||||||
|
setIsPending(true)
|
||||||
|
const response = await recordRoom()
|
||||||
|
egressStore.egressId = response['egress_id'] as string
|
||||||
|
setIsPending(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
isDisabled={isPending}
|
||||||
|
className={menuItemRecipe({ icon: true })}
|
||||||
|
onAction={handleAction}
|
||||||
|
>
|
||||||
|
{egressId ? (
|
||||||
|
<>
|
||||||
|
<RiPauseCircleLine size={18} />
|
||||||
|
Stop recording room
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<RiRecordCircleLine size={18} />
|
||||||
|
Record room
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</MenuItem>
|
||||||
|
)
|
||||||
|
}
|
||||||
+81
@@ -0,0 +1,81 @@
|
|||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { Text } from '@/primitives/Text'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Avatar } from '@/components/Avatar'
|
||||||
|
import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'
|
||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { isLocal } from '@/utils/livekit'
|
||||||
|
import { RiHand } from '@remixicon/react'
|
||||||
|
import { useLowerHandParticipant } from '@/features/rooms/livekit/api/lowerHandParticipant.ts'
|
||||||
|
import { Button } from '@/primitives'
|
||||||
|
|
||||||
|
type HandRaisedListItemProps = {
|
||||||
|
participant: Participant
|
||||||
|
}
|
||||||
|
|
||||||
|
export const HandRaisedListItem = ({
|
||||||
|
participant,
|
||||||
|
}: HandRaisedListItemProps) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const name = participant.name || participant.identity
|
||||||
|
|
||||||
|
const { lowerHandParticipant } = useLowerHandParticipant()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HStack
|
||||||
|
role="listitem"
|
||||||
|
justify="space-between"
|
||||||
|
key={participant.identity}
|
||||||
|
id={participant.identity}
|
||||||
|
className={css({
|
||||||
|
padding: '0.25rem 0',
|
||||||
|
width: 'full',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<HStack>
|
||||||
|
<Avatar name={name} bgColor={getParticipantColor(participant)} />
|
||||||
|
<Text
|
||||||
|
variant={'sm'}
|
||||||
|
className={css({
|
||||||
|
userSelect: 'none',
|
||||||
|
cursor: 'default',
|
||||||
|
display: 'flex',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={css({
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
maxWidth: '120px',
|
||||||
|
display: 'block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</span>
|
||||||
|
{isLocal(participant) && (
|
||||||
|
<span
|
||||||
|
className={css({
|
||||||
|
marginLeft: '.25rem',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
({t('participants.you')})
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</HStack>
|
||||||
|
<Button
|
||||||
|
square
|
||||||
|
invisible
|
||||||
|
size="sm"
|
||||||
|
onPress={() => lowerHandParticipant(participant)}
|
||||||
|
tooltip={t('participants.lowerParticipantHand', { name })}
|
||||||
|
>
|
||||||
|
<RiHand />
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
)
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
import { Button } from '@/primitives'
|
||||||
|
import { useLowerHandParticipants } from '@/features/rooms/livekit/api/lowerHandParticipants'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
|
||||||
|
type LowerAllHandsButtonProps = {
|
||||||
|
participants: Array<Participant>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LowerAllHandsButton = ({
|
||||||
|
participants,
|
||||||
|
}: LowerAllHandsButtonProps) => {
|
||||||
|
const { lowerHandParticipants } = useLowerHandParticipants()
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
aria-label={t('participants.lowerParticipantsHand')}
|
||||||
|
size="sm"
|
||||||
|
fullWidth
|
||||||
|
variant="text"
|
||||||
|
onPress={() => lowerHandParticipants(participants)}
|
||||||
|
>
|
||||||
|
{t('participants.lowerParticipantsHand')}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
+162
@@ -0,0 +1,162 @@
|
|||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { Text } from '@/primitives/Text'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { Avatar } from '@/components/Avatar'
|
||||||
|
import { getParticipantColor } from '@/features/rooms/utils/getParticipantColor'
|
||||||
|
import { Participant, Track } from 'livekit-client'
|
||||||
|
import { isLocal } from '@/utils/livekit'
|
||||||
|
import {
|
||||||
|
useIsSpeaking,
|
||||||
|
useTrackMutedIndicator,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
import Source = Track.Source
|
||||||
|
import { RiMicFill, RiMicOffFill } from '@remixicon/react'
|
||||||
|
import { Button, Dialog, P } from '@/primitives'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useMuteParticipant } from '@/features/rooms/livekit/api/muteParticipant'
|
||||||
|
|
||||||
|
const MuteAlertDialog = ({
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
onSubmit,
|
||||||
|
name,
|
||||||
|
}: {
|
||||||
|
isOpen: boolean
|
||||||
|
onClose: () => void
|
||||||
|
onSubmit: () => void
|
||||||
|
name: string
|
||||||
|
}) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
return (
|
||||||
|
<Dialog isOpen={isOpen} role="alertdialog">
|
||||||
|
<P>{t('participants.muteParticipantAlert.description', { name })}</P>
|
||||||
|
<HStack gap={1}>
|
||||||
|
<Button variant="text" size="sm" onPress={onClose}>
|
||||||
|
{t('participants.muteParticipantAlert.cancel')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="text" size="sm" onPress={onSubmit}>
|
||||||
|
{t('participants.muteParticipantAlert.confirm')}
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type MicIndicatorProps = {
|
||||||
|
participant: Participant
|
||||||
|
}
|
||||||
|
|
||||||
|
const MicIndicator = ({ participant }: MicIndicatorProps) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const { muteParticipant } = useMuteParticipant()
|
||||||
|
const { isMuted } = useTrackMutedIndicator({
|
||||||
|
participant: participant,
|
||||||
|
source: Source.Microphone,
|
||||||
|
})
|
||||||
|
const isSpeaking = useIsSpeaking(participant)
|
||||||
|
const [isAlertOpen, setIsAlertOpen] = useState(false)
|
||||||
|
const name = participant.name || participant.identity
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
square
|
||||||
|
invisible
|
||||||
|
size="sm"
|
||||||
|
tooltip={
|
||||||
|
isLocal(participant)
|
||||||
|
? t('participants.muteYourself')
|
||||||
|
: t('participants.muteParticipant', {
|
||||||
|
name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
isDisabled={isMuted}
|
||||||
|
onPress={() =>
|
||||||
|
!isMuted && isLocal(participant)
|
||||||
|
? muteParticipant(participant)
|
||||||
|
: setIsAlertOpen(true)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{isMuted ? (
|
||||||
|
<RiMicOffFill color={'gray'} />
|
||||||
|
) : (
|
||||||
|
<RiMicFill
|
||||||
|
style={{
|
||||||
|
animation: isSpeaking ? 'pulse_mic 800ms infinite' : undefined,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Button>
|
||||||
|
<MuteAlertDialog
|
||||||
|
isOpen={isAlertOpen}
|
||||||
|
onSubmit={() =>
|
||||||
|
muteParticipant(participant).then(() => setIsAlertOpen(false))
|
||||||
|
}
|
||||||
|
onClose={() => setIsAlertOpen(false)}
|
||||||
|
name={name}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ParticipantListItemProps = {
|
||||||
|
participant: Participant
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ParticipantListItem = ({
|
||||||
|
participant,
|
||||||
|
}: ParticipantListItemProps) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const name = participant.name || participant.identity
|
||||||
|
return (
|
||||||
|
<HStack
|
||||||
|
role="listitem"
|
||||||
|
justify="space-between"
|
||||||
|
key={participant.identity}
|
||||||
|
id={participant.identity}
|
||||||
|
className={css({
|
||||||
|
padding: '0.25rem 0',
|
||||||
|
width: 'full',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<HStack>
|
||||||
|
<Avatar name={name} bgColor={getParticipantColor(participant)} />
|
||||||
|
<Text
|
||||||
|
variant={'sm'}
|
||||||
|
className={css({
|
||||||
|
userSelect: 'none',
|
||||||
|
cursor: 'default',
|
||||||
|
display: 'flex',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={css({
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
maxWidth: '120px',
|
||||||
|
display: 'block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{name}
|
||||||
|
</span>
|
||||||
|
{isLocal(participant) && (
|
||||||
|
<span
|
||||||
|
className={css({
|
||||||
|
marginLeft: '.25rem',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
({t('participants.you')})
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</Text>
|
||||||
|
</HStack>
|
||||||
|
<HStack>
|
||||||
|
<MicIndicator participant={participant} />
|
||||||
|
</HStack>
|
||||||
|
</HStack>
|
||||||
|
)
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
import { useState } from 'react'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { ToggleButton } from 'react-aria-components'
|
||||||
|
import { HStack, styled, VStack } from '@/styled-system/jsx'
|
||||||
|
import { RiArrowUpSLine } from '@remixicon/react'
|
||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
|
const ToggleHeader = styled(ToggleButton, {
|
||||||
|
base: {
|
||||||
|
minHeight: '40px', //fixme hardcoded value
|
||||||
|
paddingRight: '.5rem',
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
width: '100%',
|
||||||
|
alignItems: 'center',
|
||||||
|
transition: 'background 200ms',
|
||||||
|
borderTopRadius: '7px',
|
||||||
|
'&[data-hovered]': {
|
||||||
|
backgroundColor: '#f5f5f5',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const Container = styled('div', {
|
||||||
|
base: {
|
||||||
|
border: '1px solid #dadce0',
|
||||||
|
borderRadius: '8px',
|
||||||
|
margin: '0 .625rem',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const ListContainer = styled(VStack, {
|
||||||
|
base: {
|
||||||
|
borderTop: '1px solid #dadce0',
|
||||||
|
alignItems: 'start',
|
||||||
|
overflowY: 'scroll',
|
||||||
|
overflowX: 'hidden',
|
||||||
|
minHeight: 0,
|
||||||
|
flexGrow: 1,
|
||||||
|
display: 'flex',
|
||||||
|
paddingY: '0.5rem',
|
||||||
|
paddingX: '1rem',
|
||||||
|
gap: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
type ParticipantsCollapsableListProps = {
|
||||||
|
heading: string
|
||||||
|
participants: Array<Participant>
|
||||||
|
renderParticipant: (participant: Participant) => JSX.Element
|
||||||
|
action?: () => JSX.Element
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ParticipantsCollapsableList = ({
|
||||||
|
heading,
|
||||||
|
participants,
|
||||||
|
renderParticipant,
|
||||||
|
action,
|
||||||
|
}: ParticipantsCollapsableListProps) => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const [isOpen, setIsOpen] = useState(true)
|
||||||
|
const label = t(`participants.collapsable.${isOpen ? 'close' : 'open'}`, {
|
||||||
|
name: heading,
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<ToggleHeader
|
||||||
|
isSelected={isOpen}
|
||||||
|
aria-label={label}
|
||||||
|
onPress={() => setIsOpen(!isOpen)}
|
||||||
|
style={{
|
||||||
|
borderRadius: !isOpen ? '7px' : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HStack
|
||||||
|
justify="space-between"
|
||||||
|
className={css({
|
||||||
|
margin: '0 1.25rem',
|
||||||
|
width: '100%',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
fontSize: '1rem',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{heading}
|
||||||
|
</div>
|
||||||
|
<div>{participants?.length || 0}</div>
|
||||||
|
</HStack>
|
||||||
|
<RiArrowUpSLine
|
||||||
|
size={32}
|
||||||
|
style={{
|
||||||
|
transform: isOpen ? 'rotate(-180deg)' : undefined,
|
||||||
|
transition: 'transform 200ms',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ToggleHeader>
|
||||||
|
{isOpen && (
|
||||||
|
<ListContainer>
|
||||||
|
{action && action()}
|
||||||
|
{participants.map((participant) => renderParticipant(participant))}
|
||||||
|
</ListContainer>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
)
|
||||||
|
}
|
||||||
+118
@@ -0,0 +1,118 @@
|
|||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useParticipants } from '@livekit/components-react'
|
||||||
|
|
||||||
|
import { Heading } from 'react-aria-components'
|
||||||
|
import { Box, Button, Div, H } from '@/primitives'
|
||||||
|
import { text } from '@/primitives/Text'
|
||||||
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
|
import { participantsStore } from '@/stores/participants'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { allParticipantRoomEvents } from '@/features/rooms/livekit/constants/events'
|
||||||
|
import { ParticipantListItem } from '@/features/rooms/livekit/components/controls/Participants/ParticipantListItem'
|
||||||
|
import { ParticipantsCollapsableList } from '@/features/rooms/livekit/components/controls/Participants/ParticipantsCollapsableList'
|
||||||
|
import { HandRaisedListItem } from '@/features/rooms/livekit/components/controls/Participants/HandRaisedListItem'
|
||||||
|
import { LowerAllHandsButton } from '@/features/rooms/livekit/components/controls/Participants/LowerAllHandsButton'
|
||||||
|
|
||||||
|
// TODO: Optimize rendering performance, especially for longer participant lists, even though they are generally short.
|
||||||
|
export const ParticipantsList = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
// Preferred using the 'useParticipants' hook rather than the separate remote and local hooks,
|
||||||
|
// because the 'useLocalParticipant' hook does not update the participant's information when their
|
||||||
|
// metadata/name changes. The LiveKit team has marked this as a TODO item in the code.
|
||||||
|
const participants = useParticipants({
|
||||||
|
updateOnlyOn: allParticipantRoomEvents,
|
||||||
|
})
|
||||||
|
|
||||||
|
const sortedRemoteParticipants = participants
|
||||||
|
.slice(1)
|
||||||
|
.sort((participantA, participantB) => {
|
||||||
|
const nameA = participantA.name || participantA.identity
|
||||||
|
const nameB = participantB.name || participantB.identity
|
||||||
|
return nameA.localeCompare(nameB)
|
||||||
|
})
|
||||||
|
|
||||||
|
const sortedParticipants = [
|
||||||
|
participants[0], // first participant returned by the hook, is always the local one
|
||||||
|
...sortedRemoteParticipants,
|
||||||
|
]
|
||||||
|
|
||||||
|
const raisedHandParticipants = participants.filter((participant) => {
|
||||||
|
const data = JSON.parse(participant.metadata || '{}')
|
||||||
|
return data.raised
|
||||||
|
})
|
||||||
|
|
||||||
|
// TODO - extract inline styling in a centralized styling file, and avoid magic numbers
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
size="sm"
|
||||||
|
minWidth="360px"
|
||||||
|
className={css({
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
margin: '1.5rem 1.5rem 1.5rem 0',
|
||||||
|
padding: 0,
|
||||||
|
gap: 0,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<Heading
|
||||||
|
slot="title"
|
||||||
|
level={1}
|
||||||
|
className={text({ variant: 'h2' })}
|
||||||
|
style={{
|
||||||
|
paddingLeft: '1.5rem',
|
||||||
|
paddingTop: '1rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('participants.heading')}
|
||||||
|
</Heading>
|
||||||
|
<Div position="absolute" top="5" right="5">
|
||||||
|
<Button
|
||||||
|
invisible
|
||||||
|
size="xs"
|
||||||
|
onPress={() => (participantsStore.showParticipants = false)}
|
||||||
|
aria-label={t('participants.closeButton')}
|
||||||
|
tooltip={t('participants.closeButton')}
|
||||||
|
>
|
||||||
|
<RiCloseLine />
|
||||||
|
</Button>
|
||||||
|
</Div>
|
||||||
|
<Div overflowY="scroll">
|
||||||
|
<H
|
||||||
|
lvl={2}
|
||||||
|
className={css({
|
||||||
|
fontSize: '0.875rem',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
color: '#5f6368',
|
||||||
|
padding: '0 1.5rem',
|
||||||
|
marginBottom: '0.83em',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{t('participants.subheading').toUpperCase()}
|
||||||
|
</H>
|
||||||
|
{raisedHandParticipants.length > 0 && (
|
||||||
|
<Div marginBottom=".9375rem">
|
||||||
|
<ParticipantsCollapsableList
|
||||||
|
heading={t('participants.raisedHands')}
|
||||||
|
participants={raisedHandParticipants}
|
||||||
|
renderParticipant={(participant) => (
|
||||||
|
<HandRaisedListItem participant={participant} />
|
||||||
|
)}
|
||||||
|
action={() => (
|
||||||
|
<LowerAllHandsButton participants={raisedHandParticipants} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Div>
|
||||||
|
)}
|
||||||
|
<ParticipantsCollapsableList
|
||||||
|
heading={t('participants.contributors')}
|
||||||
|
participants={sortedParticipants}
|
||||||
|
renderParticipant={(participant) => (
|
||||||
|
<ParticipantListItem participant={participant} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Div>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { RiGroupLine, RiInfinityLine } from '@remixicon/react'
|
||||||
|
import { ToggleButton } from '@/primitives'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { useParticipants } from '@livekit/components-react'
|
||||||
|
import { useWidgetInteraction } from '../../../hooks/useWidgetInteraction'
|
||||||
|
|
||||||
|
export const ParticipantsToggle = () => {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context could not be used due to inconsistent refresh behavior.
|
||||||
|
* The 'numParticipant' property on the room only updates when the room's metadata changes,
|
||||||
|
* resulting in a delay compared to the participant list's actual refresh rate.
|
||||||
|
*/
|
||||||
|
const participants = useParticipants()
|
||||||
|
const numParticipants = participants?.length
|
||||||
|
|
||||||
|
const { isParticipantsOpen, toggleParticipants } = useWidgetInteraction()
|
||||||
|
|
||||||
|
const tooltipLabel = isParticipantsOpen ? 'open' : 'closed'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'relative',
|
||||||
|
display: 'inline-block',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<ToggleButton
|
||||||
|
square
|
||||||
|
legacyStyle
|
||||||
|
aria-label={t(`controls.participants.${tooltipLabel}`)}
|
||||||
|
tooltip={t(`controls.participants.${tooltipLabel}`)}
|
||||||
|
isSelected={isParticipantsOpen}
|
||||||
|
onPress={() => toggleParticipants()}
|
||||||
|
>
|
||||||
|
<RiGroupLine />
|
||||||
|
</ToggleButton>
|
||||||
|
<div
|
||||||
|
className={css({
|
||||||
|
position: 'absolute',
|
||||||
|
top: '-.25rem',
|
||||||
|
right: '-.25rem',
|
||||||
|
width: '1.25rem',
|
||||||
|
height: '1.25rem',
|
||||||
|
backgroundColor: 'gray',
|
||||||
|
borderRadius: '50%',
|
||||||
|
color: 'white',
|
||||||
|
fontSize: '0.75rem',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
textAlign: 'center',
|
||||||
|
zIndex: 1,
|
||||||
|
userSelect: 'none',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{numParticipants < 100 ? (
|
||||||
|
numParticipants || 1
|
||||||
|
) : (
|
||||||
|
<RiInfinityLine size={10} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import {
|
||||||
|
useRoomContext,
|
||||||
|
useStartAudio,
|
||||||
|
useStartVideo,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export interface AllowMediaPlaybackProps
|
||||||
|
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
|
label?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `StartMediaButton` component is only visible when the browser blocks media playback. This is due to some browser implemented autoplay policies.
|
||||||
|
* To start media playback, the user must perform a user-initiated event such as clicking this button.
|
||||||
|
* As soon as media playback starts, the button hides itself again.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* <LiveKitRoom>
|
||||||
|
* <StartMediaButton label="Click to allow media playback" />
|
||||||
|
* </LiveKitRoom>
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @see Autoplay policy on MDN web docs: {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Best_practices#autoplay_policy}
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export const StartMediaButton: (
|
||||||
|
props: AllowMediaPlaybackProps & React.RefAttributes<HTMLButtonElement>
|
||||||
|
) => React.ReactNode = /* @__PURE__ */ React.forwardRef<
|
||||||
|
HTMLButtonElement,
|
||||||
|
AllowMediaPlaybackProps
|
||||||
|
>(function StartMediaButton({ label, ...props }: AllowMediaPlaybackProps, ref) {
|
||||||
|
const room = useRoomContext()
|
||||||
|
const { mergedProps: audioProps, canPlayAudio } = useStartAudio({
|
||||||
|
room,
|
||||||
|
props,
|
||||||
|
})
|
||||||
|
const { mergedProps, canPlayVideo } = useStartVideo({
|
||||||
|
room,
|
||||||
|
props: audioProps,
|
||||||
|
})
|
||||||
|
const { style, ...restProps } = mergedProps
|
||||||
|
style.display = canPlayAudio && canPlayVideo ? 'none' : 'block'
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button ref={ref} style={style} {...restProps}>
|
||||||
|
{label ?? `Start ${!canPlayAudio ? 'Audio' : 'Video'}`}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { RoomEvent } from 'livekit-client'
|
||||||
|
|
||||||
|
// Issue: 'allRemoteParticipantRoomEvents' is not exposed or importable. One event is missing
|
||||||
|
// to trigger the real-time update of participants when they change their name.
|
||||||
|
// This code is duplicated from LiveKit.
|
||||||
|
export const allRemoteParticipantRoomEvents = [
|
||||||
|
RoomEvent.ConnectionStateChanged,
|
||||||
|
RoomEvent.RoomMetadataChanged,
|
||||||
|
|
||||||
|
RoomEvent.ActiveSpeakersChanged,
|
||||||
|
RoomEvent.ConnectionQualityChanged,
|
||||||
|
|
||||||
|
RoomEvent.ParticipantConnected,
|
||||||
|
RoomEvent.ParticipantDisconnected,
|
||||||
|
RoomEvent.ParticipantPermissionsChanged,
|
||||||
|
RoomEvent.ParticipantMetadataChanged,
|
||||||
|
RoomEvent.ParticipantNameChanged, // This element is missing in LiveKit and causes problems
|
||||||
|
|
||||||
|
RoomEvent.TrackMuted,
|
||||||
|
RoomEvent.TrackUnmuted,
|
||||||
|
RoomEvent.TrackPublished,
|
||||||
|
RoomEvent.TrackUnpublished,
|
||||||
|
RoomEvent.TrackStreamStateChanged,
|
||||||
|
RoomEvent.TrackSubscriptionFailed,
|
||||||
|
RoomEvent.TrackSubscriptionPermissionChanged,
|
||||||
|
RoomEvent.TrackSubscriptionStatusChanged,
|
||||||
|
]
|
||||||
|
|
||||||
|
export const allParticipantRoomEvents = [
|
||||||
|
...allRemoteParticipantRoomEvents,
|
||||||
|
RoomEvent.LocalTrackPublished,
|
||||||
|
RoomEvent.LocalTrackUnpublished,
|
||||||
|
]
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import * as React from 'react'
|
||||||
|
/**
|
||||||
|
* Implementation used from https://github.com/juliencrn/usehooks-ts
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function useMediaQuery(query: string): boolean {
|
||||||
|
const getMatches = (query: string): boolean => {
|
||||||
|
// Prevents SSR issues
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
return window.matchMedia(query).matches
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const [matches, setMatches] = React.useState<boolean>(getMatches(query))
|
||||||
|
|
||||||
|
function handleChange() {
|
||||||
|
setMatches(getMatches(query))
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
const matchMedia = window.matchMedia(query)
|
||||||
|
|
||||||
|
// Triggered at the first client-side load and if query changes
|
||||||
|
handleChange()
|
||||||
|
|
||||||
|
// Listen matchMedia
|
||||||
|
if (matchMedia.addListener) {
|
||||||
|
matchMedia.addListener(handleChange)
|
||||||
|
} else {
|
||||||
|
matchMedia.addEventListener('change', handleChange)
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (matchMedia.removeListener) {
|
||||||
|
matchMedia.removeListener(handleChange)
|
||||||
|
} else {
|
||||||
|
matchMedia.removeEventListener('change', handleChange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [query])
|
||||||
|
|
||||||
|
return matches
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { LocalParticipant, Participant } from 'livekit-client'
|
||||||
|
import { useParticipantInfo } from '@livekit/components-react'
|
||||||
|
import { isLocal } from '@/utils/livekit'
|
||||||
|
|
||||||
|
type useRaisedHandProps = {
|
||||||
|
participant: Participant
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useRaisedHand({ participant }: useRaisedHandProps) {
|
||||||
|
const { metadata } = useParticipantInfo({ participant })
|
||||||
|
const parsedMetadata = JSON.parse(metadata || '{}')
|
||||||
|
|
||||||
|
const toggleRaisedHand = () => {
|
||||||
|
if (isLocal(participant)) {
|
||||||
|
parsedMetadata.raised = !parsedMetadata.raised
|
||||||
|
const localParticipant = participant as LocalParticipant
|
||||||
|
localParticipant.setMetadata(JSON.stringify(parsedMetadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { isHandRaised: parsedMetadata.raised, toggleRaisedHand }
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import * as React from 'react'
|
||||||
|
|
||||||
|
const useLatest = <T>(current: T) => {
|
||||||
|
const storedValue = React.useRef(current)
|
||||||
|
React.useEffect(() => {
|
||||||
|
storedValue.current = current
|
||||||
|
})
|
||||||
|
return storedValue
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A React hook that fires a callback whenever ResizeObserver detects a change to its size
|
||||||
|
* code extracted from https://github.com/jaredLunde/react-hook/blob/master/packages/resize-observer/src/index.tsx in order to not include the polyfill for resize-observer
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
export function useResizeObserver<T extends HTMLElement>(
|
||||||
|
target: React.RefObject<T>,
|
||||||
|
callback: UseResizeObserverCallback
|
||||||
|
) {
|
||||||
|
const resizeObserver = getResizeObserver()
|
||||||
|
const storedCallback = useLatest(callback)
|
||||||
|
|
||||||
|
React.useLayoutEffect(() => {
|
||||||
|
let didUnsubscribe = false
|
||||||
|
|
||||||
|
const targetEl = target.current
|
||||||
|
if (!targetEl) return
|
||||||
|
|
||||||
|
function cb(entry: ResizeObserverEntry, observer: ResizeObserver) {
|
||||||
|
if (didUnsubscribe) return
|
||||||
|
storedCallback.current(entry, observer)
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeObserver?.subscribe(targetEl as HTMLElement, cb)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
didUnsubscribe = true
|
||||||
|
resizeObserver?.unsubscribe(targetEl as HTMLElement, cb)
|
||||||
|
}
|
||||||
|
}, [target.current, resizeObserver, storedCallback])
|
||||||
|
|
||||||
|
return resizeObserver?.observer
|
||||||
|
}
|
||||||
|
|
||||||
|
function createResizeObserver() {
|
||||||
|
let ticking = false
|
||||||
|
let allEntries: ResizeObserverEntry[] = []
|
||||||
|
|
||||||
|
const callbacks: Map<unknown, Array<UseResizeObserverCallback>> = new Map()
|
||||||
|
|
||||||
|
if (typeof window === 'undefined') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const observer = new ResizeObserver(
|
||||||
|
(entries: ResizeObserverEntry[], obs: ResizeObserver) => {
|
||||||
|
allEntries = allEntries.concat(entries)
|
||||||
|
if (!ticking) {
|
||||||
|
window.requestAnimationFrame(() => {
|
||||||
|
const triggered = new Set<Element>()
|
||||||
|
for (let i = 0; i < allEntries.length; i++) {
|
||||||
|
if (triggered.has(allEntries[i].target)) continue
|
||||||
|
triggered.add(allEntries[i].target)
|
||||||
|
const cbs = callbacks.get(allEntries[i].target)
|
||||||
|
cbs?.forEach((cb) => cb(allEntries[i], obs))
|
||||||
|
}
|
||||||
|
allEntries = []
|
||||||
|
ticking = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ticking = true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
observer,
|
||||||
|
subscribe(target: HTMLElement, callback: UseResizeObserverCallback) {
|
||||||
|
observer.observe(target)
|
||||||
|
const cbs = callbacks.get(target) ?? []
|
||||||
|
cbs.push(callback)
|
||||||
|
callbacks.set(target, cbs)
|
||||||
|
},
|
||||||
|
unsubscribe(target: HTMLElement, callback: UseResizeObserverCallback) {
|
||||||
|
const cbs = callbacks.get(target) ?? []
|
||||||
|
if (cbs.length === 1) {
|
||||||
|
observer.unobserve(target)
|
||||||
|
callbacks.delete(target)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const cbIndex = cbs.indexOf(callback)
|
||||||
|
if (cbIndex !== -1) cbs.splice(cbIndex, 1)
|
||||||
|
callbacks.set(target, cbs)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let _resizeObserver: ReturnType<typeof createResizeObserver>
|
||||||
|
|
||||||
|
const getResizeObserver = () =>
|
||||||
|
!_resizeObserver
|
||||||
|
? (_resizeObserver = createResizeObserver())
|
||||||
|
: _resizeObserver
|
||||||
|
|
||||||
|
export type UseResizeObserverCallback = (
|
||||||
|
entry: ResizeObserverEntry,
|
||||||
|
observer: ResizeObserver
|
||||||
|
) => unknown
|
||||||
|
|
||||||
|
export const useSize = (target: React.RefObject<HTMLDivElement>) => {
|
||||||
|
const [size, setSize] = React.useState({ width: 0, height: 0 })
|
||||||
|
React.useLayoutEffect(() => {
|
||||||
|
if (target.current) {
|
||||||
|
const { width, height } = target.current.getBoundingClientRect()
|
||||||
|
setSize({ width, height })
|
||||||
|
}
|
||||||
|
}, [target.current])
|
||||||
|
|
||||||
|
const resizeCallback = React.useCallback(
|
||||||
|
(entry: ResizeObserverEntry) => setSize(entry.contentRect),
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
// Where the magic happens
|
||||||
|
useResizeObserver(target, resizeCallback)
|
||||||
|
return size
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { ApiRoom } from '@/features/rooms/api/ApiRoom'
|
||||||
|
import { useRoomContext } from '@livekit/components-react'
|
||||||
|
import { useParams } from 'wouter'
|
||||||
|
import { keys } from '@/api/queryKeys'
|
||||||
|
import { queryClient } from '@/api/queryClient'
|
||||||
|
|
||||||
|
export const useRoomData = (): ApiRoom | undefined => {
|
||||||
|
const room = useRoomContext()
|
||||||
|
const { roomId } = useParams()
|
||||||
|
const queryKey = [keys.room, roomId, room.localParticipant.name]
|
||||||
|
return queryClient.getQueryData<ApiRoom>(queryKey)
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { useLayoutContext } from '@livekit/components-react'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import { participantsStore } from '@/stores/participants.ts'
|
||||||
|
|
||||||
|
export const useWidgetInteraction = () => {
|
||||||
|
const { dispatch, state } = useLayoutContext().widget
|
||||||
|
|
||||||
|
const participantsSnap = useSnapshot(participantsStore)
|
||||||
|
const isParticipantsOpen = participantsSnap.showParticipants
|
||||||
|
|
||||||
|
const toggleParticipants = () => {
|
||||||
|
if (dispatch && state?.showChat) {
|
||||||
|
dispatch({ msg: 'toggle_chat' })
|
||||||
|
}
|
||||||
|
participantsStore.showParticipants = !isParticipantsOpen
|
||||||
|
}
|
||||||
|
|
||||||
|
const toggleChat = () => {
|
||||||
|
if (isParticipantsOpen) {
|
||||||
|
participantsStore.showParticipants = false
|
||||||
|
}
|
||||||
|
if (dispatch) {
|
||||||
|
dispatch({ msg: 'toggle_chat' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
toggleParticipants,
|
||||||
|
toggleChat,
|
||||||
|
isChatOpen: state?.showChat,
|
||||||
|
unreadMessages: state?.unreadMessages,
|
||||||
|
isParticipantsOpen,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
import { Track } from 'livekit-client'
|
||||||
|
import * as React from 'react'
|
||||||
|
|
||||||
|
import { supportsScreenSharing } from '@livekit/components-core'
|
||||||
|
|
||||||
|
import {
|
||||||
|
DisconnectButton,
|
||||||
|
LeaveIcon,
|
||||||
|
MediaDeviceMenu,
|
||||||
|
TrackToggle,
|
||||||
|
useMaybeLayoutContext,
|
||||||
|
usePersistentUserChoices,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
|
||||||
|
import { mergeProps } from '@/utils/mergeProps.ts'
|
||||||
|
import { StartMediaButton } from '../components/controls/StartMediaButton'
|
||||||
|
import { useMediaQuery } from '../hooks/useMediaQuery'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { OptionsButton } from '../components/controls/Options/OptionsButton'
|
||||||
|
import { ParticipantsToggle } from '@/features/rooms/livekit/components/controls/Participants/ParticipantsToggle'
|
||||||
|
import { ChatToggle } from '@/features/rooms/livekit/components/controls/ChatToggle'
|
||||||
|
import { HandToggle } from '@/features/rooms/livekit/components/controls/HandToggle'
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export type ControlBarControls = {
|
||||||
|
microphone?: boolean
|
||||||
|
camera?: boolean
|
||||||
|
chat?: boolean
|
||||||
|
screenShare?: boolean
|
||||||
|
leave?: boolean
|
||||||
|
settings?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @public */
|
||||||
|
export interface ControlBarProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
onDeviceError?: (error: { source: Track.Source; error: Error }) => void
|
||||||
|
variation?: 'minimal' | 'verbose' | 'textOnly'
|
||||||
|
controls?: ControlBarControls
|
||||||
|
/**
|
||||||
|
* If `true`, the user's device choices will be persisted.
|
||||||
|
* This will enables the user to have the same device choices when they rejoin the room.
|
||||||
|
* @defaultValue true
|
||||||
|
* @alpha
|
||||||
|
*/
|
||||||
|
saveUserChoices?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `ControlBar` prefab gives the user the basic user interface to control their
|
||||||
|
* media devices (camera, microphone and screen share), open the `Chat` and leave the room.
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* This component is build with other LiveKit components like `TrackToggle`,
|
||||||
|
* `DeviceSelectorButton`, `DisconnectButton` and `StartAudio`.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* <LiveKitRoom>
|
||||||
|
* <ControlBar />
|
||||||
|
* </LiveKitRoom>
|
||||||
|
* ```
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function ControlBar({
|
||||||
|
variation,
|
||||||
|
saveUserChoices = true,
|
||||||
|
onDeviceError,
|
||||||
|
...props
|
||||||
|
}: ControlBarProps) {
|
||||||
|
const { t } = useTranslation('rooms')
|
||||||
|
const [isChatOpen, setIsChatOpen] = React.useState(false)
|
||||||
|
const layoutContext = useMaybeLayoutContext()
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (layoutContext?.widget.state?.showChat !== undefined) {
|
||||||
|
setIsChatOpen(layoutContext?.widget.state?.showChat)
|
||||||
|
}
|
||||||
|
}, [layoutContext?.widget.state?.showChat])
|
||||||
|
|
||||||
|
const isTooLittleSpace = useMediaQuery(
|
||||||
|
`(max-width: ${isChatOpen ? 1000 : 760}px)`
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultVariation = isTooLittleSpace ? 'minimal' : 'verbose'
|
||||||
|
variation ??= defaultVariation
|
||||||
|
|
||||||
|
const showIcon = React.useMemo(
|
||||||
|
() => variation === 'minimal' || variation === 'verbose',
|
||||||
|
[variation]
|
||||||
|
)
|
||||||
|
const showText = React.useMemo(
|
||||||
|
() => variation === 'textOnly' || variation === 'verbose',
|
||||||
|
[variation]
|
||||||
|
)
|
||||||
|
|
||||||
|
const browserSupportsScreenSharing = supportsScreenSharing()
|
||||||
|
|
||||||
|
const [isScreenShareEnabled, setIsScreenShareEnabled] = React.useState(false)
|
||||||
|
|
||||||
|
const onScreenShareChange = React.useCallback(
|
||||||
|
(enabled: boolean) => {
|
||||||
|
setIsScreenShareEnabled(enabled)
|
||||||
|
},
|
||||||
|
[setIsScreenShareEnabled]
|
||||||
|
)
|
||||||
|
|
||||||
|
const htmlProps = mergeProps({ className: 'lk-control-bar' }, props)
|
||||||
|
|
||||||
|
const {
|
||||||
|
saveAudioInputEnabled,
|
||||||
|
saveVideoInputEnabled,
|
||||||
|
saveAudioInputDeviceId,
|
||||||
|
saveVideoInputDeviceId,
|
||||||
|
} = usePersistentUserChoices({ preventSave: !saveUserChoices })
|
||||||
|
|
||||||
|
const microphoneOnChange = React.useCallback(
|
||||||
|
(enabled: boolean, isUserInitiated: boolean) =>
|
||||||
|
isUserInitiated ? saveAudioInputEnabled(enabled) : null,
|
||||||
|
[saveAudioInputEnabled]
|
||||||
|
)
|
||||||
|
|
||||||
|
const cameraOnChange = React.useCallback(
|
||||||
|
(enabled: boolean, isUserInitiated: boolean) =>
|
||||||
|
isUserInitiated ? saveVideoInputEnabled(enabled) : null,
|
||||||
|
[saveVideoInputEnabled]
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div {...htmlProps}>
|
||||||
|
<div className="lk-button-group">
|
||||||
|
<TrackToggle
|
||||||
|
source={Track.Source.Microphone}
|
||||||
|
showIcon={showIcon}
|
||||||
|
onChange={microphoneOnChange}
|
||||||
|
onDeviceError={(error) =>
|
||||||
|
onDeviceError?.({ source: Track.Source.Microphone, error })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{showText && t('controls.microphone')}
|
||||||
|
</TrackToggle>
|
||||||
|
<div className="lk-button-group-menu">
|
||||||
|
<MediaDeviceMenu
|
||||||
|
kind="audioinput"
|
||||||
|
onActiveDeviceChange={(_kind, deviceId) =>
|
||||||
|
saveAudioInputDeviceId(deviceId ?? '')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="lk-button-group">
|
||||||
|
<TrackToggle
|
||||||
|
source={Track.Source.Camera}
|
||||||
|
showIcon={showIcon}
|
||||||
|
onChange={cameraOnChange}
|
||||||
|
onDeviceError={(error) =>
|
||||||
|
onDeviceError?.({ source: Track.Source.Camera, error })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{showText && t('controls.camera')}
|
||||||
|
</TrackToggle>
|
||||||
|
<div className="lk-button-group-menu">
|
||||||
|
<MediaDeviceMenu
|
||||||
|
kind="videoinput"
|
||||||
|
onActiveDeviceChange={(_kind, deviceId) =>
|
||||||
|
saveVideoInputDeviceId(deviceId ?? '')
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{browserSupportsScreenSharing && (
|
||||||
|
<TrackToggle
|
||||||
|
source={Track.Source.ScreenShare}
|
||||||
|
captureOptions={{ audio: true, selfBrowserSurface: 'include' }}
|
||||||
|
showIcon={showIcon}
|
||||||
|
onChange={onScreenShareChange}
|
||||||
|
onDeviceError={(error) =>
|
||||||
|
onDeviceError?.({ source: Track.Source.ScreenShare, error })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{showText &&
|
||||||
|
t(
|
||||||
|
isScreenShareEnabled
|
||||||
|
? 'controls.stopScreenShare'
|
||||||
|
: 'controls.shareScreen'
|
||||||
|
)}
|
||||||
|
</TrackToggle>
|
||||||
|
)}
|
||||||
|
<HandToggle />
|
||||||
|
<ChatToggle />
|
||||||
|
<ParticipantsToggle />
|
||||||
|
<OptionsButton />
|
||||||
|
<DisconnectButton>
|
||||||
|
{showIcon && <LeaveIcon />}
|
||||||
|
{showText && t('controls.leave')}
|
||||||
|
</DisconnectButton>
|
||||||
|
<StartMediaButton />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
import type {
|
||||||
|
MessageDecoder,
|
||||||
|
MessageEncoder,
|
||||||
|
TrackReferenceOrPlaceholder,
|
||||||
|
WidgetState,
|
||||||
|
} from '@livekit/components-core'
|
||||||
|
import {
|
||||||
|
isEqualTrackRef,
|
||||||
|
isTrackReference,
|
||||||
|
isWeb,
|
||||||
|
log,
|
||||||
|
} from '@livekit/components-core'
|
||||||
|
import { RoomEvent, Track } from 'livekit-client'
|
||||||
|
import * as React from 'react'
|
||||||
|
|
||||||
|
import {
|
||||||
|
CarouselLayout,
|
||||||
|
ConnectionStateToast,
|
||||||
|
FocusLayoutContainer,
|
||||||
|
GridLayout,
|
||||||
|
LayoutContextProvider,
|
||||||
|
RoomAudioRenderer,
|
||||||
|
MessageFormatter,
|
||||||
|
usePinnedTracks,
|
||||||
|
useTracks,
|
||||||
|
useCreateLayoutContext,
|
||||||
|
Chat,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
|
||||||
|
import { ControlBar } from './ControlBar'
|
||||||
|
import { styled } from '@/styled-system/jsx'
|
||||||
|
import { cva } from '@/styled-system/css'
|
||||||
|
import { ParticipantsList } from '@/features/rooms/livekit/components/controls/Participants/ParticipantsList'
|
||||||
|
import { useSnapshot } from 'valtio'
|
||||||
|
import { participantsStore } from '@/stores/participants'
|
||||||
|
import { FocusLayout } from '../components/FocusLayout'
|
||||||
|
import { ParticipantTile } from '../components/ParticipantTile'
|
||||||
|
import { MainNotificationToast } from '@/features/notifications/MainNotificationToast'
|
||||||
|
import { RecordingIndicator } from '@/features/rooms/livekit/components/RecordingIndicator.tsx'
|
||||||
|
|
||||||
|
const LayoutWrapper = styled(
|
||||||
|
'div',
|
||||||
|
cva({
|
||||||
|
base: {
|
||||||
|
position: 'relative',
|
||||||
|
display: 'flex',
|
||||||
|
width: '100%',
|
||||||
|
height: 'calc(100% - var(--lk-control-bar-height))',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export interface VideoConferenceProps
|
||||||
|
extends React.HTMLAttributes<HTMLDivElement> {
|
||||||
|
chatMessageFormatter?: MessageFormatter
|
||||||
|
chatMessageEncoder?: MessageEncoder
|
||||||
|
chatMessageDecoder?: MessageDecoder
|
||||||
|
/** @alpha */
|
||||||
|
SettingsComponent?: React.ComponentType
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `VideoConference` ready-made component is your drop-in solution for a classic video conferencing application.
|
||||||
|
* It provides functionality such as focusing on one participant, grid view with pagination to handle large numbers
|
||||||
|
* of participants, basic non-persistent chat, screen sharing, and more.
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* The component is implemented with other LiveKit components like `FocusContextProvider`,
|
||||||
|
* `GridLayout`, `ControlBar`, `FocusLayoutContainer` and `FocusLayout`.
|
||||||
|
* You can use this components as a starting point for your own custom video conferencing application.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```tsx
|
||||||
|
* <LiveKitRoom>
|
||||||
|
* <VideoConference />
|
||||||
|
* <LiveKitRoom>
|
||||||
|
* ```
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export function VideoConference({
|
||||||
|
chatMessageFormatter,
|
||||||
|
chatMessageDecoder,
|
||||||
|
chatMessageEncoder,
|
||||||
|
...props
|
||||||
|
}: VideoConferenceProps) {
|
||||||
|
const [widgetState, setWidgetState] = React.useState<WidgetState>({
|
||||||
|
showChat: false,
|
||||||
|
unreadMessages: 0,
|
||||||
|
showSettings: false,
|
||||||
|
})
|
||||||
|
const lastAutoFocusedScreenShareTrack =
|
||||||
|
React.useRef<TrackReferenceOrPlaceholder | null>(null)
|
||||||
|
|
||||||
|
const tracks = useTracks(
|
||||||
|
[
|
||||||
|
{ source: Track.Source.Camera, withPlaceholder: true },
|
||||||
|
{ source: Track.Source.ScreenShare, withPlaceholder: false },
|
||||||
|
],
|
||||||
|
{ updateOnlyOn: [RoomEvent.ActiveSpeakersChanged], onlySubscribed: false }
|
||||||
|
)
|
||||||
|
|
||||||
|
const widgetUpdate = (state: WidgetState) => {
|
||||||
|
log.debug('updating widget state', state)
|
||||||
|
setWidgetState(state)
|
||||||
|
}
|
||||||
|
|
||||||
|
const layoutContext = useCreateLayoutContext()
|
||||||
|
|
||||||
|
const screenShareTracks = tracks
|
||||||
|
.filter(isTrackReference)
|
||||||
|
.filter((track) => track.publication.source === Track.Source.ScreenShare)
|
||||||
|
|
||||||
|
const focusTrack = usePinnedTracks(layoutContext)?.[0]
|
||||||
|
const carouselTracks = tracks.filter(
|
||||||
|
(track) => !isEqualTrackRef(track, focusTrack)
|
||||||
|
)
|
||||||
|
|
||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
// Code duplicated from LiveKit; this warning will be addressed in the refactoring.
|
||||||
|
React.useEffect(() => {
|
||||||
|
// If screen share tracks are published, and no pin is set explicitly, auto set the screen share.
|
||||||
|
if (
|
||||||
|
screenShareTracks.some((track) => track.publication.isSubscribed) &&
|
||||||
|
lastAutoFocusedScreenShareTrack.current === null
|
||||||
|
) {
|
||||||
|
log.debug('Auto set screen share focus:', {
|
||||||
|
newScreenShareTrack: screenShareTracks[0],
|
||||||
|
})
|
||||||
|
layoutContext.pin.dispatch?.({
|
||||||
|
msg: 'set_pin',
|
||||||
|
trackReference: screenShareTracks[0],
|
||||||
|
})
|
||||||
|
lastAutoFocusedScreenShareTrack.current = screenShareTracks[0]
|
||||||
|
} else if (
|
||||||
|
lastAutoFocusedScreenShareTrack.current &&
|
||||||
|
!screenShareTracks.some(
|
||||||
|
(track) =>
|
||||||
|
track.publication.trackSid ===
|
||||||
|
lastAutoFocusedScreenShareTrack.current?.publication?.trackSid
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
log.debug('Auto clearing screen share focus.')
|
||||||
|
layoutContext.pin.dispatch?.({ msg: 'clear_pin' })
|
||||||
|
lastAutoFocusedScreenShareTrack.current = null
|
||||||
|
}
|
||||||
|
if (focusTrack && !isTrackReference(focusTrack)) {
|
||||||
|
const updatedFocusTrack = tracks.find(
|
||||||
|
(tr) =>
|
||||||
|
tr.participant.identity === focusTrack.participant.identity &&
|
||||||
|
tr.source === focusTrack.source
|
||||||
|
)
|
||||||
|
if (
|
||||||
|
updatedFocusTrack !== focusTrack &&
|
||||||
|
isTrackReference(updatedFocusTrack)
|
||||||
|
) {
|
||||||
|
layoutContext.pin.dispatch?.({
|
||||||
|
msg: 'set_pin',
|
||||||
|
trackReference: updatedFocusTrack,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
screenShareTracks
|
||||||
|
.map(
|
||||||
|
(ref) => `${ref.publication.trackSid}_${ref.publication.isSubscribed}`
|
||||||
|
)
|
||||||
|
.join(),
|
||||||
|
focusTrack?.publication?.trackSid,
|
||||||
|
tracks,
|
||||||
|
])
|
||||||
|
/* eslint-enable react-hooks/exhaustive-deps */
|
||||||
|
|
||||||
|
const participantsSnap = useSnapshot(participantsStore)
|
||||||
|
const showParticipants = participantsSnap.showParticipants
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="lk-video-conference" {...props}>
|
||||||
|
{isWeb() && (
|
||||||
|
<LayoutContextProvider
|
||||||
|
value={layoutContext}
|
||||||
|
// onPinChange={handleFocusStateChange}
|
||||||
|
onWidgetChange={widgetUpdate}
|
||||||
|
>
|
||||||
|
<div className="lk-video-conference-inner">
|
||||||
|
<RecordingIndicator />
|
||||||
|
<LayoutWrapper>
|
||||||
|
<div
|
||||||
|
style={{ display: 'flex', position: 'relative', width: '100%' }}
|
||||||
|
>
|
||||||
|
{!focusTrack ? (
|
||||||
|
<div
|
||||||
|
className="lk-grid-layout-wrapper"
|
||||||
|
style={{ height: 'auto' }}
|
||||||
|
>
|
||||||
|
<GridLayout tracks={tracks}>
|
||||||
|
<ParticipantTile />
|
||||||
|
</GridLayout>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className="lk-focus-layout-wrapper"
|
||||||
|
style={{ height: 'auto' }}
|
||||||
|
>
|
||||||
|
<FocusLayoutContainer>
|
||||||
|
<CarouselLayout
|
||||||
|
tracks={carouselTracks}
|
||||||
|
style={{
|
||||||
|
minWidth: '200px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ParticipantTile />
|
||||||
|
</CarouselLayout>
|
||||||
|
{focusTrack && <FocusLayout trackRef={focusTrack} />}
|
||||||
|
</FocusLayoutContainer>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<MainNotificationToast />
|
||||||
|
</div>
|
||||||
|
<Chat
|
||||||
|
style={{ display: widgetState.showChat ? 'grid' : 'none' }}
|
||||||
|
messageFormatter={chatMessageFormatter}
|
||||||
|
messageEncoder={chatMessageEncoder}
|
||||||
|
messageDecoder={chatMessageDecoder}
|
||||||
|
/>
|
||||||
|
{showParticipants && <ParticipantsList />}
|
||||||
|
</LayoutWrapper>
|
||||||
|
<ControlBar />
|
||||||
|
</div>
|
||||||
|
</LayoutContextProvider>
|
||||||
|
)}
|
||||||
|
<RoomAudioRenderer />
|
||||||
|
<ConnectionStateToast />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -8,7 +8,9 @@ export const FeedbackRoute = () => {
|
|||||||
return (
|
return (
|
||||||
<Screen layout="centered">
|
<Screen layout="centered">
|
||||||
<CenteredContent title={t('feedback.heading')} withBackButton>
|
<CenteredContent title={t('feedback.heading')} withBackButton>
|
||||||
<Text as="p" variant="h3" centered>{t('feedback.body')}</Text>
|
<Text as="p" variant="h3" centered>
|
||||||
|
{t('feedback.body')}
|
||||||
|
</Text>
|
||||||
</CenteredContent>
|
</CenteredContent>
|
||||||
</Screen>
|
</Screen>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import {
|
import {
|
||||||
usePersistentUserChoices,
|
usePersistentUserChoices,
|
||||||
type LocalUserChoices,
|
type LocalUserChoices,
|
||||||
@@ -19,6 +19,19 @@ export const Room = () => {
|
|||||||
const mode = isLoggedIn && history.state?.create ? 'create' : 'join'
|
const mode = isLoggedIn && history.state?.create ? 'create' : 'join'
|
||||||
const skipJoinScreen = isLoggedIn && mode === 'create'
|
const skipJoinScreen = isLoggedIn && mode === 'create'
|
||||||
|
|
||||||
|
const clearRouterState = () => {
|
||||||
|
if (window?.history?.state) {
|
||||||
|
window.history.replaceState({}, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
window.addEventListener('beforeunload', clearRouterState)
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('beforeunload', clearRouterState)
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
if (!roomId) {
|
if (!roomId) {
|
||||||
return <ErrorScreen />
|
return <ErrorScreen />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { Participant } from 'livekit-client'
|
||||||
|
|
||||||
|
export const getParticipantColor = (
|
||||||
|
participant: Participant
|
||||||
|
): undefined | string => {
|
||||||
|
const { metadata } = participant
|
||||||
|
if (!metadata) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return JSON.parse(metadata)['color']
|
||||||
|
}
|
||||||
@@ -1,12 +1,38 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
import { useLanguageLabels } from '@/i18n/useLanguageLabels'
|
import { useLanguageLabels } from '@/i18n/useLanguageLabels'
|
||||||
import { Dialog, Field, H } from '@/primitives'
|
import { A, Badge, Dialog, type DialogProps, Field, H, P } from '@/primitives'
|
||||||
|
import { authUrl, logoutUrl, useUser } from '@/features/auth'
|
||||||
|
|
||||||
export const SettingsDialog = () => {
|
export type SettingsDialogProps = Pick<DialogProps, 'isOpen' | 'onOpenChange'>
|
||||||
|
|
||||||
|
export const SettingsDialog = (props: SettingsDialogProps) => {
|
||||||
const { t, i18n } = useTranslation('settings')
|
const { t, i18n } = useTranslation('settings')
|
||||||
|
const { user, isLoggedIn } = useUser()
|
||||||
const { languagesList, currentLanguage } = useLanguageLabels()
|
const { languagesList, currentLanguage } = useLanguageLabels()
|
||||||
return (
|
return (
|
||||||
<Dialog title={t('dialog.heading')}>
|
<Dialog title={t('dialog.heading')} {...props}>
|
||||||
|
<H lvl={2}>{t('account.heading')}</H>
|
||||||
|
{isLoggedIn ? (
|
||||||
|
<>
|
||||||
|
<P>
|
||||||
|
<Trans
|
||||||
|
i18nKey="settings:account.currentlyLoggedAs"
|
||||||
|
values={{ user: user?.email }}
|
||||||
|
components={[<Badge />]}
|
||||||
|
/>
|
||||||
|
</P>
|
||||||
|
<P>
|
||||||
|
<A href={logoutUrl()}>{t('logout', { ns: 'global' })}</A>
|
||||||
|
</P>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<P>{t('account.youAreNotLoggedIn')}</P>
|
||||||
|
<P>
|
||||||
|
<A href={authUrl()}>{t('login', { ns: 'global' })}</A>
|
||||||
|
</P>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<H lvl={2}>{t('language.heading')}</H>
|
<H lvl={2}>{t('language.heading')}</H>
|
||||||
<Field
|
<Field
|
||||||
type="select"
|
type="select"
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
import { Dialog, type DialogProps } from '@/primitives'
|
||||||
|
import { Tab, Tabs, TabList } from '@/primitives/Tabs.tsx'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { text } from '@/primitives/Text.tsx'
|
||||||
|
import { Heading } from 'react-aria-components'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import {
|
||||||
|
RiAccountCircleLine,
|
||||||
|
RiSettings3Line,
|
||||||
|
RiSpeakerLine,
|
||||||
|
} from '@remixicon/react'
|
||||||
|
import { AccountTab } from './tabs/AccountTab'
|
||||||
|
import { GeneralTab } from '@/features/settings/components/tabs/GeneralTab.tsx'
|
||||||
|
import { AudioTab } from '@/features/settings/components/tabs/AudioTab.tsx'
|
||||||
|
import { useSize } from '@/features/rooms/livekit/hooks/useResizeObserver'
|
||||||
|
import { useRef } from 'react'
|
||||||
|
|
||||||
|
const tabsStyle = css({
|
||||||
|
maxHeight: '40.625rem', // fixme size copied from meet settings modal
|
||||||
|
width: '50rem', // fixme size copied from meet settings modal
|
||||||
|
marginY: '-1rem', // fixme hacky solution to cancel modal padding
|
||||||
|
maxWidth: '100%',
|
||||||
|
overflow: 'hidden',
|
||||||
|
height: 'calc(100vh - 2rem)',
|
||||||
|
})
|
||||||
|
|
||||||
|
const tabListContainerStyle = css({
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
borderRight: '1px solid lightGray', // fixme poor color management
|
||||||
|
paddingY: '1rem',
|
||||||
|
paddingRight: '1.5rem',
|
||||||
|
})
|
||||||
|
|
||||||
|
const tabPanelContainerStyle = css({
|
||||||
|
display: 'flex',
|
||||||
|
flexGrow: '1',
|
||||||
|
marginTop: '3.5rem',
|
||||||
|
minWidth: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
export type SettingsDialogExtended = Pick<
|
||||||
|
DialogProps,
|
||||||
|
'isOpen' | 'onOpenChange'
|
||||||
|
>
|
||||||
|
|
||||||
|
export const SettingsDialogExtended = (props: SettingsDialogExtended) => {
|
||||||
|
// display only icon on small screen
|
||||||
|
const { t } = useTranslation('settings')
|
||||||
|
|
||||||
|
const dialogEl = useRef<HTMLDivElement>(null)
|
||||||
|
const { width } = useSize(dialogEl)
|
||||||
|
const isWideScreen = !width || width >= 800 // fixme - hardcoded 50rem in pixel
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog innerRef={dialogEl} {...props} role="dialog" type="flex">
|
||||||
|
<Tabs orientation="vertical" className={tabsStyle}>
|
||||||
|
<div
|
||||||
|
className={tabListContainerStyle}
|
||||||
|
style={{
|
||||||
|
flex: isWideScreen ? '0 0 16rem' : undefined,
|
||||||
|
paddingTop: !isWideScreen ? '64px' : undefined,
|
||||||
|
paddingRight: !isWideScreen ? '1rem' : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isWideScreen && (
|
||||||
|
<Heading slot="title" level={1} className={text({ variant: 'h1' })}>
|
||||||
|
{t('dialog.heading')}
|
||||||
|
</Heading>
|
||||||
|
)}
|
||||||
|
<TabList border={false} aria-label="Chat log orientation example">
|
||||||
|
<Tab icon highlight id="1">
|
||||||
|
<RiAccountCircleLine />
|
||||||
|
{isWideScreen && t('tabs.account')}
|
||||||
|
</Tab>
|
||||||
|
<Tab icon highlight id="2">
|
||||||
|
<RiSpeakerLine />
|
||||||
|
{isWideScreen && t('tabs.audio')}
|
||||||
|
</Tab>
|
||||||
|
<Tab icon highlight id="3">
|
||||||
|
<RiSettings3Line />
|
||||||
|
{isWideScreen && t('tabs.general')}
|
||||||
|
</Tab>
|
||||||
|
</TabList>
|
||||||
|
</div>
|
||||||
|
<div className={tabPanelContainerStyle}>
|
||||||
|
<AccountTab id="1" onOpenChange={props.onOpenChange} />
|
||||||
|
<AudioTab id="2" />
|
||||||
|
<GeneralTab id="3" />
|
||||||
|
</div>
|
||||||
|
</Tabs>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { A, Badge, Button, DialogProps, Field, H, P } from '@/primitives'
|
||||||
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
import {
|
||||||
|
usePersistentUserChoices,
|
||||||
|
useRoomContext,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
import { authUrl, logoutUrl, useUser } from '@/features/auth'
|
||||||
|
import { css } from '@/styled-system/css'
|
||||||
|
import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
export type AccountTabProps = Pick<DialogProps, 'onOpenChange'> &
|
||||||
|
Pick<TabPanelProps, 'id'>
|
||||||
|
|
||||||
|
export const AccountTab = ({ id, onOpenChange }: AccountTabProps) => {
|
||||||
|
const { t } = useTranslation('settings')
|
||||||
|
const { saveUsername } = usePersistentUserChoices()
|
||||||
|
const room = useRoomContext()
|
||||||
|
const { user, isLoggedIn } = useUser()
|
||||||
|
const [name, setName] = useState(room?.localParticipant.name || '')
|
||||||
|
|
||||||
|
const handleOnSubmit = () => {
|
||||||
|
if (room) room.localParticipant.setName(name)
|
||||||
|
saveUsername(name)
|
||||||
|
if (onOpenChange) onOpenChange(false)
|
||||||
|
}
|
||||||
|
const handleOnCancel = () => {
|
||||||
|
if (onOpenChange) onOpenChange(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TabPanel padding={'md'} flex id={id}>
|
||||||
|
<H lvl={2}>{t('account.heading')}</H>
|
||||||
|
<Field
|
||||||
|
type="text"
|
||||||
|
label={t('account.nameLabel')}
|
||||||
|
value={name}
|
||||||
|
onChange={setName}
|
||||||
|
validate={(value) => {
|
||||||
|
return !value ? <p>{'Votre Nom ne peut pas être vide'}</p> : null
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<H lvl={2}>{t('account.authentication')}</H>
|
||||||
|
{isLoggedIn ? (
|
||||||
|
<>
|
||||||
|
<P>
|
||||||
|
<Trans
|
||||||
|
i18nKey="settings:account.currentlyLoggedAs"
|
||||||
|
values={{ user: user?.email }}
|
||||||
|
components={[<Badge />]}
|
||||||
|
/>
|
||||||
|
</P>
|
||||||
|
<P>
|
||||||
|
<A href={logoutUrl()}>{t('logout', { ns: 'global' })}</A>
|
||||||
|
</P>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<P>{t('account.youAreNotLoggedIn')}</P>
|
||||||
|
<P>
|
||||||
|
<A href={authUrl()}>{t('login', { ns: 'global' })}</A>
|
||||||
|
</P>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<HStack
|
||||||
|
className={css({
|
||||||
|
marginTop: 'auto',
|
||||||
|
marginLeft: 'auto',
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<Button onPress={handleOnCancel}>
|
||||||
|
{t('cancel', { ns: 'global' })}
|
||||||
|
</Button>
|
||||||
|
<Button variant={'primary'} onPress={handleOnSubmit}>
|
||||||
|
{t('submit', { ns: 'global' })}
|
||||||
|
</Button>
|
||||||
|
</HStack>
|
||||||
|
</TabPanel>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
import { DialogProps, Field, H } from '@/primitives'
|
||||||
|
|
||||||
|
import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
|
||||||
|
import {
|
||||||
|
useIsSpeaking,
|
||||||
|
useMediaDeviceSelect,
|
||||||
|
useRoomContext,
|
||||||
|
} from '@livekit/components-react'
|
||||||
|
import { isSafari } from '@/utils/livekit'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { SoundTester } from '@/components/SoundTester'
|
||||||
|
import { HStack } from '@/styled-system/jsx'
|
||||||
|
import { ActiveSpeaker } from '@/features/rooms/components/ActiveSpeaker'
|
||||||
|
import { ReactNode } from 'react'
|
||||||
|
|
||||||
|
type RowWrapperProps = {
|
||||||
|
heading: string
|
||||||
|
children: ReactNode[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const RowWrapper = ({ heading, children }: RowWrapperProps) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<H lvl={2}>{heading}</H>
|
||||||
|
<HStack
|
||||||
|
gap={0}
|
||||||
|
style={{
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
flex: '1 1 215px',
|
||||||
|
minWidth: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children[0]}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: '10rem',
|
||||||
|
justifyContent: 'center',
|
||||||
|
display: 'flex',
|
||||||
|
paddingLeft: '1.5rem',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children[1]}
|
||||||
|
</div>
|
||||||
|
</HStack>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AudioTabProps = Pick<DialogProps, 'onOpenChange'> &
|
||||||
|
Pick<TabPanelProps, 'id'>
|
||||||
|
|
||||||
|
type DeviceItems = Array<{ value: string; label: string }>
|
||||||
|
|
||||||
|
export const AudioTab = ({ id }: AudioTabProps) => {
|
||||||
|
const { t } = useTranslation('settings')
|
||||||
|
const { localParticipant } = useRoomContext()
|
||||||
|
|
||||||
|
const isSpeaking = useIsSpeaking(localParticipant)
|
||||||
|
|
||||||
|
const {
|
||||||
|
devices: devicesOut,
|
||||||
|
activeDeviceId: activeDeviceIdOut,
|
||||||
|
setActiveMediaDevice: setActiveMediaDeviceOut,
|
||||||
|
} = useMediaDeviceSelect({ kind: 'audiooutput' })
|
||||||
|
|
||||||
|
const {
|
||||||
|
devices: devicesIn,
|
||||||
|
activeDeviceId: activeDeviceIdIn,
|
||||||
|
setActiveMediaDevice: setActiveMediaDeviceIn,
|
||||||
|
} = useMediaDeviceSelect({ kind: 'audioinput' })
|
||||||
|
|
||||||
|
const itemsOut: DeviceItems = devicesOut.map((d) => ({
|
||||||
|
value: d.deviceId,
|
||||||
|
label: d.label,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const itemsIn: DeviceItems = devicesIn.map((d) => ({
|
||||||
|
value: d.deviceId,
|
||||||
|
label: d.label,
|
||||||
|
}))
|
||||||
|
|
||||||
|
// The Permissions API is not fully supported in Firefox and Safari, and attempting to use it for microphone permissions
|
||||||
|
// may raise an error. As a workaround, we infer microphone permission status by checking if the list of audio input
|
||||||
|
// devices (devicesIn) is non-empty. If the list has one or more devices, we assume the user has granted microphone access.
|
||||||
|
const isMicEnabled = devicesIn?.length > 0
|
||||||
|
|
||||||
|
const disabledProps = isMicEnabled
|
||||||
|
? {}
|
||||||
|
: {
|
||||||
|
placeholder: t('audio.permissionsRequired'),
|
||||||
|
isDisabled: true,
|
||||||
|
defaultSelectedKey: undefined,
|
||||||
|
}
|
||||||
|
|
||||||
|
// No API to directly query the default audio device; this function heuristically finds it.
|
||||||
|
// Returns the item with value 'default' if present; otherwise, returns the first item in the list.
|
||||||
|
const getDefaultSelectedKey = (items: DeviceItems) => {
|
||||||
|
if (!items || items.length === 0) return
|
||||||
|
const defaultItem =
|
||||||
|
items.find((item) => item.value === 'default') || items[0]
|
||||||
|
return defaultItem.value
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TabPanel padding={'md'} flex id={id}>
|
||||||
|
<RowWrapper heading={t('audio.microphone.heading')}>
|
||||||
|
<Field
|
||||||
|
type="select"
|
||||||
|
label={t('audio.microphone.label')}
|
||||||
|
items={itemsIn}
|
||||||
|
defaultSelectedKey={
|
||||||
|
activeDeviceIdIn || getDefaultSelectedKey(itemsIn)
|
||||||
|
}
|
||||||
|
onSelectionChange={(key) => setActiveMediaDeviceIn(key as string)}
|
||||||
|
{...disabledProps}
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<>
|
||||||
|
{localParticipant.isMicrophoneEnabled ? (
|
||||||
|
<ActiveSpeaker isSpeaking={isSpeaking} />
|
||||||
|
) : (
|
||||||
|
<span>Micro désactivé</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
</RowWrapper>
|
||||||
|
{/* Safari has a known limitation where its implementation of 'enumerateDevices' does not include audio output devices.
|
||||||
|
To prevent errors or an empty selection list, we only render the speakers selection field on non-Safari browsers. */}
|
||||||
|
{!isSafari() && (
|
||||||
|
<RowWrapper heading={t('audio.speakers.heading')}>
|
||||||
|
<Field
|
||||||
|
type="select"
|
||||||
|
label={t('audio.speakers.label')}
|
||||||
|
items={itemsOut}
|
||||||
|
defaultSelectedKey={
|
||||||
|
activeDeviceIdOut || getDefaultSelectedKey(itemsOut)
|
||||||
|
}
|
||||||
|
onSelectionChange={async (key) =>
|
||||||
|
setActiveMediaDeviceOut(key as string)
|
||||||
|
}
|
||||||
|
{...disabledProps}
|
||||||
|
style={{
|
||||||
|
minWidth: 0,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<SoundTester />
|
||||||
|
</RowWrapper>
|
||||||
|
)}
|
||||||
|
</TabPanel>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { Field, H } from '@/primitives'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useLanguageLabels } from '@/i18n/useLanguageLabels'
|
||||||
|
import { TabPanel, TabPanelProps } from '@/primitives/Tabs'
|
||||||
|
|
||||||
|
export type GeneralTabProps = Pick<TabPanelProps, 'id'>
|
||||||
|
|
||||||
|
export const GeneralTab = ({ id }: GeneralTabProps) => {
|
||||||
|
const { t, i18n } = useTranslation('settings')
|
||||||
|
const { languagesList, currentLanguage } = useLanguageLabels()
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TabPanel padding={'md'} flex id={id}>
|
||||||
|
<H lvl={2}>{t('language.heading')}</H>
|
||||||
|
<Field
|
||||||
|
type="select"
|
||||||
|
label={t('language.label')}
|
||||||
|
items={languagesList}
|
||||||
|
defaultSelectedKey={currentLanguage.key}
|
||||||
|
onSelectionChange={(lang) => {
|
||||||
|
i18n.changeLanguage(lang as string)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</TabPanel>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import { useTranslation } from 'react-i18next'
|
|
||||||
import { Button, Popover, PopoverList } from '@/primitives'
|
|
||||||
import { useLanguageLabels } from './useLanguageLabels'
|
|
||||||
|
|
||||||
export const LanguageSelector = () => {
|
|
||||||
const { t, i18n } = useTranslation()
|
|
||||||
const { languagesList, currentLanguage } = useLanguageLabels()
|
|
||||||
return (
|
|
||||||
<Popover aria-label={t('languageSelector.popoverLabel')}>
|
|
||||||
<Button
|
|
||||||
aria-label={t('languageSelector.buttonLabel', {
|
|
||||||
currentLanguage: currentLanguage.label,
|
|
||||||
})}
|
|
||||||
size="sm"
|
|
||||||
variant="primary"
|
|
||||||
outline
|
|
||||||
>
|
|
||||||
{i18n.language}
|
|
||||||
</Button>
|
|
||||||
<PopoverList
|
|
||||||
items={languagesList}
|
|
||||||
onAction={(lang) => {
|
|
||||||
i18n.changeLanguage(lang)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Popover>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { ReactNode } from 'react'
|
import type { ReactNode } from 'react'
|
||||||
import { Div, VerticallyOffCenter } from '@/primitives'
|
import { Div, VerticallyOffCenter } from '@/primitives'
|
||||||
import type { SystemStyleObject } from '../styled-system/types'
|
import type { SystemStyleObject } from '@/styled-system/types'
|
||||||
|
|
||||||
export const Centered = ({
|
export const Centered = ({
|
||||||
width = '38rem',
|
width = '38rem',
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import { Link } from 'wouter'
|
|||||||
import { css } from '@/styled-system/css'
|
import { css } from '@/styled-system/css'
|
||||||
import { Stack } from '@/styled-system/jsx'
|
import { Stack } from '@/styled-system/jsx'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { A, Button, Popover, PopoverList, Text } from '@/primitives'
|
import { A, Text, Button } from '@/primitives'
|
||||||
import { SettingsButton } from '@/features/settings'
|
import { SettingsButton } from '@/features/settings'
|
||||||
import { authUrl, logoutUrl, useUser } from '@/features/auth'
|
import { authUrl, logoutUrl, useUser } from '@/features/auth'
|
||||||
import { useMatchesRoute } from '@/navigation/useMatchesRoute'
|
import { useMatchesRoute } from '@/navigation/useMatchesRoute'
|
||||||
import { Feedback } from '@/components/Feedback'
|
import { Feedback } from '@/components/Feedback'
|
||||||
|
import { Menu } from '@/primitives/Menu'
|
||||||
|
import { MenuList } from '@/primitives/MenuList'
|
||||||
|
|
||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -64,7 +66,7 @@ export const Header = () => {
|
|||||||
<A href={authUrl()}>{t('login')}</A>
|
<A href={authUrl()}>{t('login')}</A>
|
||||||
)}
|
)}
|
||||||
{!!user && (
|
{!!user && (
|
||||||
<Popover aria-label={t('logout')}>
|
<Menu>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
invisible
|
invisible
|
||||||
@@ -73,15 +75,15 @@ export const Header = () => {
|
|||||||
>
|
>
|
||||||
{user.email}
|
{user.email}
|
||||||
</Button>
|
</Button>
|
||||||
<PopoverList
|
<MenuList
|
||||||
items={[{ key: 'logout', value: 'logout', label: t('logout') }]}
|
items={[{ value: 'logout', label: t('logout') }]}
|
||||||
onAction={(value) => {
|
onAction={(value) => {
|
||||||
if (value === 'logout') {
|
if (value === 'logout') {
|
||||||
window.location.href = logoutUrl()
|
window.location.href = logoutUrl()
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Popover>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
<SettingsButton />
|
<SettingsButton />
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -10,15 +10,12 @@
|
|||||||
"forbidden": {
|
"forbidden": {
|
||||||
"heading": ""
|
"heading": ""
|
||||||
},
|
},
|
||||||
"languageSelector": {
|
|
||||||
"buttonLabel": "",
|
|
||||||
"popoverLabel": ""
|
|
||||||
},
|
|
||||||
"loading": "",
|
"loading": "",
|
||||||
"loggedInUserTooltip": "",
|
"loggedInUserTooltip": "",
|
||||||
"login": "Anmelden",
|
"login": "Anmelden",
|
||||||
"logout": "",
|
"logout": "",
|
||||||
"notFound": {
|
"notFound": {
|
||||||
"heading": ""
|
"heading": ""
|
||||||
}
|
},
|
||||||
|
"submit": "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,16 @@
|
|||||||
"joinMeeting": "",
|
"joinMeeting": "",
|
||||||
"joinMeetingTipContent": "",
|
"joinMeetingTipContent": "",
|
||||||
"joinMeetingTipHeading": "",
|
"joinMeetingTipHeading": "",
|
||||||
"loginToCreateMeeting": ""
|
"loginToCreateMeeting": "",
|
||||||
|
"createMenu": {
|
||||||
|
"laterOption": "",
|
||||||
|
"instantOption": ""
|
||||||
|
},
|
||||||
|
"laterMeetingDialog": {
|
||||||
|
"heading": "",
|
||||||
|
"description": "",
|
||||||
|
"copy": "",
|
||||||
|
"copied": "",
|
||||||
|
"permissions": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"defaultName": "",
|
||||||
|
"joined": {
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"raised": {
|
||||||
|
"description": "",
|
||||||
|
"cta": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,65 @@
|
|||||||
},
|
},
|
||||||
"leaveRoomPrompt": "",
|
"leaveRoomPrompt": "",
|
||||||
"shareDialog": {
|
"shareDialog": {
|
||||||
"copied": "",
|
|
||||||
"copy": "",
|
"copy": "",
|
||||||
|
"copied": "",
|
||||||
"heading": "",
|
"heading": "",
|
||||||
"inputLabel": ""
|
"description": "",
|
||||||
|
"permissions": ""
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"createRoom": {
|
"createRoom": {
|
||||||
"heading": "",
|
"heading": "",
|
||||||
"body": ""
|
"body": ""
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"controls": {
|
||||||
|
"microphone": "",
|
||||||
|
"camera": "",
|
||||||
|
"shareScreen": "",
|
||||||
|
"stopScreenShare": "",
|
||||||
|
"chat": {
|
||||||
|
"open": "",
|
||||||
|
"closed": ""
|
||||||
|
},
|
||||||
|
"hand": {
|
||||||
|
"raise": "",
|
||||||
|
"lower": ""
|
||||||
|
},
|
||||||
|
"leave": "",
|
||||||
|
"participants": {
|
||||||
|
"open": "",
|
||||||
|
"closed": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"buttonLabel": "",
|
||||||
|
"items": {
|
||||||
|
"feedbacks": "",
|
||||||
|
"support": "",
|
||||||
|
"settings": "",
|
||||||
|
"username": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"participants": {
|
||||||
|
"heading": "",
|
||||||
|
"subheading": "",
|
||||||
|
"closeButton": "",
|
||||||
|
"contributors": "",
|
||||||
|
"collapsable": {
|
||||||
|
"open": "",
|
||||||
|
"close": ""
|
||||||
|
},
|
||||||
|
"you": "",
|
||||||
|
"muteYourself": "",
|
||||||
|
"muteParticipant": "",
|
||||||
|
"muteParticipantAlert": {
|
||||||
|
"description": "",
|
||||||
|
"confirm": "",
|
||||||
|
"cancel": ""
|
||||||
|
},
|
||||||
|
"raisedHands": "",
|
||||||
|
"lowerParticipantHand": "",
|
||||||
|
"lowerParticipantsHand": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,24 @@
|
|||||||
{
|
{
|
||||||
|
"account": {
|
||||||
|
"currentlyLoggedAs": "",
|
||||||
|
"heading": "",
|
||||||
|
"youAreNotLoggedIn": "",
|
||||||
|
"nameLabel": "",
|
||||||
|
"authentication": ""
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"microphone": {
|
||||||
|
"heading": "",
|
||||||
|
"label": ""
|
||||||
|
},
|
||||||
|
"speakers": {
|
||||||
|
"heading": "",
|
||||||
|
"label": "",
|
||||||
|
"test": "",
|
||||||
|
"ongoingTest": ""
|
||||||
|
},
|
||||||
|
"permissionsRequired": ""
|
||||||
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"heading": ""
|
"heading": ""
|
||||||
},
|
},
|
||||||
@@ -6,5 +26,10 @@
|
|||||||
"heading": "",
|
"heading": "",
|
||||||
"label": ""
|
"label": ""
|
||||||
},
|
},
|
||||||
"settingsButtonLabel": ""
|
"settingsButtonLabel": "",
|
||||||
|
"tabs": {
|
||||||
|
"account": "",
|
||||||
|
"audio": "",
|
||||||
|
"general": ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,12 @@
|
|||||||
"forbidden": {
|
"forbidden": {
|
||||||
"heading": "You don't have the permission to view this page"
|
"heading": "You don't have the permission to view this page"
|
||||||
},
|
},
|
||||||
"languageSelector": {
|
|
||||||
"buttonLabel": "Change language (currently {{currentLanguage}})",
|
|
||||||
"popoverLabel": "Choose language"
|
|
||||||
},
|
|
||||||
"loading": "Loading…",
|
"loading": "Loading…",
|
||||||
"loggedInUserTooltip": "Logged in as…",
|
"loggedInUserTooltip": "Logged in as…",
|
||||||
"login": "Login",
|
"login": "Login",
|
||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"notFound": {
|
"notFound": {
|
||||||
"heading": "Page not found"
|
"heading": "Page not found"
|
||||||
}
|
},
|
||||||
|
"submit": "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,16 @@
|
|||||||
"joinMeeting": "Join a meeting",
|
"joinMeeting": "Join a meeting",
|
||||||
"joinMeetingTipContent": "You can join a meeting by pasting its full link in the browser's address bar.",
|
"joinMeetingTipContent": "You can join a meeting by pasting its full link in the browser's address bar.",
|
||||||
"joinMeetingTipHeading": "Did you know?",
|
"joinMeetingTipHeading": "Did you know?",
|
||||||
"loginToCreateMeeting": "Login to create a meeting"
|
"loginToCreateMeeting": "Login to create a meeting",
|
||||||
|
"createMenu": {
|
||||||
|
"laterOption": "Create a meeting for a later date",
|
||||||
|
"instantOption": "Start an instant meeting"
|
||||||
|
},
|
||||||
|
"laterMeetingDialog": {
|
||||||
|
"heading": "Your connection details",
|
||||||
|
"description": "Send this link to the people you want to invite to the meeting. They will be able to join without Agent Connect.",
|
||||||
|
"copy": "Copy the meeting link",
|
||||||
|
"copied": "Link copied to clipboard",
|
||||||
|
"permissions": "People with this link do not need your permission to join this meeting."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"defaultName": "A contributor",
|
||||||
|
"joined": {
|
||||||
|
"description": "{{name}} has joined the room"
|
||||||
|
},
|
||||||
|
"raised": {
|
||||||
|
"description": "{{name}} has raised their hand.",
|
||||||
|
"cta": "Open waiting list"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,15 +12,65 @@
|
|||||||
},
|
},
|
||||||
"leaveRoomPrompt": "This will make you leave the meeting.",
|
"leaveRoomPrompt": "This will make you leave the meeting.",
|
||||||
"shareDialog": {
|
"shareDialog": {
|
||||||
"copied": "Copied",
|
"copy": "Copy the meeting link",
|
||||||
"copy": "Copy",
|
"copied": "Link copied to clipboard",
|
||||||
"heading": "Share the meeting link",
|
"heading": "Your meeting is ready",
|
||||||
"inputLabel": "Meeting link"
|
"description": "Share this link with people you want to invite to the meeting.",
|
||||||
|
"permissions": "People with this link do not need your permission to join this meeting."
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"createRoom": {
|
"createRoom": {
|
||||||
"heading": "Authentication Required",
|
"heading": "Authentication Required",
|
||||||
"body": "This room has not been created yet. Please authenticate to create it or wait for an authenticated user to do so."
|
"body": "This room has not been created yet. Please authenticate to create it or wait for an authenticated user to do so."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"controls": {
|
||||||
|
"microphone": "Microphone",
|
||||||
|
"camera": "Camera",
|
||||||
|
"shareScreen": "Share screen",
|
||||||
|
"stopScreenShare": "Stop screen share",
|
||||||
|
"chat": {
|
||||||
|
"open": "Close the chat",
|
||||||
|
"closed": "Open the chat"
|
||||||
|
},
|
||||||
|
"hand": {
|
||||||
|
"raise": "Raise hand",
|
||||||
|
"lower": "Lower hand"
|
||||||
|
},
|
||||||
|
"leave": "Leave",
|
||||||
|
"participants": {
|
||||||
|
"open": "Hide everyone",
|
||||||
|
"closed": "See everyone"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"buttonLabel": "More Options",
|
||||||
|
"items": {
|
||||||
|
"feedbacks": "Give us feedbacks",
|
||||||
|
"support": "Get Help on Tchap",
|
||||||
|
"settings": "Settings",
|
||||||
|
"username": "Update Your Name"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"participants": {
|
||||||
|
"heading": "Participants",
|
||||||
|
"subheading": "In room",
|
||||||
|
"closeButton": "Hide participants",
|
||||||
|
"you": "You",
|
||||||
|
"contributors": "Contributors",
|
||||||
|
"collapsable": {
|
||||||
|
"open": "Open {{name}} list",
|
||||||
|
"close": "Close {{name}} list"
|
||||||
|
},
|
||||||
|
"muteYourself": "Close your mic",
|
||||||
|
"muteParticipant": "Close the mic of {{name}}",
|
||||||
|
"muteParticipantAlert": {
|
||||||
|
"description": "Mute {{name}} for all participants? {{name}} will be the only one who can unmute themselves.",
|
||||||
|
"confirm": "Mute",
|
||||||
|
"cancel": "Cancel"
|
||||||
|
},
|
||||||
|
"raisedHands": "Raised hands",
|
||||||
|
"lowerParticipantHand": "Lower {{name}}'s hand",
|
||||||
|
"lowerParticipantsHand": "Lower all hands"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,24 @@
|
|||||||
{
|
{
|
||||||
|
"account": {
|
||||||
|
"currentlyLoggedAs": "You are currently logged in as <0>{{user}}</0>",
|
||||||
|
"heading": "Account",
|
||||||
|
"youAreNotLoggedIn": "You are not logged in.",
|
||||||
|
"nameLabel": "Votre Nom",
|
||||||
|
"authentication": "Authentication"
|
||||||
|
},
|
||||||
|
"audio": {
|
||||||
|
"microphone": {
|
||||||
|
"heading": "Microphone",
|
||||||
|
"label": "Select your audio input"
|
||||||
|
},
|
||||||
|
"speakers": {
|
||||||
|
"heading": "Speakers",
|
||||||
|
"label": "Select your audio output",
|
||||||
|
"test": "Test",
|
||||||
|
"ongoingTest": "Testing sound…"
|
||||||
|
},
|
||||||
|
"permissionsRequired": "Permissions required"
|
||||||
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"heading": "Settings"
|
"heading": "Settings"
|
||||||
},
|
},
|
||||||
@@ -6,5 +26,10 @@
|
|||||||
"heading": "Language",
|
"heading": "Language",
|
||||||
"label": "Language"
|
"label": "Language"
|
||||||
},
|
},
|
||||||
"settingsButtonLabel": "Settings"
|
"settingsButtonLabel": "Settings",
|
||||||
|
"tabs": {
|
||||||
|
"account": "Profile",
|
||||||
|
"audio": "Audio",
|
||||||
|
"general": "General"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,15 +10,12 @@
|
|||||||
"forbidden": {
|
"forbidden": {
|
||||||
"heading": "Accès interdit"
|
"heading": "Accès interdit"
|
||||||
},
|
},
|
||||||
"languageSelector": {
|
|
||||||
"buttonLabel": "Changer de langue (actuellement {{currentLanguage}})",
|
|
||||||
"popoverLabel": "Choix de la langue"
|
|
||||||
},
|
|
||||||
"loading": "Chargement…",
|
"loading": "Chargement…",
|
||||||
"loggedInUserTooltip": "Connecté en tant que…",
|
"loggedInUserTooltip": "Connecté en tant que…",
|
||||||
"login": "Se connecter",
|
"login": "Se connecter",
|
||||||
"logout": "Se déconnecter",
|
"logout": "Se déconnecter",
|
||||||
"notFound": {
|
"notFound": {
|
||||||
"heading": "Page introuvable"
|
"heading": "Page introuvable"
|
||||||
}
|
},
|
||||||
|
"submit": "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user