forked from github/cinny
Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 695218595a | |||
| 7f08ce6b10 | |||
| 5967455d60 | |||
| 3b681ac766 | |||
| 8e6b26477a | |||
| 3b8d7fb026 | |||
| 7f12d047f3 | |||
| 1173c17452 | |||
| 8c892f14f8 | |||
| 5423e8bb7a | |||
|
|
a33e8db9a3 | ||
|
|
fb76e3ecb4 | ||
|
|
3d79293167 | ||
|
|
74745edcda | ||
|
|
0812131a97 | ||
|
|
1068bba5c7 | ||
|
|
1b5e58a3b4 | ||
|
|
acae043f31 | ||
|
|
b4299f8f37 | ||
|
|
b6adac6714 | ||
|
|
1c8f203164 | ||
|
|
0c30ece281 | ||
|
|
4e559e56d4 | ||
|
|
19f28b40ac | ||
|
|
bcaf43a540 | ||
|
|
9c7b635e7e | ||
|
|
65c87dff3a | ||
|
|
132a76df27 | ||
|
|
b0954eeddc | ||
|
|
8f1add6059 | ||
|
|
8a78c9699e | ||
|
|
0721b29a2c | ||
|
|
3d354909d6 | ||
|
|
7570a84dfd | ||
|
|
6a05ff5840 | ||
|
|
919fe8381b | ||
|
|
b76ad3caaf | ||
|
|
409d45857d | ||
|
|
0d1566977a | ||
|
|
0cbfbab5ad | ||
|
|
37e0c2aaac | ||
|
|
296249de32 | ||
|
|
4449e7c6e8 | ||
|
|
2eb5a9a616 | ||
|
|
d679e68501 | ||
|
|
bc6caddcc8 | ||
|
|
55e8306576 | ||
|
|
7953ec80e5 | ||
|
|
c6bb4915bc | ||
|
|
b050cd01f9 | ||
|
|
730670cf52 | ||
|
|
c5c8703699 | ||
|
|
2bd1570d6b | ||
|
|
68b6a09697 | ||
|
|
7b52c921d5 | ||
|
|
bb8b9ab6da | ||
|
|
971f312b46 | ||
|
|
e0d5c63dc5 | ||
|
|
85fcbd84fe | ||
|
|
221bc04754 | ||
|
|
6347640a35 | ||
|
|
f2d8ad0b6b | ||
|
|
739786d9ab | ||
|
|
f642809939 | ||
|
|
02106a99b9 | ||
|
|
df3a3ba789 | ||
|
|
cd80d4c9e8 | ||
|
|
dab44edef2 | ||
|
|
ed0ad61bc4 | ||
|
|
b2cb717178 | ||
|
|
7a9f6d2223 | ||
|
|
a9022184fc | ||
|
|
826b3c2997 | ||
|
|
2e6c5f7c04 | ||
|
|
2d6730de56 | ||
|
|
b6cc0e3077 | ||
|
|
91c8731940 | ||
|
|
1f03891b25 | ||
|
|
9ff15b8b03 | ||
|
|
170f5cd473 |
127
.github/DISCUSSION_TEMPLATE/issue-triage.yml
vendored
Normal file
127
.github/DISCUSSION_TEMPLATE/issue-triage.yml
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
labels: ["needs-confirmation"]
|
||||
body:
|
||||
- type: markdown #add faqs in future
|
||||
attributes:
|
||||
value: |
|
||||
> [!IMPORTANT]
|
||||
> Please read through [the Discussion rules](https://github.com/cinnyapp/cinny/discussions/2653) and check for both existing [Discussions](https://github.com/cinnyapp/cinny/discussions?discussions_q=) and [Issues](https://github.com/cinnyapp/cinny/issues?q=sort%3Areactions-desc) prior to opening a new Discussion.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "# Issue Details"
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Issue Description
|
||||
description: |
|
||||
Provide a detailed description of the issue. Include relevant information, such as:
|
||||
- The feature or configuration option you encounter the issue with.
|
||||
- Screenshots, screen recordings, or other supporting media (as needed).
|
||||
- If this is a regression of an existing issue that was closed or resolved, please include the previous item reference (Discussion, Issue, PR, commit) in your description.
|
||||
placeholder: |
|
||||
When I try to send a message in a room, the message doesn't appear in the timeline.
|
||||
OR
|
||||
The application crashes when I click on the settings button.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: |
|
||||
Describe how you expect Cinny to behave in this situation.
|
||||
placeholder: |
|
||||
I expected the message to appear in the room timeline immediately after sending.
|
||||
OR
|
||||
The settings panel should open smoothly without any crashes.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Actual Behavior
|
||||
description: |
|
||||
Describe how Cinny actually behaves in this situation. If it is not immediately obvious how the actual behavior differs from the expected behavior described above, please be sure to mention the deviation specifically.
|
||||
placeholder: |
|
||||
The application freezes for 3 seconds and then shows a white screen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Reproduction Steps
|
||||
description: |
|
||||
Provide a detailed set of step-by-step instructions for reproducing this issue.
|
||||
placeholder: |
|
||||
1. Open Cinny and log in to my account
|
||||
2. Navigate to the #general room
|
||||
3. Type a message in the message box
|
||||
4. Press Enter to send
|
||||
5. Notice that the message doesn't appear in the timeline
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environement
|
||||
description: |
|
||||
Please provide information about your environment. Include the following:
|
||||
- OS:
|
||||
- Browser:
|
||||
- Cinny Web Version: (app.cinny.in or self hosted)
|
||||
- Cinny desktop Version: (appimage or deb or flatpak)
|
||||
- Matrix Homeserver:
|
||||
placeholder: |
|
||||
- OS: Windows 11
|
||||
- Browser: Chrome 120.0.6099.109
|
||||
- Cinny Web Version: 3.2.0 (app.cinny.in or self hosted)
|
||||
- Cinny desktop Version: 3.2.0 (appimage or deb or flatpak)
|
||||
- Matrix Homeserver: matrix.org (Synapse 1.97.0)
|
||||
render: text
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant Logs
|
||||
description: |
|
||||
If applicable, add browser console logs to help explain your problem.
|
||||
|
||||
**To get browser console logs:**
|
||||
- Chrome/Edge: Press F12 → Console tab
|
||||
- Firefox: Press F12 → Console tab
|
||||
- Safari: Develop → Show Web Inspector → Console
|
||||
|
||||
Please wrap large log outputs in code blocks with triple backticks (```).
|
||||
placeholder: |
|
||||
```
|
||||
Error: Failed to send message
|
||||
at MessageComposer.sendMessage (composer.js:245)
|
||||
at HTMLButtonElement.onClick (composer.js:189)
|
||||
TypeError: Cannot read property 'content' of undefined
|
||||
at RoomTimeline.render (timeline.js:567)
|
||||
```
|
||||
render: shell
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: |
|
||||
Add any other context about the problem here (e.g., when did this start happening, does it happen on different homeservers, etc.)
|
||||
placeholder: |
|
||||
- This started happening after I updated to version 3.2.0
|
||||
- It only happens in encrypted rooms, not in public rooms
|
||||
- I've tried on both Firefox and Chrome with the same result
|
||||
- It works fine on my phone using the same account
|
||||
- This happens on all homeservers I've tested (matrix.org, mozilla.org)
|
||||
validations:
|
||||
required: false
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
# User Acknowledgements
|
||||
> [!TIP]
|
||||
> Use these links to review the existing Cinny [Discussions](https://github.com/cinnyapp/cinny/discussions?discussions_q=) and [Issues](https://github.com/cinnyapp/cinny/issues?q=sort%3Areactions-desc).
|
||||
- type: checkboxes #add faqs in future
|
||||
attributes:
|
||||
label: "I acknowledge that:"
|
||||
options:
|
||||
- label: I have searched the Cinny repository (both open and closed Discussions and Issues) and confirm this is not a duplicate of an existing issue or discussion.
|
||||
required: true
|
||||
- label: I have checked the "Preview" tab on all text fields to ensure that everything looks right, and have wrapped all configuration and code in code blocks with a group of three backticks (` ``` `) on separate lines.
|
||||
required: true
|
||||
57
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
57
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -1,57 +0,0 @@
|
||||
name: 🐞 Bug Report
|
||||
description: Report a bug
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
## First of all
|
||||
1. Please search for [existing issues](https://github.com/ajbura/cinny/issues?q=is%3Aissue) about this problem first.
|
||||
2. Make sure Cinny is up to date.
|
||||
3. Make sure it's an issue with Cinny and not something else you are using.
|
||||
4. Remember to be friendly.
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear description of what the bug is. Include screenshots if applicable.
|
||||
placeholder: Bug description
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1. Go to ...
|
||||
2. Click on ...
|
||||
3. See error
|
||||
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear description of what you expected to happen.
|
||||
|
||||
- type: textarea
|
||||
id: info
|
||||
attributes:
|
||||
label: Platform and versions
|
||||
description: "Provide OS, browser and Cinny version with your Homeserver."
|
||||
placeholder: |
|
||||
1. OS: [e.g. Windows 10, MacOS]
|
||||
2. Browser: [e.g. chrome 99.5, firefox 97.2]
|
||||
3. Cinny version: [e.g. 1.8.1 (app.cinny.in)]
|
||||
4. Matrix homeserver: [e.g. matrix.org]
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
7
.github/ISSUE_TEMPLATE/config.yml
vendored
7
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,4 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 💬 Matrix Chat
|
||||
url: https://matrix.to/#/#cinny:matrix.org
|
||||
about: Ask questions and talk to other Cinny users and the maintainers
|
||||
- name: Features, Bug Reports, Questions
|
||||
url: https://github.com/cinnyapp/cinny/discussions/new/choose
|
||||
about: Our preferred starting point if you have any questions or suggestions about features or behavior.
|
||||
|
||||
33
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
33
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
@@ -1,33 +0,0 @@
|
||||
name: 💡 Feature Request
|
||||
description: Suggest an idea
|
||||
|
||||
body:
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Describe the problem
|
||||
description: A clear description of the problem this feature would solve
|
||||
placeholder: "I'm always frustrated when..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: "Describe the solution you'd like"
|
||||
description: A clear description of what change you would like
|
||||
placeholder: "I would like to..."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: "Any alternative solutions you've considered"
|
||||
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
9
.github/ISSUE_TEMPLATE/preapproved.md
vendored
Normal file
9
.github/ISSUE_TEMPLATE/preapproved.md
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
name: Pre-Discussed and Approved Topics
|
||||
about: |-
|
||||
Only for topics already discussed and approved in the GitHub Discussions section.
|
||||
---
|
||||
|
||||
**DO NOT OPEN A NEW ISSUE. PLEASE USE THE DISCUSSIONS SECTION.**
|
||||
|
||||
**I DIDN'T READ THE ABOVE LINE. PLEASE CLOSE THIS ISSUE.**
|
||||
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,22 +0,0 @@
|
||||
<!-- Please read https://github.com/ajbura/cinny/blob/dev/CONTRIBUTING.md before submitting your pull request -->
|
||||
|
||||
### Description
|
||||
<!-- Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. -->
|
||||
|
||||
|
||||
Fixes #
|
||||
|
||||
#### Type of change
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
- [ ] This change requires a documentation update
|
||||
|
||||
### Checklist:
|
||||
|
||||
- [ ] My code follows the style guidelines of this project
|
||||
- [ ] I have performed a self-review of my own code
|
||||
- [ ] I have commented my code, particularly in hard-to-understand areas
|
||||
- [ ] I have made corresponding changes to the documentation
|
||||
- [ ] My changes generate no new warnings
|
||||
3
.github/SECURITY.md
vendored
3
.github/SECURITY.md
vendored
@@ -1,3 +0,0 @@
|
||||
# Reporting a Vulnerability
|
||||
|
||||
**If you've found a security vulnerability, please report it to cinnyapp@gmail.com**
|
||||
20
.github/renovate.json
vendored
20
.github/renovate.json
vendored
@@ -1,10 +1,28 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:recommended", ":dependencyDashboardApproval"],
|
||||
"extends": [
|
||||
"config:recommended",
|
||||
":dependencyDashboardApproval",
|
||||
":semanticCommits",
|
||||
"group:monorepos"
|
||||
],
|
||||
"labels": ["Dependencies"],
|
||||
"rebaseWhen": "conflicted",
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": ["lockFileMaintenance"]
|
||||
},
|
||||
{
|
||||
"groupName": "Slatejs",
|
||||
"matchPackageNames": ["slate", "slate-dom", "slate-history", "slate-react"]
|
||||
},
|
||||
{
|
||||
"groupName": "Call",
|
||||
"matchPackageNames": ["@element-hq/element-call-embedded", "matrix-widget-api"]
|
||||
},
|
||||
{
|
||||
"groupName": "Linkify",
|
||||
"matchPackageNames": ["linkifyjs", "linkify-react"]
|
||||
}
|
||||
],
|
||||
"lockFileMaintenance": {
|
||||
|
||||
12
.github/workflows/build-pull-request.yml
vendored
12
.github/workflows/build-pull-request.yml
vendored
@@ -12,12 +12,12 @@ jobs:
|
||||
PR_NUMBER: ${{github.event.number}}
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: 20.12.2
|
||||
cache: 'npm'
|
||||
node-version-file: ".node-version"
|
||||
package-manager-cache: false
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build app
|
||||
@@ -25,7 +25,7 @@ jobs:
|
||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
||||
run: npm run build
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: preview
|
||||
path: dist
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Save pr number
|
||||
run: echo ${PR_NUMBER} > ./pr.txt
|
||||
- name: Upload pr number
|
||||
uses: actions/upload-artifact@v4.6.2
|
||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: pr
|
||||
path: ./pr.txt
|
||||
|
||||
2
.github/workflows/cla.yml
vendored
2
.github/workflows/cla.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
||||
- name: 'CLA Assistant'
|
||||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
||||
# Beta Release
|
||||
uses: cla-assistant/github-action@v2.6.1
|
||||
uses: cla-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# the below token should have repo scope and must be manually added by you in the repository's secret
|
||||
|
||||
15
.github/workflows/deploy-pull-request.yml
vendored
15
.github/workflows/deploy-pull-request.yml
vendored
@@ -1,4 +1,5 @@
|
||||
name: Deploy PR to Netlify
|
||||
run-name: "Deploy PR to Netlify (${{ github.event.workflow_run.head_branch }})"
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
@@ -15,7 +16,7 @@ jobs:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
steps:
|
||||
- name: Download pr number
|
||||
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5
|
||||
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
|
||||
with:
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
@@ -24,7 +25,7 @@ jobs:
|
||||
id: pr
|
||||
run: echo "id=$(<pr.txt)" >> $GITHUB_OUTPUT
|
||||
- name: Download artifact
|
||||
uses: dawidd6/action-download-artifact@ac66b43f0e6a346234dd65d4d0c8fbb31cb316e5
|
||||
uses: dawidd6/action-download-artifact@8305c0f1062bb0d184d09ef4493ecb9288447732 # v20
|
||||
with:
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
@@ -32,7 +33,7 @@ jobs:
|
||||
path: dist
|
||||
- name: Deploy to Netlify
|
||||
id: netlify
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0.0
|
||||
with:
|
||||
publish-dir: dist
|
||||
deploy-message: "Deploy PR ${{ steps.pr.outputs.id }}"
|
||||
@@ -45,12 +46,12 @@ jobs:
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_PR_CINNY }}
|
||||
timeout-minutes: 1
|
||||
- name: Comment preview on PR
|
||||
uses: thollander/actions-comment-pull-request@fabd468d3a1a0b97feee5f6b9e499eab0dd903f6
|
||||
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b #v3.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
pr_number: ${{ steps.pr.outputs.id }}
|
||||
comment_tag: ${{ steps.pr.outputs.id }}
|
||||
pr-number: ${{ steps.pr.outputs.id }}
|
||||
comment-tag: ${{ steps.pr.outputs.id }}
|
||||
message: |
|
||||
Preview: ${{ steps.netlify.outputs.deploy-url }}
|
||||
⚠️ Exercise caution. Use test accounts. ⚠️
|
||||
50
.github/workflows/docker-pr.yml
vendored
50
.github/workflows/docker-pr.yml
vendored
@@ -5,15 +5,59 @@ on:
|
||||
paths:
|
||||
- 'Dockerfile'
|
||||
- '.github/workflows/docker-pr.yml'
|
||||
- '.github/workflows/prod-deploy.yml'
|
||||
|
||||
jobs:
|
||||
docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
- name: Build Docker image
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
|
||||
- name: Login to Docker Hub #Do not update this action from a outside PR
|
||||
if: github.event.pull_request.head.repo.fork == false
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Login to the Github Container registry #Do not update this action from a outside PR
|
||||
if: github.event.pull_request.head.repo.fork == false
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
continue-on-error: true
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker, GHCR
|
||||
id: meta
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
||||
with:
|
||||
images: |
|
||||
ajbura/cinny
|
||||
ghcr.io/${{ github.repository }}
|
||||
|
||||
- name: Build Docker image (no push)
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: false
|
||||
load: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
- name: Show Docker images
|
||||
run: docker images
|
||||
|
||||
4
.github/workflows/lockfile.yml
vendored
4
.github/workflows/lockfile.yml
vendored
@@ -14,9 +14,9 @@ jobs:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: NPM Lockfile Changes
|
||||
uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891
|
||||
uses: codepunkt/npm-lockfile-changes@b40543471c36394409466fdb277a73a0856d7891 # v1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Optional inputs, can be deleted safely if you are happy with default values.
|
||||
|
||||
10
.github/workflows/netlify-dev.yml
vendored
10
.github/workflows/netlify-dev.yml
vendored
@@ -11,12 +11,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4.4.0
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version: 20.12.2
|
||||
cache: 'npm'
|
||||
node-version-file: ".node-version"
|
||||
package-manager-cache: false
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Build app
|
||||
@@ -24,7 +24,7 @@ jobs:
|
||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
||||
run: npm run build
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0.0
|
||||
with:
|
||||
publish-dir: dist
|
||||
deploy-message: 'Dev deploy ${{ github.sha }}'
|
||||
|
||||
15
.github/workflows/pr-title.yml
vendored
Normal file
15
.github/workflows/pr-title.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: Check PR title
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
70
.github/workflows/prod-deploy.yml
vendored
70
.github/workflows/prod-deploy.yml
vendored
@@ -1,32 +1,48 @@
|
||||
name: Production deploy
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy-and-tarball:
|
||||
name: Netlify deploy and tarball
|
||||
outputs:
|
||||
version: ${{ steps.vars.outputs.tag }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v4.4.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
node-version: 20.12.2
|
||||
cache: 'npm'
|
||||
fetch-depth: 0
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
|
||||
with:
|
||||
node-version-file: ".node-version"
|
||||
package-manager-cache: false
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Run semantic release
|
||||
run: npm run semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
|
||||
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
|
||||
GIT_COMMITTER_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
|
||||
GIT_COMMITTER_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
|
||||
- name: Get version from tag
|
||||
id: vars
|
||||
run: |
|
||||
TAG=$(git describe --tags --abbrev=0)
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
- name: Build app
|
||||
env:
|
||||
NODE_OPTIONS: '--max_old_space_size=4096'
|
||||
run: npm run build
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654
|
||||
uses: nwtgck/actions-netlify@4cbaf4c08f1a7bfa537d6113472ef4424e4eb654 # v3.0.0
|
||||
with:
|
||||
publish-dir: dist
|
||||
deploy-message: 'Prod deploy ${{ github.ref_name }}'
|
||||
deploy-message: 'Prod deploy ${{ steps.vars.outputs.tag }}'
|
||||
enable-commit-comment: false
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
production-deploy: true
|
||||
@@ -36,9 +52,6 @@ jobs:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_APP }}
|
||||
timeout-minutes: 1
|
||||
- name: Get version from tag
|
||||
id: vars
|
||||
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
|
||||
- name: Create tar.gz
|
||||
run: tar -czvf cinny-${{ steps.vars.outputs.tag }}.tar.gz dist
|
||||
- name: Sign tar.gz
|
||||
@@ -52,45 +65,54 @@ jobs:
|
||||
gpg --export | xxd -p
|
||||
echo '${{ secrets.GNUPG_PASSPHRASE }}' | gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --armor --detach-sign cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
||||
- name: Upload tagged release
|
||||
uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836
|
||||
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
|
||||
with:
|
||||
tag_name: ${{ steps.vars.outputs.tag }}
|
||||
files: |
|
||||
cinny-${{ steps.vars.outputs.tag }}.tar.gz
|
||||
cinny-${{ steps.vars.outputs.tag }}.tar.gz.asc
|
||||
|
||||
publish-image:
|
||||
name: Push Docker image to Docker Hub, ghcr
|
||||
name: Push Docker image to Docker Hub, GHCR
|
||||
needs: deploy-and-tarball
|
||||
env:
|
||||
VERSION: ${{ needs.deploy-and-tarball.outputs.version }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4.2.0
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3.6.0
|
||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3.11.1
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3.6.0
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
- name: Login to Docker Hub #Do not update this action from a outside PR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
- name: Login to the Container registry
|
||||
uses: docker/login-action@v3.6.0
|
||||
- name: Login to the Github Container registry #Do not update this action from a outside PR
|
||||
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
- name: Extract metadata (tags, labels) for Docker, GHCR
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5.8.0
|
||||
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
|
||||
with:
|
||||
images: |
|
||||
${{ secrets.DOCKER_USERNAME }}/cinny
|
||||
ghcr.io/${{ github.repository }}
|
||||
tags: |
|
||||
type=raw,value=${{ env.VERSION }}
|
||||
type=raw,value=latest
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6.18.0
|
||||
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
|
||||
3
.husky/pre-commit
Normal file
3
.husky/pre-commit
Normal file
@@ -0,0 +1,3 @@
|
||||
# These are commented until we enable lint and typecheck
|
||||
# npx tsc -p tsconfig.json --noEmit
|
||||
# npx lint-staged
|
||||
1
.node-version
Normal file
1
.node-version
Normal file
@@ -0,0 +1 @@
|
||||
24.13.1
|
||||
@@ -18,7 +18,7 @@ Bug reports and feature suggestions must use descriptive and concise titles and
|
||||
## Pull requests
|
||||
|
||||
> ### Legal Notice
|
||||
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license.
|
||||
> When contributing to this project, you must agree that you have authored 100% of the content, that you have the necessary rights to the content and that the content you contribute may be provided under the project license. You will also be asked to [sign the CLA](https://github.com/cinnyapp/cla) upon submiting your pull request.
|
||||
|
||||
**NOTE: If you want to add new features, please discuss with maintainers before coding or opening a pull request.** This is to ensure that we are on same track and following our roadmap.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
## Builder
|
||||
FROM node:20.12.2-alpine3.18 as builder
|
||||
FROM node:24.13.1-alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
@@ -11,7 +11,7 @@ RUN npm run build
|
||||
|
||||
|
||||
## App
|
||||
FROM nginx:1.29.3-alpine
|
||||
FROM nginx:1.29.8-alpine
|
||||
|
||||
COPY --from=builder /src/dist /app
|
||||
COPY --from=builder /src/docker-nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
@@ -16,6 +16,10 @@ A Matrix client focusing primarily on simple, elegant and secure interface. The
|
||||
- [Roadmap](https://github.com/orgs/cinnyapp/projects/1)
|
||||
- [Contributing](./CONTRIBUTING.md)
|
||||
|
||||
> [!IMPORTANT]
|
||||
We are currently in the [process of replacing the matrix-js-sdk](https://github.com/cinnyapp/cinny/issues/257#issuecomment-3714406704) with our own SDK. As a result, we will not be accepting any pull requests until further notice.
|
||||
Thank you for your understanding.
|
||||
|
||||
<img align="center" src="https://raw.githubusercontent.com/cinnyapp/cinny-site/main/assets/preview2-light.png" height="380">
|
||||
|
||||
## Getting started
|
||||
@@ -83,7 +87,7 @@ mxFo+ioe/ABCufSmyqFye0psX3Sp
|
||||
|
||||
## Local development
|
||||
> [!TIP]
|
||||
> We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple Node.js versions based on the needs of different projects you're working on. [NVM on windows](https://github.com/coreybutler/nvm-windows#installation--upgrades) on Windows and [nvm](https://github.com/nvm-sh/nvm) on Linux/macOS are pretty good choices. Recommended nodejs version is Iron LTS (v20).
|
||||
> We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple Node.js versions based on the needs of different projects you're working on. [NVM on windows](https://github.com/coreybutler/nvm-windows#installation--upgrades) on Windows and [nvm](https://github.com/nvm-sh/nvm) on Linux/macOS are pretty good choices. Recommended nodejs version is Krypton LTS (v24.13.1).
|
||||
|
||||
Execute the following commands to start a development server:
|
||||
```sh
|
||||
|
||||
13
config.json
13
config.json
@@ -1,12 +1,6 @@
|
||||
{
|
||||
"defaultHomeserver": 1,
|
||||
"homeserverList": [
|
||||
"converser.eu",
|
||||
"matrix.org",
|
||||
"mozilla.org",
|
||||
"unredacted.org",
|
||||
"xmr.se"
|
||||
],
|
||||
"homeserverList": ["converser.eu", "matrix.org", "mozilla.org", "unredacted.org", "xmr.se"],
|
||||
"allowCustomHomeservers": true,
|
||||
|
||||
"featuredCommunities": {
|
||||
@@ -17,7 +11,8 @@
|
||||
"#space:unredacted.org",
|
||||
"#science-space:matrix.org",
|
||||
"#libregaming-games:tchncs.de",
|
||||
"#mathematics-on:matrix.org"
|
||||
"#mathematics-on:matrix.org",
|
||||
"#stickers-and-emojis:tastytea.de"
|
||||
],
|
||||
"rooms": [
|
||||
"#cinny:matrix.org",
|
||||
@@ -27,7 +22,7 @@
|
||||
"#PrivSec.dev:arcticfoxes.net",
|
||||
"#disroot:aria-net.org"
|
||||
],
|
||||
"servers": [ "matrix.org", "mozilla.org", "unredacted.org" ]
|
||||
"servers": ["matrixrooms.info", "matrix.org", "mozilla.org", "unredacted.org"]
|
||||
},
|
||||
|
||||
"hashRouter": {
|
||||
|
||||
36
owl/README.md
Normal file
36
owl/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Owl Folder
|
||||
|
||||
owl.cx employs it's own cinny fork.
|
||||
|
||||
this one should slowly introduce changes and features that are useful for a homeserver, and go even further into the direction of replacing teamspeak or discord.
|
||||
|
||||
it does not try to keep up the typical matrix approach to have overengineered decisions in the chat, or avoid all kinds of exploits that are dangerous for federated servers, but less impactful for a single-server-instance.
|
||||
|
||||
It still tries to _respect_ matrix as a tool, that can do all these things.
|
||||
|
||||
In this owl folder should go all documents we produce for this Endeavour.
|
||||
|
||||
## Goals
|
||||
|
||||
- [x] Find a way to build extensions that survive upstream merges best. This means, reduce contact point, create own files, even be in own folder if possible. This needs a thorough scan of the codebase.
|
||||
- [ ] We will try to integrate `comms` project at some point. but this is a separate task, not needed yet. It will bring voice server to the rooms. comms uses a wasm system.
|
||||
- [x] Try to find out how much we can change behaviour of the page with the _themes_ (skins) only. Some small silly things, like that reacting with a new emoji on a post should not be on the left side of a message, where currently it is embedded in a popup.
|
||||
- [x] Find out how we can set that Twitter Emojis are standard - system emojis on windows are terrible.
|
||||
- [x] Find out how we can set a theme by default for new users.
|
||||
- [x] img tags in messages should be rendered, without requiring them to be on a local cache. We do not need to secure against identification attacks.
|
||||
- [x] youtube links should create embedded players (if enabled).
|
||||
- [x] 9gag links with videos should allow them to be played if possible on demand.
|
||||
|
||||
|
||||
## Commit Messages
|
||||
|
||||
- All Commits for OWL changes start with the Owl Emoji 🦉
|
||||
- I do most commits as user
|
||||
|
||||
## Code Guidelines
|
||||
|
||||
- This Repository follows the official cinny repo, but represents a custom modification.
|
||||
- This means we have to keep Upstream Codebase mergable easy
|
||||
- This means: /src/owl/ is the local override folder, longer implementations and definitions go
|
||||
- Only required wirings, imports or unavoidable modifications should be in the main source code.
|
||||
- Learn from owl commits
|
||||
262
owl/REPORT-001-initial-research.md
Normal file
262
owl/REPORT-001-initial-research.md
Normal file
@@ -0,0 +1,262 @@
|
||||
# OWL Research Report #001 - Initial Codebase Analysis
|
||||
|
||||
Date: 2026-04-15
|
||||
|
||||
This report covers the initial research into all goals outlined in the README, except comms integration (deferred).
|
||||
|
||||
---
|
||||
|
||||
## 1. Extension Strategy - Surviving Upstream Merges
|
||||
|
||||
### Codebase Overview
|
||||
|
||||
Cinny is a Vite 5 + React 18 SPA using TypeScript, Jotai for state, `@vanilla-extract/css` for styling, and the `folds` design system. Key layout:
|
||||
|
||||
```
|
||||
src/
|
||||
app/
|
||||
components/ # Reusable React components (48 feature components)
|
||||
features/ # Feature modules (17 major features)
|
||||
hooks/ # Custom React hooks (~40 files)
|
||||
pages/ # Page-level components (routing/auth)
|
||||
plugins/ # Extension plugins (emoji, markdown, calls, etc.)
|
||||
state/ # State management (Jotai atoms)
|
||||
styles/ # CSS (Vanilla Extract)
|
||||
utils/ # Utilities (matrix, room, sanitization, etc.)
|
||||
client/ # Matrix client initialization
|
||||
colors.css.ts # Theme color definitions
|
||||
index.tsx # Application entry point
|
||||
```
|
||||
|
||||
### No Plugin System
|
||||
|
||||
Cinny has **no formal plugin/extension architecture**. All imports are static. The `plugins/` directory is just a naming convention for utility modules, not a registration system.
|
||||
|
||||
### Recommended Isolation Strategy
|
||||
|
||||
All custom owl code lives in a single `src/owl/` directory tree. React and Vite don't care where files live — imports are just paths. This keeps everything in one place that upstream will never touch, making it easy to see the full scope of our fork and trivial to manage across merges.
|
||||
|
||||
```
|
||||
src/owl/
|
||||
components/ # Our custom UI components (YouTubeEmbedCard, etc.)
|
||||
features/ # Our custom feature modules
|
||||
hooks/ # Our custom hooks
|
||||
plugins/ # Our custom plugins
|
||||
state/ # Our custom Jotai atoms & settings
|
||||
styles/ # Our custom CSS (Vanilla Extract)
|
||||
utils/ # Our custom utilities (sanitizer overrides, etc.)
|
||||
```
|
||||
|
||||
Upstream files import our code via relative paths like `import { YouTubeEmbed } from '../../../owl/components/YouTubeEmbed'`. These one-liner injection points are the only upstream modifications needed and are easy to re-apply after a merge.
|
||||
|
||||
### Injection Points (unavoidable upstream edits)
|
||||
|
||||
These are the upstream files we'll need to add small imports/calls into. Each edit should be minimal — ideally a single import + one-liner call to owl code, keeping the actual logic in `src/owl/`.
|
||||
|
||||
| File | Why | Change Size |
|
||||
|------|-----|-------------|
|
||||
| `src/app/state/settings.ts` | Change defaults (twitterEmoji, theme) and add new settings (youtubeEmbed) | ~5 lines |
|
||||
| `src/app/utils/sanitize.ts` | Allow external img src URLs | ~10 lines |
|
||||
| `src/app/plugins/react-custom-html-parser.tsx` | Render external images directly | ~10 lines |
|
||||
| `src/app/components/RenderMessageContent.tsx` | Import & call owl YouTubeEmbedCard | ~5 lines |
|
||||
| `src/colors.css.ts` | Add custom themes (if needed) | ~lines for theme |
|
||||
| `src/app/hooks/useTheme.ts` | Register custom themes (if needed) | ~5 lines |
|
||||
| `src/app/pages/Router.tsx` | Only if adding new routes | ~5 lines |
|
||||
|
||||
### Merge Strategy
|
||||
|
||||
- All logic lives in `src/owl/` — upstream never touches it
|
||||
- Upstream edits are kept to minimal injection points (imports + short calls)
|
||||
- On upstream merge, only the injection points can conflict — re-apply them by hand if needed
|
||||
- Consider a `src/owl/INJECTIONS.md` file listing every upstream file we touch and why, so re-applying after merge is mechanical
|
||||
|
||||
---
|
||||
|
||||
## 2. Theming - What CSS Can and Cannot Change
|
||||
|
||||
### What Themes Control
|
||||
|
||||
Themes in Cinny are **color-only**. The `createTheme()` system from vanilla-extract exposes these token categories:
|
||||
|
||||
- **Background**: Container, ContainerHover, ContainerActive, ContainerLine, OnContainer
|
||||
- **Surface**: Same pattern
|
||||
- **SurfaceVariant**: Same pattern
|
||||
- **Primary**: Main, MainHover, MainActive, MainLine, OnMain, Container variants, OnContainer
|
||||
- **Secondary**: Same as Primary
|
||||
- **Success / Warning / Critical**: Same as Primary
|
||||
- **Other**: FocusRing, Shadow, Overlay
|
||||
|
||||
### What Themes CANNOT Change
|
||||
|
||||
- **Layout/positioning** - Component layout is hardcoded in vanilla-extract style objects, not CSS variables
|
||||
- **Icon choices** - Icons are imported React components, not themeable
|
||||
- **Behavior** - Popup positioning, menu structure, click handlers are all JS
|
||||
- **Spacing/sizing** - Uses `folds` design tokens (`config.space`, `config.radii`, etc.) which are not part of the theme contract
|
||||
|
||||
### Verdict
|
||||
|
||||
**Themes alone cannot fix the reaction popup UX or change icons/menus.** They can only change colors. Layout, positioning, and behavioral changes require component modifications.
|
||||
|
||||
---
|
||||
|
||||
## 3. Reaction Popup UX
|
||||
|
||||
### Current Mechanism
|
||||
|
||||
The reaction picker is controlled by `src/app/features/room/message/Message.tsx`:
|
||||
|
||||
- A toolbar (`MessageOptionsBase`) appears on message hover, positioned `top: -30px; right: 0` (absolute) via `src/app/features/room/message/styles.css.ts`
|
||||
- Clicking the emoji button captures `getBoundingClientRect()` and opens a `PopOut` component with `position="Bottom"` and `align="End"`
|
||||
- The emoji board renders inside this PopOut popup
|
||||
- There's also a context menu with `MessageQuickReactions` showing 4 recent emojis
|
||||
|
||||
### What Would Need to Change
|
||||
|
||||
To move reactions to a more sensible position:
|
||||
|
||||
1. **styles.css.ts** - Change `MessageOptionsBase` positioning (top/right/bottom)
|
||||
2. **Message.tsx** - Change `PopOut` props (`position`, `align`) or replace PopOut with inline rendering
|
||||
3. Optionally: render the emoji board inline below the message instead of as a floating popup
|
||||
|
||||
This is a **component-level change**, not achievable through themes.
|
||||
|
||||
---
|
||||
|
||||
## 4. Twitter Emoji (Twemoji) as Default
|
||||
|
||||
### Current State
|
||||
|
||||
- Setting exists: `twitterEmoji` in `src/app/state/settings.ts` (line 26)
|
||||
- **Default is `false`** (line 60)
|
||||
- Font files exist: `public/font/Twemoji.Mozilla.v15.1.0.ttf` and `.woff2`
|
||||
- Applied via CSS custom property `--font-emoji` in `src/app/pages/client/ClientNonUIFeatures.tsx` (lines 30-40)
|
||||
|
||||
### How to Make It Default
|
||||
|
||||
**One-line change** in `src/app/state/settings.ts`:
|
||||
|
||||
```typescript
|
||||
// Line 60: change from
|
||||
twitterEmoji: false,
|
||||
// to
|
||||
twitterEmoji: true,
|
||||
```
|
||||
|
||||
New users get `defaultSettings` merged with their (empty) localStorage. Existing users who never touched the toggle will also get the new default via the merge logic in `getSettings()` (lines 86-93).
|
||||
|
||||
**Merge risk: LOW** - Single line change in a defaults object.
|
||||
|
||||
---
|
||||
|
||||
## 5. Default Theme for New Users
|
||||
|
||||
### Current Defaults
|
||||
|
||||
In `src/app/state/settings.ts` (lines 52-56):
|
||||
```typescript
|
||||
themeId: undefined, // no manual override
|
||||
useSystemTheme: true, // follow OS preference
|
||||
lightThemeId: undefined, // fallback: LightTheme
|
||||
darkThemeId: undefined, // fallback: DarkTheme
|
||||
```
|
||||
|
||||
Theme resolution in `src/app/hooks/useTheme.ts`:
|
||||
- If `useSystemTheme` is true (default): detects OS preference, picks light/dark fallback
|
||||
- If disabled: uses `themeId`, falls back to LightTheme
|
||||
|
||||
### Available Themes
|
||||
|
||||
| ID | Name |
|
||||
|----|------|
|
||||
| `light-theme` | Light (default light) |
|
||||
| `silver-theme` | Silver |
|
||||
| `dark-theme` | Dark (default dark) |
|
||||
| `butter-theme` | Butter |
|
||||
|
||||
### How to Set a Default Theme
|
||||
|
||||
**Option A - Force a specific theme:**
|
||||
```typescript
|
||||
useSystemTheme: false,
|
||||
themeId: 'butter-theme', // or any theme ID
|
||||
```
|
||||
|
||||
**Option B - Change the dark/light fallbacks (keeps system detection):**
|
||||
```typescript
|
||||
darkThemeId: 'butter-theme', // dark mode users get Butter
|
||||
lightThemeId: 'silver-theme', // light mode users get Silver
|
||||
```
|
||||
|
||||
**Merge risk: LOW** - Changes to defaults object only.
|
||||
|
||||
---
|
||||
|
||||
## 6. External IMG Tags in Messages
|
||||
|
||||
### Current Behavior
|
||||
|
||||
External image URLs are **blocked** at two levels:
|
||||
|
||||
1. **Sanitization** (`src/app/utils/sanitize.ts`, lines 108-127): `transformImgTag` converts any `<img>` with non-`mxc://` src into an `<a>` link
|
||||
2. **React parser** (`src/app/plugins/react-custom-html-parser.tsx`, lines 476-494): Non-mxc images are rendered as links, not `<img>` elements
|
||||
|
||||
This is a deliberate privacy measure for federated Matrix — loading external images reveals user IPs to image hosts.
|
||||
|
||||
### What Needs to Change
|
||||
|
||||
Since owl.cx is a single-server instance where this threat model doesn't apply:
|
||||
|
||||
1. **sanitize.ts**: Modify `transformImgTag` to allow `https://` and `http://` src URLs through as `<img>` tags instead of converting to `<a>`
|
||||
2. **react-custom-html-parser.tsx**: Modify the `img` handler to render external URLs directly with `<img src={originalUrl}>` instead of converting to links
|
||||
|
||||
### Suggested Approach
|
||||
|
||||
Add an owl setting (e.g., `allowExternalImages: true`) and conditionally bypass the mxc-only restriction. This keeps the change isolated and opt-in.
|
||||
|
||||
**Merge risk: MEDIUM** - Touching security-sensitive sanitization code. Keep changes minimal and well-isolated.
|
||||
|
||||
---
|
||||
|
||||
## 7. YouTube Link Embeds
|
||||
|
||||
### Current State
|
||||
|
||||
- **No YouTube handling exists** in the codebase
|
||||
- **`iframe` is NOT in the allowed tags** in sanitize.ts
|
||||
- URL previews exist (`UrlPreviewCard.tsx`) but only render Open Graph metadata cards (title, image, description) — no embeds
|
||||
- Settings exist: `urlPreview` and `encUrlPreview` booleans
|
||||
|
||||
### What Needs to Be Built
|
||||
|
||||
**Recommended approach**: Create a `YouTubeEmbedCard` component that slots into the existing URL preview system.
|
||||
|
||||
1. **Create** `src/owl/components/YouTubeEmbedCard.tsx`:
|
||||
- Detect YouTube URLs via regex (`youtube.com/watch?v=`, `youtu.be/`)
|
||||
- Extract video ID
|
||||
- Render `<iframe src="https://www.youtube.com/embed/{ID}" ...>`
|
||||
- Include sandbox attributes for security
|
||||
|
||||
2. **Modify** `src/app/components/RenderMessageContent.tsx`:
|
||||
- In `renderUrlsPreview`, check if URL is YouTube before rendering `UrlPreviewCard`
|
||||
- If YouTube and embed enabled, render `YouTubeEmbedCard` instead
|
||||
|
||||
3. **Add setting** in `src/app/state/settings.ts`:
|
||||
- `youtubeEmbed: boolean` (default: true for owl)
|
||||
|
||||
4. **No need to modify sanitize.ts** for this — the iframe is rendered by our component, not parsed from message HTML.
|
||||
|
||||
**Merge risk: LOW-MEDIUM** - Most code is new files. Only `RenderMessageContent.tsx` and `settings.ts` need upstream modifications.
|
||||
|
||||
---
|
||||
|
||||
## Priority Recommendations
|
||||
|
||||
| Task | Effort | Risk | Recommendation |
|
||||
|------|--------|------|---------------|
|
||||
| Twemoji default | 1 line | Low | Do immediately |
|
||||
| Default theme | 2-3 lines | Low | Do immediately |
|
||||
| External images | ~30 lines | Medium | Do soon, add owl setting |
|
||||
| YouTube embeds | New component + ~20 lines changes | Low-Medium | Build as isolated component |
|
||||
| Reaction UX | Component restructure | Medium | Plan carefully, touches upstream |
|
||||
|
||||
The first two are trivial defaults changes. External images and YouTube embeds can be built mostly in isolation. The reaction UX rework is the most invasive change and should be planned carefully to minimize merge conflict surface.
|
||||
176
owl/REPORT-002-external-images.md
Normal file
176
owl/REPORT-002-external-images.md
Normal file
@@ -0,0 +1,176 @@
|
||||
# OWL Report #002 - External Images: Settings & Scoping
|
||||
|
||||
Date: 2026-04-15
|
||||
|
||||
## The Question
|
||||
|
||||
We've already removed the external image block (sanitize.ts + react-custom-html-parser.tsx). But should this be unconditional? Options:
|
||||
|
||||
1. Global toggle (user setting)
|
||||
2. Per-room setting
|
||||
3. Automatic based on federation status
|
||||
4. Homeserver-level default via config.json
|
||||
|
||||
## What Context Is Available at Render Time
|
||||
|
||||
The key rendering call chain is:
|
||||
|
||||
```
|
||||
RoomTimeline.tsx (has: room object, mx client, settings)
|
||||
→ getReactCustomHtmlParser(mx, roomId, params)
|
||||
→ HTMLReactParserOptions (handles img tags)
|
||||
→ RenderMessageContent (receives pre-built parser options)
|
||||
```
|
||||
|
||||
At the `RoomTimeline` level (line 528 of `src/app/features/room/RoomTimeline.tsx`), we have:
|
||||
- Full `room` object (Room from matrix-js-sdk)
|
||||
- `mx` (MatrixClient) — knows the homeserver domain
|
||||
- All user settings via Jotai atoms
|
||||
|
||||
### Federation Detection
|
||||
|
||||
Rooms carry an `m.federate` flag in their `m.room.create` state event:
|
||||
```typescript
|
||||
const createEvent = getStateEvent(room, StateEvent.RoomCreate);
|
||||
const isFederated = createEvent?.getContent()?.['m.federate'] !== false;
|
||||
```
|
||||
Default is `true` (federated). Local-only rooms explicitly set `m.federate: false`.
|
||||
|
||||
### Homeserver Detection
|
||||
|
||||
We can tell if a message sender is local:
|
||||
```typescript
|
||||
const senderDomain = event.getSender()?.split(':')[1];
|
||||
const isLocal = senderDomain === mx.getDomain();
|
||||
```
|
||||
|
||||
## Options Analysis
|
||||
|
||||
### Option A: Global User Setting
|
||||
|
||||
Add `allowExternalImages: boolean` to settings, default `false` (or `true` via config.json for owl).
|
||||
|
||||
**Pros:** Simple, one toggle, works everywhere.
|
||||
**Cons:** All-or-nothing. A privacy-conscious user can't allow it for trusted rooms only.
|
||||
|
||||
### Option B: Per-Room Setting (Room State Event)
|
||||
|
||||
Store a custom state event like `cx.owl.room.settings` with `{ allowExternalImages: true }` per room. Room admins control it.
|
||||
|
||||
**Pros:** Fine-grained, admin-controlled.
|
||||
**Cons:** Requires room admin action. UX overhead. Need UI for room settings. Only works in rooms we control.
|
||||
|
||||
### Option C: Automatic by Federation Status
|
||||
|
||||
If `m.federate === false` (local-only room) → allow external images. If federated → block.
|
||||
|
||||
**Pros:** Zero configuration, matches the threat model (federated = untrusted external servers can leak IPs via images).
|
||||
**Cons:** Most rooms default to `m.federate: true` even on a single homeserver. Users would need to explicitly create non-federated rooms. Doesn't match the real intent — on owl.cx, all rooms are effectively local even if technically federated.
|
||||
|
||||
### Option D: Homeserver-Level Default via config.json
|
||||
|
||||
Add to config.json:
|
||||
```json
|
||||
{
|
||||
"defaultSettings": {
|
||||
"allowExternalImages": "homeserver"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Where the value is one of: `"always"`, `"never"`, `"homeserver"` (only in rooms on this homeserver), `"local"` (only non-federated rooms).
|
||||
|
||||
**Pros:** Server operator controls the policy. Matches the owl use case perfectly — "we trust our own server."
|
||||
**Cons:** More logic to implement. Need to define what "homeserver room" means (all members local? room alias local? room ID local?).
|
||||
|
||||
### Option E: Layered Approach (Recommended)
|
||||
|
||||
Combine a global setting with smart defaults:
|
||||
|
||||
1. **Global setting** `externalImages`: `"always"` | `"never"` | `"homeserver"`
|
||||
- Default: `"never"` (safe for general Cinny users)
|
||||
- owl config.json sets: `"homeserver"` or `"always"`
|
||||
2. **"homeserver" mode**: allow external images when the room's server matches the user's homeserver (check room ID domain: `!roomid:owl.cx`)
|
||||
3. **Per-room override** (future): room admins can set `cx.owl.room.settings` state event to override
|
||||
|
||||
This gives us:
|
||||
- Safe default for upstream/general use
|
||||
- owl.cx sets `"homeserver"` via config.json — external images work in all owl rooms
|
||||
- Users can override to `"always"` or `"never"` in settings
|
||||
- Room-level control can be added later without changing the architecture
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
### Settings Layer
|
||||
|
||||
**`src/app/state/settings.ts`:**
|
||||
```typescript
|
||||
// Add to Settings interface:
|
||||
externalImages: 'always' | 'never' | 'homeserver';
|
||||
|
||||
// Add to defaultSettings:
|
||||
externalImages: 'never',
|
||||
```
|
||||
|
||||
**`config.json` (owl deployment):**
|
||||
```json
|
||||
{
|
||||
"defaultSettings": {
|
||||
"externalImages": "homeserver"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Rendering Layer
|
||||
|
||||
**`src/app/plugins/react-custom-html-parser.tsx`:**
|
||||
Add `allowExternalImages?: boolean` to the params type. When false, revert to the original behavior (convert external img to `<a>` link).
|
||||
|
||||
**`src/app/features/room/RoomTimeline.tsx`:**
|
||||
Read the `externalImages` setting, check room context, compute the boolean `allowExternalImages`, pass it into `getReactCustomHtmlParser` params.
|
||||
|
||||
```typescript
|
||||
const [externalImages] = useSetting(settingsAtom, 'externalImages');
|
||||
const allowExternalImages = useMemo(() => {
|
||||
if (externalImages === 'always') return true;
|
||||
if (externalImages === 'never') return false;
|
||||
// 'homeserver': check if room belongs to our homeserver
|
||||
const roomDomain = room.roomId.split(':')[1];
|
||||
return roomDomain === mx.getDomain();
|
||||
}, [externalImages, room.roomId, mx]);
|
||||
```
|
||||
|
||||
**`src/app/utils/sanitize.ts`:**
|
||||
`sanitizeCustomHtml` needs the flag too, since it runs before the React parser. Either:
|
||||
- Pass it as a parameter: `sanitizeCustomHtml(html, { allowExternalImages })`
|
||||
- Or move all image logic to the React parser (simpler — sanitizer just passes img tags through, parser decides what to render)
|
||||
|
||||
The second approach is cleaner: the sanitizer allows img tags with any src (already done), and the React parser decides whether to render or convert to link based on the flag.
|
||||
|
||||
### Settings UI
|
||||
|
||||
Add a dropdown in `src/app/features/settings/general/General.tsx` under the "Media" or "Privacy" section:
|
||||
|
||||
```
|
||||
External Images: [Always / Homeserver Only / Never]
|
||||
```
|
||||
|
||||
### Files to Touch
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/app/state/settings.ts` | Add `externalImages` to Settings + defaults |
|
||||
| `src/app/plugins/react-custom-html-parser.tsx` | Accept + check `allowExternalImages` param |
|
||||
| `src/app/features/room/RoomTimeline.tsx` | Compute flag from setting + room context, pass to parser |
|
||||
| `src/app/features/settings/general/General.tsx` | Add UI dropdown |
|
||||
| `src/app/utils/sanitize.ts` | Already done — img tags pass through |
|
||||
|
||||
### What About the Sanitizer?
|
||||
|
||||
Current state: we already removed the img→link conversion in `sanitize.ts`. For the settings-based approach, we have two options:
|
||||
|
||||
**Option 1 (simpler):** Leave sanitize.ts as-is (allows all img src through). The React parser handles the allow/block decision. This means the sanitized HTML contains `<img src="https://...">` but the React parser may convert it to a link at render time.
|
||||
|
||||
**Option 2 (stricter):** Restore the original sanitize.ts behavior and only bypass it when `allowExternalImages` is true. This requires passing options to `sanitizeCustomHtml`, which changes its signature and every call site.
|
||||
|
||||
**Recommendation:** Option 1. The sanitizer's job is preventing XSS, not policy decisions. Let the React parser handle the rendering policy — it already has all the context it needs.
|
||||
337
owl/REPORT-003-external-videos.md
Normal file
337
owl/REPORT-003-external-videos.md
Normal file
@@ -0,0 +1,337 @@
|
||||
# OWL Report #003 - External Video Embeds (YouTube + Direct Video URLs)
|
||||
|
||||
Date: 2026-04-17
|
||||
|
||||
## The Goal
|
||||
|
||||
Two README items merge naturally into one feature:
|
||||
|
||||
- **YouTube links** should create embedded players (click-to-play).
|
||||
- **9gag-style direct video URLs** (e.g. `https://img-9gag-fun.9cache.com/photo/aYQnPXN_460svav1.mp4`) should be playable inline.
|
||||
|
||||
Both are "external video in the timeline". They share the same wiring points (URL detection → card renderer in `RenderMessageContent.tsx`) and the same policy model (`'always' | 'homeserver' | 'never'`, mirroring the external-images setting). Different rendering tech: YouTube needs an iframe, direct videos use the `<video>` tag — but that's an internal detail of the renderer.
|
||||
|
||||
---
|
||||
|
||||
## Existing Plumbing We Will Reuse
|
||||
|
||||
The external-images work (Report #002, now shipped) gave us the exact pattern to follow.
|
||||
|
||||
| Piece | File | Role |
|
||||
|-------|------|------|
|
||||
| URL extraction | `src/app/utils/regex.ts` → `URL_REG` / `HTTP_URL_PATTERN` | Already pulls every http(s) URL out of message text |
|
||||
| URL classifier | `src/owl/utils/imageUrl.ts` → `isImageUrl()` | Pattern we will mirror for `isVideoUrl`/`isYouTubeUrl` |
|
||||
| Render dispatch | `src/app/components/RenderMessageContent.tsx:63-84` → `renderUrlsPreview` | The single place we branch per URL kind |
|
||||
| Card component | `src/owl/components/ExternalImageCard.tsx` | Exact shape to mirror |
|
||||
| Policy setting | `src/app/state/settings.ts:44` → `externalImages: ExternalImageMode` | Copy for `externalVideos` |
|
||||
| Policy hook | `src/owl/hooks/useAllowExternalImages.ts` | Copy for `useAllowExternalVideos` |
|
||||
| Settings UI | `src/app/features/settings/general/General.tsx:882-954` (`SelectExternalImages`) + mount at line 1043-1048 | Copy for `SelectExternalVideos` |
|
||||
| Matrix `<video>` element | `src/app/components/media/Video.tsx` | Already exists — reusable for direct video rendering |
|
||||
|
||||
The key insight: `renderUrlsPreview` in `RenderMessageContent.tsx` is already where all URL-derived embeds dispatch. Today it routes images to `ExternalImageCard` and everything else to `UrlPreviewCard`. Adding video is one more branch in the same `filter()` chain. **No changes to `sanitize.ts` or the HTML parser are needed** — we are rendering from the URL list, not from user HTML.
|
||||
|
||||
---
|
||||
|
||||
## Part A — YouTube Embeds
|
||||
|
||||
### Detection
|
||||
|
||||
YouTube URL variants we want to catch:
|
||||
|
||||
```
|
||||
https://www.youtube.com/watch?v=VIDEOID
|
||||
https://youtube.com/watch?v=VIDEOID&t=42s
|
||||
https://youtu.be/VIDEOID
|
||||
https://youtu.be/VIDEOID?t=42
|
||||
https://www.youtube.com/shorts/VIDEOID
|
||||
https://www.youtube.com/embed/VIDEOID
|
||||
https://m.youtube.com/watch?v=VIDEOID
|
||||
```
|
||||
|
||||
Parse via `URL` rather than a mega-regex. That way a typo in the query string won't break detection:
|
||||
|
||||
```ts
|
||||
// src/owl/utils/videoUrl.ts
|
||||
export function getYouTubeId(url: string): string | null {
|
||||
try {
|
||||
const u = new URL(url);
|
||||
const host = u.hostname.replace(/^www\.|^m\./, '');
|
||||
if (host === 'youtu.be') return u.pathname.slice(1).split('/')[0] || null;
|
||||
if (host === 'youtube.com') {
|
||||
if (u.pathname === '/watch') return u.searchParams.get('v');
|
||||
const m = u.pathname.match(/^\/(shorts|embed|v)\/([^/]+)/);
|
||||
if (m) return m[2];
|
||||
}
|
||||
return null;
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
export function getYouTubeStart(url: string): number | null {
|
||||
try {
|
||||
const t = new URL(url).searchParams.get('t') ?? new URL(url).searchParams.get('start');
|
||||
if (!t) return null;
|
||||
// handle "42", "42s", "1m30s"
|
||||
const m = t.match(/(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?/);
|
||||
if (!m) return null;
|
||||
return (+(m[1] || 0)) * 3600 + (+(m[2] || 0)) * 60 + (+(m[3] || 0));
|
||||
} catch { return null; }
|
||||
}
|
||||
```
|
||||
|
||||
### Rendering Strategy: "Facade" (Click-to-Load)
|
||||
|
||||
Don't render the iframe eagerly. Two reasons:
|
||||
|
||||
1. **Privacy**: YouTube's iframe (even on `youtube-nocookie.com`) phones home as soon as it mounts. Loading a full iframe for every YouTube link in a room scrollback is a tracking and performance problem.
|
||||
2. **Performance**: A YouTube iframe is ~500KB of JS per instance. Ten YouTube links in a channel would pin the tab.
|
||||
|
||||
Instead: show a clickable thumbnail from `https://i.ytimg.com/vi/<ID>/hqdefault.jpg` with a play-button overlay. On click, swap to the iframe. This is the standard approach (used by Reddit, Discord, Mastodon front-ends).
|
||||
|
||||
```
|
||||
┌───────────────────────────────────┐
|
||||
│ [ YouTube thumbnail image ] │
|
||||
│ ▶ (big play button) │
|
||||
│ │
|
||||
│ youtube.com/watch?v=dQw4w9WgXcQ │
|
||||
└───────────────────────────────────┘
|
||||
↓ click
|
||||
┌───────────────────────────────────┐
|
||||
│ [ <iframe> YouTube player ] │
|
||||
└───────────────────────────────────┘
|
||||
```
|
||||
|
||||
### iframe Attributes
|
||||
|
||||
When the user clicks to load:
|
||||
|
||||
```tsx
|
||||
<iframe
|
||||
src={`https://www.youtube-nocookie.com/embed/${id}?autoplay=1${start ? `&start=${start}` : ''}`}
|
||||
title={`YouTube: ${id}`}
|
||||
loading="lazy"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen"
|
||||
allowFullScreen
|
||||
referrerPolicy="strict-origin-when-cross-origin"
|
||||
// no sandbox attr — the full YouTube embed API needs scripts+same-origin, and
|
||||
// youtube-nocookie is already an isolated origin. Sandbox breaks fullscreen.
|
||||
/>
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- **`youtube-nocookie.com`** is the reduced-tracking variant and should be the default.
|
||||
- **Don't sandbox**. The YouTube player relies on `postMessage` and same-origin window access for its controls; sandboxing breaks fullscreen and picture-in-picture. The iframe is already origin-isolated.
|
||||
- **CSP**: Cinny's `vite.config.ts` / `public/config.json` don't set CSP headers — the deployment host does. owl.cx must allow `frame-src https://www.youtube-nocookie.com https://www.youtube.com` (and the `i.ytimg.com` image host). Flag this for deployment.
|
||||
|
||||
### Component sketch
|
||||
|
||||
```tsx
|
||||
// src/owl/components/YouTubeEmbedCard.tsx
|
||||
export const YouTubeEmbedCard = as<'div', { url: string }>(({ url, ...p }, ref) => {
|
||||
const id = getYouTubeId(url);
|
||||
const start = getYouTubeStart(url);
|
||||
const [playing, setPlaying] = useState(false);
|
||||
if (!id) return null;
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100" {...p} ref={ref}>
|
||||
<div className={css.YouTubeFrame}>
|
||||
{playing ? (
|
||||
<iframe {...see above with id + start} />
|
||||
) : (
|
||||
<button onClick={() => setPlaying(true)}>
|
||||
<img src={`https://i.ytimg.com/vi/${id}/hqdefault.jpg`} loading="lazy" />
|
||||
<PlayOverlay />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<Text as="a" href={url} target="_blank" rel="noreferrer">{url}</Text>
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
Aspect ratio: 16:9 (`aspect-ratio: 16 / 9` in CSS) with a sensible `max-width` (e.g. 480px) so it doesn't dominate the timeline.
|
||||
|
||||
---
|
||||
|
||||
## Part B — Direct Video URLs (9gag, etc.)
|
||||
|
||||
### Detection
|
||||
|
||||
Mirror `isImageUrl` exactly:
|
||||
|
||||
```ts
|
||||
// src/owl/utils/videoUrl.ts
|
||||
const VIDEO_EXTENSIONS = ['.mp4', '.webm', '.ogg', '.ogv', '.mov', '.m4v'];
|
||||
|
||||
export function isVideoUrl(url: string): boolean {
|
||||
try {
|
||||
const { pathname } = new URL(url);
|
||||
return VIDEO_EXTENSIONS.some((ext) => pathname.toLowerCase().endsWith(ext));
|
||||
} catch { return false; }
|
||||
}
|
||||
```
|
||||
|
||||
**About 9gag specifically**: their `.webp` links served under `/photo/` are actually animated images (not video). The `.mp4` variant (`aYQnPXN_460svav1.mp4`) is a true MP4 and needs `<video>`. The path-segment `photo` is misleading — extension is what matters. Our image-extension list already handles `.webp`, so animated WebP 9gag links will flow through `ExternalImageCard` today (the `<img>` tag will animate them natively). MP4 variants will flow through the new video card. No special 9gag detection needed.
|
||||
|
||||
### Rendering
|
||||
|
||||
No facade needed — `<video>` with `preload="metadata"` only downloads the first few KB (metadata + poster frame). Users click play to stream.
|
||||
|
||||
```tsx
|
||||
// src/owl/components/ExternalVideoCard.tsx
|
||||
export const ExternalVideoCard = as<'div', { url: string }>(({ url, ...p }, ref) => {
|
||||
const [error, setError] = useState(false);
|
||||
if (error) return null;
|
||||
return (
|
||||
<Box direction="Column" gap="100" {...p} ref={ref}>
|
||||
<video
|
||||
className={css.ExternalVideo}
|
||||
src={url}
|
||||
controls
|
||||
preload="metadata"
|
||||
playsInline
|
||||
onError={() => setError(true)}
|
||||
/>
|
||||
<Text as="a" href={url} target="_blank" rel="noreferrer">{url}</Text>
|
||||
</Box>
|
||||
);
|
||||
});
|
||||
```
|
||||
|
||||
We can reuse the existing `<Video>` wrapper from `src/app/components/media/Video.tsx` if we want shared styling, but a new card mirroring `ExternalImageCard` is simpler and keeps all owl code in `src/owl/`.
|
||||
|
||||
### Gotchas
|
||||
|
||||
- **CORS / Hotlinking**: Some hosts (including Cloudflare sites) block hotlinked video with `Referer` checks. 9cache.com currently allows it — easy to verify empirically. If a host blocks us, `<video onError>` falls back (card hides itself). No leaking user IP because the threat model for owl is single-server — same as external images.
|
||||
- **Autoplay**: Do **not** autoplay. Browsers require `muted` for autoplay and it's user-hostile. `preload="metadata"` gives a poster frame without streaming the whole file.
|
||||
- **Mobile data**: `preload="metadata"` is the right default; don't change it to `auto`.
|
||||
|
||||
---
|
||||
|
||||
## Part C — Unified Wiring
|
||||
|
||||
### Setting
|
||||
|
||||
```ts
|
||||
// src/app/state/settings.ts
|
||||
export type ExternalVideoMode = 'always' | 'homeserver' | 'never';
|
||||
|
||||
// add to Settings interface:
|
||||
externalVideos: ExternalVideoMode;
|
||||
|
||||
// add to defaultSettings:
|
||||
externalVideos: 'never', // upstream-safe default
|
||||
```
|
||||
|
||||
owl.cx `config.json` overrides to `'homeserver'` (or `'always'`) via the same `defaultSettings` mechanism that external-images already uses.
|
||||
|
||||
Open question: **single setting or two?** My recommendation is **one setting `externalVideos` covering both YouTube and direct video**, because:
|
||||
|
||||
- They have the same privacy/trust model from the user's point of view ("do I trust external video hosts?").
|
||||
- Two toggles create decision fatigue for a feature that's largely "on or off".
|
||||
- If we later want finer control, splitting later is easier than merging later.
|
||||
|
||||
If we ever need YouTube-specific controls (e.g. "block YouTube but allow direct video" for a super-privacy-conscious user), we can add it then. Don't design for the hypothetical.
|
||||
|
||||
### Hook
|
||||
|
||||
```ts
|
||||
// src/owl/hooks/useAllowExternalVideos.ts (one-to-one copy of useAllowExternalImages)
|
||||
export function useAllowExternalVideos(mx: MatrixClient, room: Room): boolean {
|
||||
const [externalVideos] = useSetting(settingsAtom, 'externalVideos');
|
||||
return useMemo(() => {
|
||||
if (externalVideos === 'always') return true;
|
||||
if (externalVideos === 'never') return false;
|
||||
return room.roomId.split(':')[1] === mx.getDomain();
|
||||
}, [externalVideos, room.roomId, mx]);
|
||||
}
|
||||
```
|
||||
|
||||
### Dispatch in `RenderMessageContent.tsx`
|
||||
|
||||
The current branch (lines 63-84):
|
||||
|
||||
```ts
|
||||
const imageUrls = filteredUrls.filter(isImageUrl);
|
||||
const otherUrls = filteredUrls.filter((url) => !isImageUrl(url));
|
||||
```
|
||||
|
||||
Becomes:
|
||||
|
||||
```ts
|
||||
const imageUrls = filteredUrls.filter(isImageUrl);
|
||||
const youtubeUrls = filteredUrls.filter((u) => !isImageUrl(u) && getYouTubeId(u));
|
||||
const videoUrls = filteredUrls.filter((u) => !isImageUrl(u) && !getYouTubeId(u) && isVideoUrl(u));
|
||||
const otherUrls = filteredUrls.filter(
|
||||
(u) => !isImageUrl(u) && !getYouTubeId(u) && !isVideoUrl(u)
|
||||
);
|
||||
```
|
||||
|
||||
And render each list with its card. **Gating**: `RenderMessageContent` doesn't currently take `allowExternalVideos` as a prop — we'd either add one (mirroring the eventual external-images gating if/when it lands here), or gate inside the new card component by reading the hook. Reading inside the card is simpler but requires the card to know its room context. Passing a prop down from `RoomTimeline` is cleaner and matches how `urlPreview` already flows. **Recommendation: prop.**
|
||||
|
||||
The prop flow would be:
|
||||
|
||||
- `RoomTimeline.tsx:451` — already calls `useAllowExternalImages(mx, room)`. Add a sibling `useAllowExternalVideos(mx, room)`.
|
||||
- `RoomTimeline.tsx` — pass `allowExternalVideos` into `RenderMessageContent` (need to find where `RenderMessageContent` is rendered in the timeline and thread it through; currently `allowExternalImages` goes into `getReactCustomHtmlParser` at line 533, not into `RenderMessageContent`, because images are gated inside HTML parsing. Video gating is different — it gates URL-derived embeds, not parsed HTML — so we pass directly to `RenderMessageContent`).
|
||||
|
||||
### Settings UI
|
||||
|
||||
In `General.tsx`, copy `SelectExternalImages` (lines 882-954) to `SelectExternalVideos`, and add a `SettingTile` row mirroring lines 1043-1048:
|
||||
|
||||
```tsx
|
||||
<SequenceCard ...>
|
||||
<SettingTile title="External Videos" after={<SelectExternalVideos />} />
|
||||
</SequenceCard>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Files Touched
|
||||
|
||||
| File | Kind | Change size |
|
||||
|------|------|-------------|
|
||||
| `src/owl/utils/videoUrl.ts` | NEW | `isVideoUrl`, `getYouTubeId`, `getYouTubeStart` |
|
||||
| `src/owl/components/YouTubeEmbedCard.tsx` | NEW | Facade + iframe |
|
||||
| `src/owl/components/YouTubeEmbedCard.css.ts` | NEW | Aspect-ratio, thumbnail, play button |
|
||||
| `src/owl/components/ExternalVideoCard.tsx` | NEW | `<video>` card |
|
||||
| `src/owl/components/ExternalVideoCard.css.ts` | NEW | Sizing |
|
||||
| `src/owl/hooks/useAllowExternalVideos.ts` | NEW | Mirror of images hook |
|
||||
| `src/app/state/settings.ts` | edit | +2 lines (type + default) |
|
||||
| `src/app/components/RenderMessageContent.tsx` | edit | ~10 lines: import cards, filter branches, render |
|
||||
| `src/app/features/room/RoomTimeline.tsx` | edit | ~2 lines: add hook call, pass prop |
|
||||
| `src/app/features/settings/general/General.tsx` | edit | ~80 lines: copy `SelectExternalImages` → `SelectExternalVideos`, add tile row |
|
||||
|
||||
Upstream surface area: the three `src/app/...` edits. All feature logic (detection, rendering, policy hook, both cards, both CSS files) lives in `src/owl/`.
|
||||
|
||||
**Merge risk: LOW.** Pure additive change. No sanitizer or HTML-parser changes. If upstream touches `renderUrlsPreview` in `RenderMessageContent.tsx`, the branch addition is mechanical to re-apply.
|
||||
|
||||
---
|
||||
|
||||
## Security Summary
|
||||
|
||||
| Concern | Mitigation |
|
||||
|---------|------------|
|
||||
| YouTube tracking | `youtube-nocookie.com`, facade (no iframe until user click), `referrerPolicy="strict-origin-when-cross-origin"` |
|
||||
| iframe XSS | YouTube iframe is on a separate origin — no DOM access to our app. No sandbox needed (and it breaks fullscreen). |
|
||||
| Video host IP leak | Same as external images: single-server threat model, already accepted by owl. Setting defaults to `'never'` for upstream. |
|
||||
| Video MIME spoofing | Browser validates MIME before playback; `<video>` rejects non-video payloads. `onError` hides the card. |
|
||||
| CSP | Deployment-side: owl.cx host config must permit `frame-src youtube-nocookie.com`, `img-src i.ytimg.com`, `media-src *` (or allowlist). Flag for deploy. |
|
||||
| Malicious autoplay | We never autoplay until user clicks. |
|
||||
|
||||
---
|
||||
|
||||
## Recommendation & Priority
|
||||
|
||||
**Build this as one PR**, in this order:
|
||||
|
||||
1. `src/owl/utils/videoUrl.ts` + unit-style smoke test (throwaway URLs in dev console is fine — this is a client app, no test infra being set up for this).
|
||||
2. `ExternalVideoCard` (easier, mostly static markup).
|
||||
3. `YouTubeEmbedCard` with facade.
|
||||
4. Settings wiring + UI row.
|
||||
5. Manual test on owl.cx dev with: YouTube watch link, `youtu.be` short link, link with `?t=` timestamp, `youtube.com/shorts/`, a 9gag mp4, an arbitrary `.webm`, and a broken URL.
|
||||
|
||||
Overall risk: LOW. The pattern is copy-paste from external images, the only genuinely new code is the YouTube facade and the setting row.
|
||||
|
||||
One thing to explicitly decide with the user before implementing: **single `externalVideos` setting vs. split `youtubeEmbed` + `directVideoEmbed`**. My recommendation is single; flagging it so we don't bikeshed after the PR is up.
|
||||
7173
package-lock.json
generated
7173
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cinny",
|
||||
"version": "4.10.3",
|
||||
"version": "4.11.1",
|
||||
"description": "Yet another matrix client",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
@@ -10,11 +10,53 @@
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "yarn check:eslint && yarn check:prettier",
|
||||
"preview": "vite preview",
|
||||
"lint": "npm run check:eslint && npm run check:prettier",
|
||||
"check:eslint": "eslint src/*",
|
||||
"check:prettier": "prettier --check .",
|
||||
"fix:prettier": "prettier --write .",
|
||||
"typecheck": "tsc --noEmit"
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prepare": "husky install",
|
||||
"commit": "git-cz",
|
||||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,jsx}": "eslint",
|
||||
"*": "prettier --ignore-unknown --write"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"release": {
|
||||
"branches": [
|
||||
"dev"
|
||||
],
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
"prepareCmd": "node scripts/update-version.js ${nextRelease.version}"
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": [
|
||||
"package.json",
|
||||
"package-lock.json",
|
||||
"src/app/features/settings/about/About.tsx",
|
||||
"src/app/pages/auth/AuthFooter.tsx",
|
||||
"src/app/pages/client/WelcomePage.tsx"
|
||||
],
|
||||
"message": "chore(release): ${nextRelease.version} [skip ci]"
|
||||
}
|
||||
],
|
||||
"@semantic-release/github"
|
||||
]
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Ajay Bura",
|
||||
@@ -43,7 +85,7 @@
|
||||
"emojibase-data": "15.3.2",
|
||||
"file-saver": "2.0.5",
|
||||
"focus-trap-react": "10.0.2",
|
||||
"folds": "2.5.0",
|
||||
"folds": "2.6.2",
|
||||
"html-dom-parser": "4.0.0",
|
||||
"html-react-parser": "4.2.0",
|
||||
"i18next": "23.12.2",
|
||||
@@ -52,9 +94,10 @@
|
||||
"immer": "9.0.16",
|
||||
"is-hotkey": "0.2.0",
|
||||
"jotai": "2.6.0",
|
||||
"linkify-react": "4.1.3",
|
||||
"linkifyjs": "4.1.3",
|
||||
"linkify-react": "4.3.2",
|
||||
"linkifyjs": "4.3.2",
|
||||
"matrix-js-sdk": "38.2.0",
|
||||
"matrix-widget-api": "1.13.0",
|
||||
"millify": "6.1.0",
|
||||
"pdfjs-dist": "4.2.67",
|
||||
"prismjs": "1.30.0",
|
||||
@@ -69,16 +112,19 @@
|
||||
"react-range": "1.8.14",
|
||||
"react-router-dom": "6.30.3",
|
||||
"sanitize-html": "2.12.1",
|
||||
"slate": "0.112.0",
|
||||
"slate-dom": "0.112.2",
|
||||
"slate-history": "0.110.3",
|
||||
"slate-react": "0.112.1",
|
||||
"slate": "0.123.0",
|
||||
"slate-dom": "0.123.0",
|
||||
"slate-history": "0.113.1",
|
||||
"slate-react": "0.123.0",
|
||||
"ua-parser-js": "1.0.35"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@element-hq/element-call-embedded": "0.16.3",
|
||||
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
|
||||
"@rollup/plugin-inject": "5.0.3",
|
||||
"@rollup/plugin-wasm": "6.1.1",
|
||||
"@semantic-release/exec": "7.1.0",
|
||||
"@semantic-release/git": "10.0.1",
|
||||
"@types/chroma-js": "3.1.1",
|
||||
"@types/file-saver": "2.0.5",
|
||||
"@types/is-hotkey": "0.1.10",
|
||||
@@ -93,6 +139,7 @@
|
||||
"@typescript-eslint/parser": "5.46.1",
|
||||
"@vitejs/plugin-react": "4.2.0",
|
||||
"buffer": "6.0.3",
|
||||
"cz-conventional-changelog": "3.3.0",
|
||||
"eslint": "8.29.0",
|
||||
"eslint-config-airbnb": "19.0.4",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
@@ -100,7 +147,10 @@
|
||||
"eslint-plugin-jsx-a11y": "6.6.1",
|
||||
"eslint-plugin-react": "7.31.11",
|
||||
"eslint-plugin-react-hooks": "4.6.0",
|
||||
"husky": "9.1.7",
|
||||
"lint-staged": "16.3.2",
|
||||
"prettier": "2.8.1",
|
||||
"semantic-release": "25.0.3",
|
||||
"typescript": "4.9.4",
|
||||
"vite": "5.4.19",
|
||||
"vite-plugin-pwa": "0.20.5",
|
||||
|
||||
48
scripts/update-version.js
Normal file
48
scripts/update-version.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { execSync } from "child_process";
|
||||
import { fileURLToPath } from "url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const version = process.argv[2];
|
||||
|
||||
if (!version) {
|
||||
console.error("Version argument missing");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const root = path.resolve(__dirname, "..");
|
||||
const newVersionTag = `v${version}`;
|
||||
|
||||
// Update package.json + package-lock.json safely
|
||||
execSync(`npm version ${version} --no-git-tag-version`, {
|
||||
cwd: root,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
console.log(`Updated package.json and package-lock.json → ${version}`);
|
||||
|
||||
// Update UI version references
|
||||
const files = [
|
||||
"src/app/features/settings/about/About.tsx",
|
||||
"src/app/pages/auth/AuthFooter.tsx",
|
||||
"src/app/pages/client/WelcomePage.tsx",
|
||||
];
|
||||
|
||||
files.forEach((filePath) => {
|
||||
const absPath = path.join(root, filePath);
|
||||
|
||||
if (!fs.existsSync(absPath)) {
|
||||
console.warn(`File not found: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(absPath, "utf8");
|
||||
const updated = content.replace(/v\d+\.\d+\.\d+/g, newVersionTag);
|
||||
|
||||
fs.writeFileSync(absPath, updated);
|
||||
|
||||
console.log(`Updated ${filePath} → ${newVersionTag}`);
|
||||
});
|
||||
66
src/app/components/CallEmbedProvider.tsx
Normal file
66
src/app/components/CallEmbedProvider.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import React, { ReactNode, useCallback, useRef } from 'react';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import { config } from 'folds';
|
||||
import {
|
||||
CallEmbedContextProvider,
|
||||
CallEmbedRefContextProvider,
|
||||
useCallHangupEvent,
|
||||
useCallJoined,
|
||||
useCallThemeSync,
|
||||
useCallMemberSoundSync,
|
||||
} from '../hooks/useCallEmbed';
|
||||
import { callChatAtom, callEmbedAtom } from '../state/callEmbed';
|
||||
import { CallEmbed } from '../plugins/call';
|
||||
import { useSelectedRoom } from '../hooks/router/useSelectedRoom';
|
||||
import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
|
||||
|
||||
function CallUtils({ embed }: { embed: CallEmbed }) {
|
||||
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||
|
||||
useCallMemberSoundSync(embed);
|
||||
useCallThemeSync(embed);
|
||||
useCallHangupEvent(
|
||||
embed,
|
||||
useCallback(() => {
|
||||
setCallEmbed(undefined);
|
||||
}, [setCallEmbed])
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
type CallEmbedProviderProps = {
|
||||
children?: ReactNode;
|
||||
};
|
||||
export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
||||
const callEmbed = useAtomValue(callEmbedAtom);
|
||||
const callEmbedRef = useRef<HTMLDivElement>(null);
|
||||
const joined = useCallJoined(callEmbed);
|
||||
|
||||
const selectedRoom = useSelectedRoom();
|
||||
const chat = useAtomValue(callChatAtom);
|
||||
const screenSize = useScreenSizeContext();
|
||||
|
||||
const chatOnlyView = chat && screenSize !== ScreenSize.Desktop;
|
||||
|
||||
const callVisible = callEmbed && selectedRoom === callEmbed.roomId && joined && !chatOnlyView;
|
||||
|
||||
return (
|
||||
<CallEmbedContextProvider value={callEmbed}>
|
||||
{callEmbed && <CallUtils embed={callEmbed} />}
|
||||
<CallEmbedRefContextProvider value={callEmbedRef}>{children}</CallEmbedRefContextProvider>
|
||||
<div
|
||||
data-call-embed-container
|
||||
style={{
|
||||
visibility: callVisible ? undefined : 'hidden',
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100%',
|
||||
height: '50%',
|
||||
}}
|
||||
ref={callEmbedRef}
|
||||
/>
|
||||
</CallEmbedContextProvider>
|
||||
);
|
||||
}
|
||||
45
src/app/components/ImageOverlay.tsx
Normal file
45
src/app/components/ImageOverlay.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { as, Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import React, { ReactNode } from 'react';
|
||||
import { ModalWide } from '../styles/Modal.css';
|
||||
import { stopPropagation } from '../utils/keyboard';
|
||||
|
||||
export type RenderViewerProps = {
|
||||
src: string;
|
||||
alt: string;
|
||||
requestClose: () => void;
|
||||
};
|
||||
|
||||
type ImageOverlayProps = RenderViewerProps & {
|
||||
viewer: boolean;
|
||||
renderViewer: (props: RenderViewerProps) => ReactNode;
|
||||
};
|
||||
|
||||
export const ImageOverlay = as<'div', ImageOverlayProps>(
|
||||
({ src, alt, viewer, requestClose, renderViewer, ...props }, ref) => (
|
||||
<Overlay {...props} ref={ref} open={viewer} backdrop={<OverlayBackdrop />}>
|
||||
<OverlayCenter>
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => requestClose(),
|
||||
clickOutsideDeactivates: true,
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Modal
|
||||
className={ModalWide}
|
||||
size="500"
|
||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
||||
>
|
||||
{renderViewer({
|
||||
src,
|
||||
alt,
|
||||
requestClose,
|
||||
})}
|
||||
</Modal>
|
||||
</FocusTrap>
|
||||
</OverlayCenter>
|
||||
</Overlay>
|
||||
)
|
||||
);
|
||||
@@ -16,34 +16,24 @@ import {
|
||||
import { JoinRule } from 'matrix-js-sdk';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { stopPropagation } from '../utils/keyboard';
|
||||
import { getRoomIconSrc } from '../utils/room';
|
||||
|
||||
export type ExtraJoinRules = 'knock_restricted';
|
||||
export type ExtendedJoinRules = JoinRule | ExtraJoinRules;
|
||||
|
||||
type JoinRuleIcons = Record<ExtendedJoinRules, IconSrc>;
|
||||
export const useRoomJoinRuleIcon = (): JoinRuleIcons =>
|
||||
|
||||
export const useJoinRuleIcons = (roomType?: string): JoinRuleIcons =>
|
||||
useMemo(
|
||||
() => ({
|
||||
[JoinRule.Invite]: Icons.HashLock,
|
||||
[JoinRule.Knock]: Icons.HashLock,
|
||||
knock_restricted: Icons.Hash,
|
||||
[JoinRule.Restricted]: Icons.Hash,
|
||||
[JoinRule.Public]: Icons.HashGlobe,
|
||||
[JoinRule.Private]: Icons.HashLock,
|
||||
[JoinRule.Invite]: getRoomIconSrc(Icons, roomType, JoinRule.Invite),
|
||||
[JoinRule.Knock]: getRoomIconSrc(Icons, roomType, JoinRule.Knock),
|
||||
knock_restricted: getRoomIconSrc(Icons, roomType, JoinRule.Restricted),
|
||||
[JoinRule.Restricted]: getRoomIconSrc(Icons, roomType, JoinRule.Restricted),
|
||||
[JoinRule.Public]: getRoomIconSrc(Icons, roomType, JoinRule.Public),
|
||||
[JoinRule.Private]: getRoomIconSrc(Icons, roomType, JoinRule.Private),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
export const useSpaceJoinRuleIcon = (): JoinRuleIcons =>
|
||||
useMemo(
|
||||
() => ({
|
||||
[JoinRule.Invite]: Icons.SpaceLock,
|
||||
[JoinRule.Knock]: Icons.SpaceLock,
|
||||
knock_restricted: Icons.Space,
|
||||
[JoinRule.Restricted]: Icons.Space,
|
||||
[JoinRule.Public]: Icons.SpaceGlobe,
|
||||
[JoinRule.Private]: Icons.SpaceLock,
|
||||
}),
|
||||
[]
|
||||
[roomType]
|
||||
);
|
||||
|
||||
type JoinRuleLabels = Record<ExtendedJoinRules, string>;
|
||||
|
||||
@@ -25,6 +25,11 @@ import {
|
||||
VideoContent,
|
||||
} from './message';
|
||||
import { UrlPreviewCard, UrlPreviewHolder } from './url-preview';
|
||||
import { ExternalImageCard } from '../../owl/components/ExternalImageCard';
|
||||
import { ExternalVideoCard } from '../../owl/components/ExternalVideoCard';
|
||||
import { YouTubeEmbedCard } from '../../owl/components/YouTubeEmbedCard';
|
||||
import { isImageUrl } from '../../owl/utils/imageUrl';
|
||||
import { getYouTubeId, isVideoUrl } from '../../owl/utils/videoUrl';
|
||||
import { Image, MediaControl, Video } from './media';
|
||||
import { ImageViewer } from './image-viewer';
|
||||
import { PdfViewer } from './Pdf-viewer';
|
||||
@@ -40,6 +45,7 @@ type RenderMessageContentProps = {
|
||||
getContent: <T>() => T;
|
||||
mediaAutoLoad?: boolean;
|
||||
urlPreview?: boolean;
|
||||
allowExternalVideos?: boolean;
|
||||
highlightRegex?: RegExp;
|
||||
htmlReactParserOptions: HTMLReactParserOptions;
|
||||
linkifyOpts: Opts;
|
||||
@@ -53,6 +59,7 @@ export function RenderMessageContent({
|
||||
getContent,
|
||||
mediaAutoLoad,
|
||||
urlPreview,
|
||||
allowExternalVideos,
|
||||
highlightRegex,
|
||||
htmlReactParserOptions,
|
||||
linkifyOpts,
|
||||
@@ -61,12 +68,38 @@ export function RenderMessageContent({
|
||||
const renderUrlsPreview = (urls: string[]) => {
|
||||
const filteredUrls = urls.filter((url) => !testMatrixTo(url));
|
||||
if (filteredUrls.length === 0) return undefined;
|
||||
|
||||
const imageUrls = filteredUrls.filter(isImageUrl);
|
||||
const nonImage = filteredUrls.filter((url) => !isImageUrl(url));
|
||||
const youtubeUrls = allowExternalVideos
|
||||
? nonImage.filter((url) => getYouTubeId(url) !== null)
|
||||
: [];
|
||||
const videoUrls = allowExternalVideos
|
||||
? nonImage.filter((url) => getYouTubeId(url) === null && isVideoUrl(url))
|
||||
: [];
|
||||
const otherUrls = nonImage.filter(
|
||||
(url) => !youtubeUrls.includes(url) && !videoUrls.includes(url)
|
||||
);
|
||||
|
||||
return (
|
||||
<UrlPreviewHolder>
|
||||
{filteredUrls.map((url) => (
|
||||
<UrlPreviewCard key={url} url={url} ts={ts} />
|
||||
<>
|
||||
{imageUrls.map((url) => (
|
||||
<ExternalImageCard key={url} url={url} />
|
||||
))}
|
||||
</UrlPreviewHolder>
|
||||
{youtubeUrls.map((url) => (
|
||||
<YouTubeEmbedCard key={url} url={url} />
|
||||
))}
|
||||
{videoUrls.map((url) => (
|
||||
<ExternalVideoCard key={url} url={url} />
|
||||
))}
|
||||
{otherUrls.length > 0 && (
|
||||
<UrlPreviewHolder>
|
||||
{otherUrls.map((url) => (
|
||||
<UrlPreviewCard key={url} url={url} ts={ts} />
|
||||
))}
|
||||
</UrlPreviewHolder>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
const renderCaption = () => {
|
||||
|
||||
@@ -2,43 +2,39 @@ import React from 'react';
|
||||
import { Box, Text, Icon, Icons, config, IconSrc } from 'folds';
|
||||
import { SequenceCard } from '../sequence-card';
|
||||
import { SettingTile } from '../setting-tile';
|
||||
import { CreateRoomAccess } from './types';
|
||||
|
||||
export enum CreateRoomKind {
|
||||
Private = 'private',
|
||||
Restricted = 'restricted',
|
||||
Public = 'public',
|
||||
}
|
||||
type CreateRoomKindSelectorProps = {
|
||||
value?: CreateRoomKind;
|
||||
onSelect: (value: CreateRoomKind) => void;
|
||||
type CreateRoomAccessSelectorProps = {
|
||||
value?: CreateRoomAccess;
|
||||
onSelect: (value: CreateRoomAccess) => void;
|
||||
canRestrict?: boolean;
|
||||
disabled?: boolean;
|
||||
getIcon: (kind: CreateRoomKind) => IconSrc;
|
||||
getIcon: (access: CreateRoomAccess) => IconSrc;
|
||||
};
|
||||
export function CreateRoomKindSelector({
|
||||
export function CreateRoomAccessSelector({
|
||||
value,
|
||||
onSelect,
|
||||
canRestrict,
|
||||
disabled,
|
||||
getIcon,
|
||||
}: CreateRoomKindSelectorProps) {
|
||||
}: CreateRoomAccessSelectorProps) {
|
||||
return (
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
{canRestrict && (
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant={value === CreateRoomKind.Restricted ? 'Primary' : 'SurfaceVariant'}
|
||||
variant={value === CreateRoomAccess.Restricted ? 'Primary' : 'SurfaceVariant'}
|
||||
direction="Column"
|
||||
gap="100"
|
||||
as="button"
|
||||
type="button"
|
||||
aria-pressed={value === CreateRoomKind.Restricted}
|
||||
onClick={() => onSelect(CreateRoomKind.Restricted)}
|
||||
aria-pressed={value === CreateRoomAccess.Restricted}
|
||||
onClick={() => onSelect(CreateRoomAccess.Restricted)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SettingTile
|
||||
before={<Icon size="400" src={getIcon(CreateRoomKind.Restricted)} />}
|
||||
after={value === CreateRoomKind.Restricted && <Icon src={Icons.Check} />}
|
||||
before={<Icon size="400" src={getIcon(CreateRoomAccess.Restricted)} />}
|
||||
after={value === CreateRoomAccess.Restricted && <Icon src={Icons.Check} />}
|
||||
>
|
||||
<Text size="H6">Restricted</Text>
|
||||
<Text size="T300" priority="300">
|
||||
@@ -49,18 +45,18 @@ export function CreateRoomKindSelector({
|
||||
)}
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant={value === CreateRoomKind.Private ? 'Primary' : 'SurfaceVariant'}
|
||||
variant={value === CreateRoomAccess.Private ? 'Primary' : 'SurfaceVariant'}
|
||||
direction="Column"
|
||||
gap="100"
|
||||
as="button"
|
||||
type="button"
|
||||
aria-pressed={value === CreateRoomKind.Private}
|
||||
onClick={() => onSelect(CreateRoomKind.Private)}
|
||||
aria-pressed={value === CreateRoomAccess.Private}
|
||||
onClick={() => onSelect(CreateRoomAccess.Private)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SettingTile
|
||||
before={<Icon size="400" src={getIcon(CreateRoomKind.Private)} />}
|
||||
after={value === CreateRoomKind.Private && <Icon src={Icons.Check} />}
|
||||
before={<Icon size="400" src={getIcon(CreateRoomAccess.Private)} />}
|
||||
after={value === CreateRoomAccess.Private && <Icon src={Icons.Check} />}
|
||||
>
|
||||
<Text size="H6">Private</Text>
|
||||
<Text size="T300" priority="300">
|
||||
@@ -70,18 +66,18 @@ export function CreateRoomKindSelector({
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant={value === CreateRoomKind.Public ? 'Primary' : 'SurfaceVariant'}
|
||||
variant={value === CreateRoomAccess.Public ? 'Primary' : 'SurfaceVariant'}
|
||||
direction="Column"
|
||||
gap="100"
|
||||
as="button"
|
||||
type="button"
|
||||
aria-pressed={value === CreateRoomKind.Public}
|
||||
onClick={() => onSelect(CreateRoomKind.Public)}
|
||||
aria-pressed={value === CreateRoomAccess.Public}
|
||||
onClick={() => onSelect(CreateRoomAccess.Public)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SettingTile
|
||||
before={<Icon size="400" src={getIcon(CreateRoomKind.Public)} />}
|
||||
after={value === CreateRoomKind.Public && <Icon src={Icons.Check} />}
|
||||
before={<Icon size="400" src={getIcon(CreateRoomAccess.Public)} />}
|
||||
after={value === CreateRoomAccess.Public && <Icon src={Icons.Check} />}
|
||||
>
|
||||
<Text size="H6">Public</Text>
|
||||
<Text size="T300" priority="300">
|
||||
75
src/app/components/create-room/CreateRoomTypeSelector.tsx
Normal file
75
src/app/components/create-room/CreateRoomTypeSelector.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import React from 'react';
|
||||
import { Box, Text, Icon, Icons, config, IconSrc } from 'folds';
|
||||
import { SequenceCard } from '../sequence-card';
|
||||
import { SettingTile } from '../setting-tile';
|
||||
import { CreateRoomType } from './types';
|
||||
import { BetaNoticeBadge } from '../BetaNoticeBadge';
|
||||
|
||||
type CreateRoomTypeSelectorProps = {
|
||||
value?: CreateRoomType;
|
||||
onSelect: (value: CreateRoomType) => void;
|
||||
disabled?: boolean;
|
||||
getIcon: (type: CreateRoomType) => IconSrc;
|
||||
};
|
||||
export function CreateRoomTypeSelector({
|
||||
value,
|
||||
onSelect,
|
||||
disabled,
|
||||
getIcon,
|
||||
}: CreateRoomTypeSelectorProps) {
|
||||
return (
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant={value === CreateRoomType.TextRoom ? 'Primary' : 'SurfaceVariant'}
|
||||
direction="Column"
|
||||
gap="100"
|
||||
as="button"
|
||||
type="button"
|
||||
aria-pressed={value === CreateRoomType.TextRoom}
|
||||
onClick={() => onSelect(CreateRoomType.TextRoom)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SettingTile
|
||||
before={<Icon size="400" src={getIcon(CreateRoomType.TextRoom)} />}
|
||||
after={value === CreateRoomType.TextRoom && <Icon src={Icons.Check} />}
|
||||
>
|
||||
<Box gap="200" alignItems="Baseline">
|
||||
<Text size="H6" style={{ flexShrink: 0 }}>
|
||||
Chat Room
|
||||
</Text>
|
||||
<Text size="T300" priority="300" truncate>
|
||||
- Messages, photos, and videos.
|
||||
</Text>
|
||||
</Box>
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant={value === CreateRoomType.VoiceRoom ? 'Primary' : 'SurfaceVariant'}
|
||||
direction="Column"
|
||||
gap="100"
|
||||
as="button"
|
||||
type="button"
|
||||
aria-pressed={value === CreateRoomType.VoiceRoom}
|
||||
onClick={() => onSelect(CreateRoomType.VoiceRoom)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<SettingTile
|
||||
before={<Icon size="400" src={getIcon(CreateRoomType.VoiceRoom)} />}
|
||||
after={value === CreateRoomType.VoiceRoom && <Icon src={Icons.Check} />}
|
||||
>
|
||||
<Box gap="200" alignItems="Baseline">
|
||||
<Text size="H6" style={{ flexShrink: 0 }}>
|
||||
Voice Room
|
||||
</Text>
|
||||
<Text size="T300" priority="300" truncate>
|
||||
- Live audio and video conversations.
|
||||
</Text>
|
||||
<BetaNoticeBadge />
|
||||
</Box>
|
||||
</SettingTile>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
export * from './CreateRoomKindSelector';
|
||||
export * from './CreateRoomAccessSelector';
|
||||
export * from './CreateRoomAliasInput';
|
||||
export * from './RoomVersionSelector';
|
||||
export * from './utils';
|
||||
export * from './AdditionalCreatorInput';
|
||||
export * from './types';
|
||||
|
||||
10
src/app/components/create-room/types.ts
Normal file
10
src/app/components/create-room/types.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export enum CreateRoomType {
|
||||
TextRoom = 'text',
|
||||
VoiceRoom = 'voice',
|
||||
}
|
||||
|
||||
export enum CreateRoomAccess {
|
||||
Private = 'private',
|
||||
Restricted = 'restricted',
|
||||
Public = 'public',
|
||||
}
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
Room,
|
||||
} from 'matrix-js-sdk';
|
||||
import { RoomJoinRulesEventContent } from 'matrix-js-sdk/lib/types';
|
||||
import { CreateRoomKind } from './CreateRoomKindSelector';
|
||||
import { RoomType, StateEvent } from '../../../types/matrix/room';
|
||||
import { getViaServers } from '../../plugins/via-servers';
|
||||
import { getMxIdServer } from '../../utils/matrix';
|
||||
import { CreateRoomAccess } from './types';
|
||||
|
||||
export const createRoomCreationContent = (
|
||||
type: RoomType | undefined,
|
||||
@@ -32,7 +32,7 @@ export const createRoomCreationContent = (
|
||||
};
|
||||
|
||||
export const createRoomJoinRulesState = (
|
||||
kind: CreateRoomKind,
|
||||
access: CreateRoomAccess,
|
||||
parent: Room | undefined,
|
||||
knock: boolean
|
||||
) => {
|
||||
@@ -40,13 +40,13 @@ export const createRoomJoinRulesState = (
|
||||
join_rule: knock ? JoinRule.Knock : JoinRule.Invite,
|
||||
};
|
||||
|
||||
if (kind === CreateRoomKind.Public) {
|
||||
if (access === CreateRoomAccess.Public) {
|
||||
content = {
|
||||
join_rule: JoinRule.Public,
|
||||
};
|
||||
}
|
||||
|
||||
if (kind === CreateRoomKind.Restricted && parent) {
|
||||
if (access === CreateRoomAccess.Restricted && parent) {
|
||||
content = {
|
||||
join_rule: knock ? ('knock_restricted' as JoinRule) : JoinRule.Restricted,
|
||||
allow: [
|
||||
@@ -74,6 +74,10 @@ export const createRoomParentState = (parent: Room) => ({
|
||||
},
|
||||
});
|
||||
|
||||
const createSpacePowerLevelsOverride = () => ({
|
||||
events_default: 50,
|
||||
});
|
||||
|
||||
export const createRoomEncryptionState = () => ({
|
||||
type: 'm.room.encryption',
|
||||
state_key: '',
|
||||
@@ -82,11 +86,23 @@ export const createRoomEncryptionState = () => ({
|
||||
},
|
||||
});
|
||||
|
||||
export const createRoomCallState = () => ({
|
||||
type: 'org.matrix.msc3401.call',
|
||||
state_key: '',
|
||||
content: {},
|
||||
});
|
||||
|
||||
export const createVoiceRoomPowerLevelsOverride = () => ({
|
||||
events: {
|
||||
[StateEvent.GroupCallMemberPrefix]: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export type CreateRoomData = {
|
||||
version: string;
|
||||
type?: RoomType;
|
||||
parent?: Room;
|
||||
kind: CreateRoomKind;
|
||||
access: CreateRoomAccess;
|
||||
name: string;
|
||||
topic?: string;
|
||||
aliasLocalPart?: string;
|
||||
@@ -106,7 +122,11 @@ export const createRoom = async (mx: MatrixClient, data: CreateRoomData): Promis
|
||||
initialState.push(createRoomParentState(data.parent));
|
||||
}
|
||||
|
||||
initialState.push(createRoomJoinRulesState(data.kind, data.parent, data.knock));
|
||||
if (data.type === RoomType.Call) {
|
||||
initialState.push(createRoomCallState());
|
||||
}
|
||||
|
||||
initialState.push(createRoomJoinRulesState(data.access, data.parent, data.knock));
|
||||
|
||||
const options: ICreateRoomOpts = {
|
||||
room_version: data.version,
|
||||
@@ -118,9 +138,15 @@ export const createRoom = async (mx: MatrixClient, data: CreateRoomData): Promis
|
||||
data.allowFederation,
|
||||
data.additionalCreators
|
||||
),
|
||||
power_level_content_override:
|
||||
data.type === RoomType.Call ? createVoiceRoomPowerLevelsOverride() : undefined,
|
||||
initial_state: initialState,
|
||||
};
|
||||
|
||||
if (data.type === RoomType.Space) {
|
||||
options.power_level_content_override = createSpacePowerLevelsOverride();
|
||||
}
|
||||
|
||||
const result = await mx.createRoom(options);
|
||||
|
||||
if (data.parent) {
|
||||
|
||||
@@ -169,12 +169,13 @@ export function RoomMentionAutocomplete({
|
||||
<RoomIcon
|
||||
size="50"
|
||||
joinRule={room.getJoinRule() ?? JoinRule.Restricted}
|
||||
roomType={room.getType()}
|
||||
filled
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon size="100" joinRule={room.getJoinRule()} space={room.isSpaceRoom()} />
|
||||
<RoomIcon size="100" joinRule={room.getJoinRule()} roomType={room.getType()} />
|
||||
)}
|
||||
</Avatar>
|
||||
}
|
||||
|
||||
@@ -228,9 +228,13 @@ const parseCodeBlockNode = (node: Element): CodeBlockElement[] | ParagraphElemen
|
||||
children: [{ text }],
|
||||
}));
|
||||
const childCode = node.children[0];
|
||||
const className =
|
||||
isTag(childCode) && childCode.tagName === 'code' ? childCode.attribs.class ?? '' : '';
|
||||
const prefix = { text: `${mdSequence}${className.replace('language-', '')}` };
|
||||
const attribs =
|
||||
isTag(childCode) && childCode.tagName === 'code' ? childCode.attribs : undefined;
|
||||
const languageClass = attribs?.class;
|
||||
const customLabel = attribs?.['data-label'];
|
||||
const prefix = {
|
||||
text: `${mdSequence}${customLabel ?? languageClass?.replace('language-', '') ?? ''}`,
|
||||
};
|
||||
const suffix = { text: mdSequence };
|
||||
return [
|
||||
{ type: BlockType.Paragraph, children: [prefix] },
|
||||
|
||||
@@ -389,6 +389,8 @@ export function MLocation({ content }: MLocationProps) {
|
||||
const geoUri = content.geo_uri;
|
||||
if (typeof geoUri !== 'string') return <BrokenContent />;
|
||||
const location = parseGeoUri(geoUri);
|
||||
if (!location) return <BrokenContent />;
|
||||
|
||||
return (
|
||||
<Box direction="Column" alignItems="Start" gap="100">
|
||||
<Text size="T400">{geoUri}</Text>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { JoinRule } from 'matrix-js-sdk';
|
||||
import { AvatarFallback, AvatarImage, Icon, Icons, color } from 'folds';
|
||||
import React, { ComponentProps, ReactEventHandler, ReactNode, forwardRef, useState } from 'react';
|
||||
import * as css from './RoomAvatar.css';
|
||||
import { joinRuleToIconSrc } from '../../utils/room';
|
||||
import { getRoomIconSrc } from '../../utils/room';
|
||||
import colorMXID from '../../../util/colorMXID';
|
||||
|
||||
type RoomAvatarProps = {
|
||||
@@ -44,13 +44,9 @@ export function RoomAvatar({ roomId, src, alt, renderFallback }: RoomAvatarProps
|
||||
export const RoomIcon = forwardRef<
|
||||
SVGSVGElement,
|
||||
Omit<ComponentProps<typeof Icon>, 'src'> & {
|
||||
joinRule: JoinRule;
|
||||
space?: boolean;
|
||||
joinRule?: JoinRule;
|
||||
roomType?: string;
|
||||
}
|
||||
>(({ joinRule, space, ...props }, ref) => (
|
||||
<Icon
|
||||
src={joinRuleToIconSrc(Icons, joinRule, space || false) ?? Icons.Hash}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
>(({ joinRule, roomType, ...props }, ref) => (
|
||||
<Icon src={getRoomIconSrc(Icons, roomType, joinRule)} {...props} ref={ref} />
|
||||
));
|
||||
|
||||
@@ -17,6 +17,7 @@ export const SequenceCard = as<
|
||||
firstChild,
|
||||
lastChild,
|
||||
outlined,
|
||||
mergeBorder,
|
||||
...props
|
||||
},
|
||||
ref
|
||||
@@ -24,7 +25,7 @@ export const SequenceCard = as<
|
||||
<Box
|
||||
as={AsSequenceCard}
|
||||
className={classNames(
|
||||
css.SequenceCard({ radii, outlined }),
|
||||
css.SequenceCard({ radii, outlined, mergeBorder }),
|
||||
ContainerColor({ variant }),
|
||||
className
|
||||
)}
|
||||
|
||||
@@ -11,7 +11,7 @@ export const SequenceCard = recipe({
|
||||
},
|
||||
borderStyle: 'solid',
|
||||
borderWidth: outlinedWidth,
|
||||
borderBottomWidth: 0,
|
||||
|
||||
selectors: {
|
||||
'&:first-child, :not(&) + &': {
|
||||
borderTopLeftRadius: [radii],
|
||||
@@ -20,7 +20,6 @@ export const SequenceCard = recipe({
|
||||
'&:last-child, &:not(:has(+&))': {
|
||||
borderBottomLeftRadius: [radii],
|
||||
borderBottomRightRadius: [radii],
|
||||
borderBottomWidth: outlinedWidth,
|
||||
},
|
||||
[`&[data-first-child="true"]`]: {
|
||||
borderTopLeftRadius: [radii],
|
||||
@@ -74,6 +73,16 @@ export const SequenceCard = recipe({
|
||||
},
|
||||
},
|
||||
},
|
||||
mergeBorder: {
|
||||
true: {
|
||||
borderBottomWidth: 0,
|
||||
selectors: {
|
||||
'&:last-child, &:not(:has(+&))': {
|
||||
borderBottomWidth: outlinedWidth,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
radii: '400',
|
||||
|
||||
18
src/app/components/stacked-avatar/StackedAvatar.tsx
Normal file
18
src/app/components/stacked-avatar/StackedAvatar.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { as, Avatar } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './styles.css';
|
||||
|
||||
type StackedAvatarProps = {
|
||||
radii?: '0' | '300' | '400' | '500' | 'Pill' | 'Inherit' | undefined;
|
||||
};
|
||||
export const StackedAvatar = as<'span', css.StackedAvatarVariants & StackedAvatarProps>(
|
||||
({ size, variant, className, ...props }, ref) => (
|
||||
<Avatar
|
||||
size={size}
|
||||
className={classNames(css.StackedAvatar({ size, variant }), className)}
|
||||
{...props}
|
||||
ref={ref}
|
||||
/>
|
||||
)
|
||||
);
|
||||
1
src/app/components/stacked-avatar/index.ts
Normal file
1
src/app/components/stacked-avatar/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './StackedAvatar';
|
||||
59
src/app/components/stacked-avatar/styles.css.ts
Normal file
59
src/app/components/stacked-avatar/styles.css.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { ComplexStyleRule } from '@vanilla-extract/css';
|
||||
import { recipe, RecipeVariants } from '@vanilla-extract/recipes';
|
||||
import { color, config, ContainerColor, toRem } from 'folds';
|
||||
|
||||
const getVariant = (variant: ContainerColor): ComplexStyleRule => ({
|
||||
outlineColor: color[variant].Container,
|
||||
});
|
||||
|
||||
export const StackedAvatar = recipe({
|
||||
base: {
|
||||
backgroundColor: color.Surface.Container,
|
||||
outlineStyle: 'solid',
|
||||
selectors: {
|
||||
'&:first-child': {
|
||||
marginLeft: 0,
|
||||
},
|
||||
'button&': {
|
||||
cursor: 'pointer',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
variants: {
|
||||
size: {
|
||||
'200': {
|
||||
marginLeft: toRem(-6),
|
||||
outlineWidth: config.borderWidth.B300,
|
||||
},
|
||||
'300': {
|
||||
marginLeft: toRem(-9),
|
||||
outlineWidth: config.borderWidth.B400,
|
||||
},
|
||||
'400': {
|
||||
marginLeft: toRem(-10.5),
|
||||
outlineWidth: config.borderWidth.B500,
|
||||
},
|
||||
'500': {
|
||||
marginLeft: toRem(-13),
|
||||
outlineWidth: config.borderWidth.B600,
|
||||
},
|
||||
},
|
||||
variant: {
|
||||
Background: getVariant('Background'),
|
||||
Surface: getVariant('Surface'),
|
||||
SurfaceVariant: getVariant('SurfaceVariant'),
|
||||
Primary: getVariant('Primary'),
|
||||
Secondary: getVariant('Secondary'),
|
||||
Success: getVariant('Success'),
|
||||
Warning: getVariant('Warning'),
|
||||
Critical: getVariant('Critical'),
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
size: '400',
|
||||
variant: 'Surface',
|
||||
},
|
||||
});
|
||||
|
||||
export type StackedAvatarVariants = RecipeVariants<typeof StackedAvatar>;
|
||||
@@ -26,7 +26,12 @@ export function SSOStage({
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = (evt: MessageEvent) => {
|
||||
if (ssoWindow && evt.data === 'authDone' && evt.source === ssoWindow) {
|
||||
if (
|
||||
evt.origin === new URL(ssoRedirectURL).origin &&
|
||||
ssoWindow &&
|
||||
evt.data === 'authDone' &&
|
||||
evt.source === ssoWindow
|
||||
) {
|
||||
ssoWindow.close();
|
||||
setSSOWindow(undefined);
|
||||
handleSubmit();
|
||||
@@ -37,7 +42,7 @@ export function SSOStage({
|
||||
return () => {
|
||||
window.removeEventListener('message', handleMessage);
|
||||
};
|
||||
}, [ssoWindow, handleSubmit]);
|
||||
}, [ssoWindow, handleSubmit, ssoRedirectURL]);
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
|
||||
@@ -23,6 +23,11 @@ export const UrlPreviewImg = style([
|
||||
objectPosition: 'center',
|
||||
flexShrink: 0,
|
||||
overflow: 'hidden',
|
||||
cursor: 'pointer',
|
||||
|
||||
':hover': {
|
||||
filter: 'brightness(0.8)',
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { IPreviewUrlResponse } from 'matrix-js-sdk';
|
||||
import { Box, Icon, IconButton, Icons, Scroll, Spinner, Text, as, color, config } from 'folds';
|
||||
import { ImageOverlay } from '../ImageOverlay';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { UrlPreview, UrlPreviewContent, UrlPreviewDescription, UrlPreviewImg } from './UrlPreview';
|
||||
@@ -12,6 +13,8 @@ import * as css from './UrlPreviewCard.css';
|
||||
import { tryDecodeURIComponent } from '../../utils/dom';
|
||||
import { mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { ImageViewer } from '../image-viewer';
|
||||
import { onEnterOrSpace } from '../../utils/keyboard';
|
||||
|
||||
const linkStyles = { color: color.Success.Main };
|
||||
|
||||
@@ -19,6 +22,7 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
|
||||
({ url, ts, ...props }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const [viewer, setViewer] = useState(false);
|
||||
const [previewStatus, loadPreview] = useAsyncCallback(
|
||||
useCallback(() => mx.getUrlPreview(url, ts), [url, ts, mx])
|
||||
);
|
||||
@@ -30,11 +34,41 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
|
||||
if (previewStatus.status === AsyncStatus.Error) return null;
|
||||
|
||||
const renderContent = (prev: IPreviewUrlResponse) => {
|
||||
const imgUrl = mxcUrlToHttp(mx, prev['og:image'] || '', useAuthentication, 256, 256, 'scale', false);
|
||||
const thumbUrl = mxcUrlToHttp(
|
||||
mx,
|
||||
prev['og:image'] || '',
|
||||
useAuthentication,
|
||||
256,
|
||||
256,
|
||||
'scale',
|
||||
false
|
||||
);
|
||||
|
||||
const imgUrl = mxcUrlToHttp(mx, prev['og:image'] || '', useAuthentication);
|
||||
|
||||
return (
|
||||
<>
|
||||
{imgUrl && <UrlPreviewImg src={imgUrl} alt={prev['og:title']} title={prev['og:title']} />}
|
||||
{thumbUrl && (
|
||||
<UrlPreviewImg
|
||||
src={thumbUrl}
|
||||
alt={prev['og:title']}
|
||||
title={prev['og:title']}
|
||||
tabIndex={0}
|
||||
onKeyDown={(evt) => onEnterOrSpace(() => setViewer(true))(evt)}
|
||||
onClick={() => setViewer(true)}
|
||||
/>
|
||||
)}
|
||||
{imgUrl && (
|
||||
<ImageOverlay
|
||||
src={imgUrl}
|
||||
alt={prev['og:title']}
|
||||
viewer={viewer}
|
||||
requestClose={() => {
|
||||
setViewer(false);
|
||||
}}
|
||||
renderViewer={(p) => <ImageViewer {...p} />}
|
||||
/>
|
||||
)}
|
||||
<UrlPreviewContent>
|
||||
<Text
|
||||
style={linkStyles}
|
||||
@@ -42,7 +76,7 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number }>(
|
||||
as="a"
|
||||
href={url}
|
||||
target="_blank"
|
||||
rel="no-referrer"
|
||||
rel="noreferrer"
|
||||
size="T200"
|
||||
priority="300"
|
||||
>
|
||||
|
||||
@@ -323,7 +323,7 @@ export function MutualRoomsChip({ userId }: { userId: string }) {
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon size="100" joinRule={room.getJoinRule()} />
|
||||
<RoomIcon size="100" joinRule={room.getJoinRule()} roomType={room.getType()} />
|
||||
)}
|
||||
</Avatar>
|
||||
}
|
||||
|
||||
@@ -20,6 +20,16 @@ export type AutoDiscoveryInfo = Record<string, unknown> & {
|
||||
'm.identity_server'?: {
|
||||
base_url: string;
|
||||
};
|
||||
'org.matrix.msc2965.authentication'?: {
|
||||
account?: string;
|
||||
issuer?: string;
|
||||
};
|
||||
'org.matrix.msc4143.rtc_foci'?: [
|
||||
{
|
||||
livekit_service_url: string;
|
||||
type: 'livekit';
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
export const autoDiscovery = async (
|
||||
|
||||
@@ -291,7 +291,11 @@ export function AddExistingModal({ parentId, space, requestClose }: AddExistingM
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon size="200" joinRule={room.getJoinRule()} />
|
||||
<RoomIcon
|
||||
size="200"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
}
|
||||
|
||||
226
src/app/features/call-status/CallControl.tsx
Normal file
226
src/app/features/call-status/CallControl.tsx
Normal file
@@ -0,0 +1,226 @@
|
||||
import { Box, Chip, Icon, IconButton, Icons, Spinner, Text, Tooltip, TooltipProvider } from 'folds';
|
||||
import React, { useCallback } from 'react';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { StatusDivider } from './components';
|
||||
import { CallEmbed, useCallControlState } from '../../plugins/call';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||
import { callEmbedAtom } from '../../state/callEmbed';
|
||||
|
||||
type MicrophoneButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => Promise<unknown>;
|
||||
disabled?: boolean;
|
||||
};
|
||||
function MicrophoneButton({ enabled, onToggle, disabled }: MicrophoneButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Turn Off Microphone' : 'Turn On Microphone'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Surface' : 'Warning'}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
size="300"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
disabled={disabled}
|
||||
>
|
||||
<Icon size="100" src={enabled ? Icons.Mic : Icons.MicMute} filled={!enabled} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type SoundButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
function SoundButton({ enabled, onToggle, disabled }: SoundButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Turn Off Sound' : 'Turn On Sound'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Surface' : 'Warning'}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
size="300"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
disabled={disabled}
|
||||
>
|
||||
<Icon
|
||||
size="100"
|
||||
src={enabled ? Icons.Headphone : Icons.HeadphoneMute}
|
||||
filled={!enabled}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type VideoButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => Promise<unknown>;
|
||||
disabled?: boolean;
|
||||
};
|
||||
function VideoButton({ enabled, onToggle, disabled }: VideoButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Stop Camera' : 'Start Camera'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
size="300"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
disabled={disabled}
|
||||
>
|
||||
<Icon
|
||||
size="100"
|
||||
src={enabled ? Icons.VideoCamera : Icons.VideoCameraMute}
|
||||
filled={enabled}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type ScreenShareButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
disabled?: boolean;
|
||||
};
|
||||
function ScreenShareButton({ enabled, onToggle, disabled }: ScreenShareButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Stop Screenshare' : 'Start Screenshare'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
size="300"
|
||||
onClick={onToggle}
|
||||
outlined
|
||||
disabled={disabled}
|
||||
>
|
||||
<Icon size="100" src={Icons.ScreenShare} filled={enabled} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function CallControl({
|
||||
callEmbed,
|
||||
compact,
|
||||
callJoined,
|
||||
}: {
|
||||
callEmbed: CallEmbed;
|
||||
compact: boolean;
|
||||
callJoined: boolean;
|
||||
}) {
|
||||
const { microphone, video, sound, screenshare } = useCallControlState(callEmbed.control);
|
||||
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||
|
||||
const [hangupState, hangup] = useAsyncCallback(
|
||||
useCallback(() => callEmbed.hangup(), [callEmbed])
|
||||
);
|
||||
const exiting =
|
||||
hangupState.status === AsyncStatus.Loading || hangupState.status === AsyncStatus.Success;
|
||||
|
||||
const handleHangup = () => {
|
||||
if (!callJoined) {
|
||||
setCallEmbed(undefined);
|
||||
return;
|
||||
}
|
||||
hangup();
|
||||
};
|
||||
|
||||
return (
|
||||
<Box shrink="No" alignItems="Center" gap="300">
|
||||
<Box alignItems="Inherit" gap="200">
|
||||
<MicrophoneButton
|
||||
enabled={microphone}
|
||||
onToggle={() => callEmbed.control.toggleMicrophone()}
|
||||
disabled={!callJoined}
|
||||
/>
|
||||
<SoundButton
|
||||
enabled={sound}
|
||||
onToggle={() => callEmbed.control.toggleSound()}
|
||||
disabled={!callJoined}
|
||||
/>
|
||||
{!compact && <StatusDivider />}
|
||||
<VideoButton
|
||||
enabled={video}
|
||||
onToggle={() => callEmbed.control.toggleVideo()}
|
||||
disabled={!callJoined}
|
||||
/>
|
||||
{!compact && (
|
||||
<ScreenShareButton
|
||||
enabled={screenshare}
|
||||
onToggle={() => callEmbed.control.toggleScreenshare()}
|
||||
disabled={!callJoined}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
<StatusDivider />
|
||||
<Chip
|
||||
variant="Critical"
|
||||
radii="Pill"
|
||||
fill="Soft"
|
||||
before={
|
||||
exiting ? (
|
||||
<Spinner variant="Critical" fill="Soft" size="50" />
|
||||
) : (
|
||||
<Icon size="50" src={Icons.PhoneDown} filled />
|
||||
)
|
||||
}
|
||||
disabled={exiting}
|
||||
outlined
|
||||
onClick={handleHangup}
|
||||
>
|
||||
{!compact && (
|
||||
<Text as="span" size="L400">
|
||||
End
|
||||
</Text>
|
||||
)}
|
||||
</Chip>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
55
src/app/features/call-status/CallRoomName.tsx
Normal file
55
src/app/features/call-status/CallRoomName.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import React from 'react';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { Chip, Text } from 'folds';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useRoomName } from '../../hooks/useRoomMeta';
|
||||
import { RoomIcon } from '../../components/room-avatar';
|
||||
import { roomToParentsAtom } from '../../state/room/roomToParents';
|
||||
import { getAllParents, guessPerfectParent } from '../../utils/room';
|
||||
import { useOrphanSpaces } from '../../state/hooks/roomList';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { allRoomsAtom } from '../../state/room-list/roomList';
|
||||
import { mDirectAtom } from '../../state/mDirectList';
|
||||
import { useAllJoinedRoomsSet, useGetRoom } from '../../hooks/useGetRoom';
|
||||
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
||||
|
||||
type CallRoomNameProps = {
|
||||
room: Room;
|
||||
};
|
||||
export function CallRoomName({ room }: CallRoomNameProps) {
|
||||
const mx = useMatrixClient();
|
||||
const name = useRoomName(room);
|
||||
const roomToParents = useAtomValue(roomToParentsAtom);
|
||||
const orphanSpaces = useOrphanSpaces(mx, allRoomsAtom, roomToParents);
|
||||
const mDirects = useAtomValue(mDirectAtom);
|
||||
const dm = mDirects.has(room.roomId);
|
||||
|
||||
const allRoomsSet = useAllJoinedRoomsSet();
|
||||
const getRoom = useGetRoom(allRoomsSet);
|
||||
|
||||
const allParents = getAllParents(roomToParents, room.roomId);
|
||||
const orphanParents = allParents && orphanSpaces.filter((o) => allParents.has(o));
|
||||
const perfectOrphanParent = orphanParents && guessPerfectParent(mx, room.roomId, orphanParents);
|
||||
|
||||
const { navigateRoom } = useRoomNavigate();
|
||||
|
||||
return (
|
||||
<Chip
|
||||
variant="Background"
|
||||
radii="Pill"
|
||||
before={
|
||||
<RoomIcon size="200" joinRule={room.getJoinRule()} roomType={room.getType()} filled />
|
||||
}
|
||||
onClick={() => navigateRoom(room.roomId)}
|
||||
>
|
||||
<Text size="L400" truncate>
|
||||
{name}
|
||||
{!dm && perfectOrphanParent && (
|
||||
<Text as="span" size="T200" priority="300">
|
||||
{' •'} <b>{getRoom(perfectOrphanParent)?.name ?? perfectOrphanParent}</b>
|
||||
</Text>
|
||||
)}
|
||||
</Text>
|
||||
</Chip>
|
||||
);
|
||||
}
|
||||
81
src/app/features/call-status/CallStatus.tsx
Normal file
81
src/app/features/call-status/CallStatus.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import React from 'react';
|
||||
import { Box, Spinner } from 'folds';
|
||||
import classNames from 'classnames';
|
||||
import { LiveChip } from './LiveChip';
|
||||
import * as css from './styles.css';
|
||||
import { CallRoomName } from './CallRoomName';
|
||||
import { CallControl } from './CallControl';
|
||||
import { ContainerColor } from '../../styles/ContainerColor.css';
|
||||
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
||||
import { ScreenSize, useScreenSize } from '../../hooks/useScreenSize';
|
||||
import { MemberGlance } from './MemberGlance';
|
||||
import { StatusDivider } from './components';
|
||||
import { CallEmbed } from '../../plugins/call/CallEmbed';
|
||||
import { useCallJoined } from '../../hooks/useCallEmbed';
|
||||
import { useCallSpeakers } from '../../hooks/useCallSpeakers';
|
||||
import { MemberSpeaking } from './MemberSpeaking';
|
||||
|
||||
type CallStatusProps = {
|
||||
callEmbed: CallEmbed;
|
||||
};
|
||||
export function CallStatus({ callEmbed }: CallStatusProps) {
|
||||
const { room } = callEmbed;
|
||||
|
||||
const callSession = useCallSession(room);
|
||||
const callMembers = useCallMembers(room, callSession);
|
||||
const screenSize = useScreenSize();
|
||||
const callJoined = useCallJoined(callEmbed);
|
||||
const speakers = useCallSpeakers(callEmbed);
|
||||
|
||||
const compact = screenSize === ScreenSize.Mobile;
|
||||
|
||||
const memberVisible = callJoined && callMembers.length > 0;
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={classNames(css.CallStatus, ContainerColor({ variant: 'Background' }))}
|
||||
shrink="No"
|
||||
gap="400"
|
||||
alignItems={compact ? undefined : 'Center'}
|
||||
direction={compact ? 'Column' : 'Row'}
|
||||
>
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
{memberVisible ? (
|
||||
<Box shrink="No">
|
||||
<LiveChip count={callMembers.length} room={room} members={callMembers} />
|
||||
</Box>
|
||||
) : (
|
||||
<Spinner variant="Secondary" size="200" />
|
||||
)}
|
||||
<Box grow="Yes" alignItems="Center" gap="Inherit">
|
||||
{!compact && (
|
||||
<>
|
||||
<CallRoomName room={room} />
|
||||
{speakers.size > 0 && (
|
||||
<>
|
||||
<StatusDivider />
|
||||
<span data-spacing-node />
|
||||
<MemberSpeaking room={room} speakers={speakers} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
{memberVisible && (
|
||||
<Box shrink="No">
|
||||
<MemberGlance room={room} members={callMembers} speakers={speakers} />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
{memberVisible && !compact && <StatusDivider />}
|
||||
<Box shrink="No" alignItems="Center" gap="Inherit">
|
||||
{compact && (
|
||||
<Box grow="Yes">
|
||||
<CallRoomName room={room} />
|
||||
</Box>
|
||||
)}
|
||||
<CallControl callJoined={callJoined} compact={compact} callEmbed={callEmbed} />
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
137
src/app/features/call-status/LiveChip.tsx
Normal file
137
src/app/features/call-status/LiveChip.tsx
Normal file
@@ -0,0 +1,137 @@
|
||||
import React, { MouseEventHandler, useState } from 'react';
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Chip,
|
||||
config,
|
||||
Icon,
|
||||
Icons,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { CallMembership } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import * as css from './styles.css';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { UserAvatar } from '../../components/user-avatar';
|
||||
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
||||
import { getMouseEventCords } from '../../utils/dom';
|
||||
|
||||
type LiveChipProps = {
|
||||
room: Room;
|
||||
members: CallMembership[];
|
||||
count: number;
|
||||
};
|
||||
export function LiveChip({ count, room, members }: LiveChipProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const openUserProfile = useOpenUserRoomProfile();
|
||||
|
||||
const [cords, setCords] = useState<RectCords>();
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
return (
|
||||
<PopOut
|
||||
anchor={cords}
|
||||
position="Top"
|
||||
align="Start"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu
|
||||
style={{
|
||||
maxHeight: '75vh',
|
||||
maxWidth: toRem(300),
|
||||
display: 'flex',
|
||||
}}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Scroll size="0" hideTrack visibility="Hover">
|
||||
<Box direction="Column" style={{ padding: config.space.S100 }}>
|
||||
{members.map((callMember) => {
|
||||
const userId = callMember.sender;
|
||||
if (!userId) return null;
|
||||
const name =
|
||||
getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
||||
const avatarMxc = getMemberAvatarMxc(room, userId);
|
||||
const avatarUrl = avatarMxc
|
||||
? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96) ?? undefined
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<MenuItem
|
||||
key={callMember.membershipID}
|
||||
size="400"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
style={{ paddingLeft: config.space.S200 }}
|
||||
onClick={(evt) =>
|
||||
openUserProfile(
|
||||
room.roomId,
|
||||
undefined,
|
||||
userId,
|
||||
getMouseEventCords(evt.nativeEvent),
|
||||
'Right'
|
||||
)
|
||||
}
|
||||
before={
|
||||
<Avatar size="200" radii="400">
|
||||
<UserAvatar
|
||||
userId={userId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
}
|
||||
>
|
||||
<Text size="T300" truncate>
|
||||
{name}
|
||||
</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<Chip
|
||||
variant="Surface"
|
||||
fill="Soft"
|
||||
before={<Badge variant="Critical" fill="Solid" size="200" />}
|
||||
after={<Icon size="50" src={cords ? Icons.ChevronBottom : Icons.ChevronTop} />}
|
||||
radii="Pill"
|
||||
onClick={handleOpenMenu}
|
||||
>
|
||||
<Text className={css.LiveChipText} as="span" size="L400" truncate>
|
||||
{count} Live
|
||||
</Text>
|
||||
</Chip>
|
||||
</PopOut>
|
||||
);
|
||||
}
|
||||
75
src/app/features/call-status/MemberGlance.tsx
Normal file
75
src/app/features/call-status/MemberGlance.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Box, config, Icon, Icons, Text } from 'folds';
|
||||
import { CallMembership } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import React from 'react';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { UserAvatar } from '../../components/user-avatar';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { StackedAvatar } from '../../components/stacked-avatar';
|
||||
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
||||
import { getMouseEventCords } from '../../utils/dom';
|
||||
import * as css from './styles.css';
|
||||
|
||||
type MemberGlanceProps = {
|
||||
room: Room;
|
||||
members: CallMembership[];
|
||||
speakers: Set<string>;
|
||||
max?: number;
|
||||
};
|
||||
export function MemberGlance({ room, members, speakers, max = 6 }: MemberGlanceProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const openUserProfile = useOpenUserRoomProfile();
|
||||
|
||||
const visibleMembers = members.slice(0, max);
|
||||
const remainingCount = max && members.length > max ? members.length - max : 0;
|
||||
|
||||
return (
|
||||
<Box alignItems="Center">
|
||||
{visibleMembers.map((callMember) => {
|
||||
const userId = callMember.sender;
|
||||
if (!userId) return null;
|
||||
const name = getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
||||
const avatarMxc = getMemberAvatarMxc(room, userId);
|
||||
const avatarUrl = avatarMxc
|
||||
? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96) ?? undefined
|
||||
: undefined;
|
||||
|
||||
return (
|
||||
<StackedAvatar
|
||||
key={callMember.membershipID}
|
||||
className={speakers.has(callMember.sender) ? css.SpeakerAvatarOutline : undefined}
|
||||
title={name}
|
||||
as="button"
|
||||
variant="Background"
|
||||
size="200"
|
||||
radii="Pill"
|
||||
onClick={(evt) =>
|
||||
openUserProfile(
|
||||
room.roomId,
|
||||
undefined,
|
||||
userId,
|
||||
getMouseEventCords(evt.nativeEvent),
|
||||
'Top'
|
||||
)
|
||||
}
|
||||
>
|
||||
<UserAvatar
|
||||
userId={userId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
|
||||
/>
|
||||
</StackedAvatar>
|
||||
);
|
||||
})}
|
||||
{remainingCount > 0 && (
|
||||
<Text size="L400" style={{ paddingLeft: config.space.S100 }}>
|
||||
+{remainingCount}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
78
src/app/features/call-status/MemberSpeaking.tsx
Normal file
78
src/app/features/call-status/MemberSpeaking.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import React from 'react';
|
||||
import { Box, Icon, Icons, Text } from 'folds';
|
||||
import { getMemberDisplayName } from '../../utils/room';
|
||||
import { getMxIdLocalPart } from '../../utils/matrix';
|
||||
|
||||
type MemberSpeakingProps = {
|
||||
room: Room;
|
||||
speakers: Set<string>;
|
||||
};
|
||||
export function MemberSpeaking({ room, speakers }: MemberSpeakingProps) {
|
||||
const speakingNames = Array.from(speakers).map(
|
||||
(userId) => getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId
|
||||
);
|
||||
return (
|
||||
<Box alignItems="Center" gap="100">
|
||||
<Icon size="100" src={Icons.Mic} filled />
|
||||
<Text size="T200" truncate>
|
||||
{speakingNames.length === 1 && (
|
||||
<>
|
||||
<b>{speakingNames[0]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' is speaking...'}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
{speakingNames.length === 2 && (
|
||||
<>
|
||||
<b>{speakingNames[0]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' and '}
|
||||
</Text>
|
||||
<b>{speakingNames[1]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' are speaking...'}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
{speakingNames.length === 3 && (
|
||||
<>
|
||||
<b>{speakingNames[0]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{', '}
|
||||
</Text>
|
||||
<b>{speakingNames[1]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' and '}
|
||||
</Text>
|
||||
<b>{speakingNames[2]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' are speaking...'}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
{speakingNames.length > 3 && (
|
||||
<>
|
||||
<b>{speakingNames[0]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{', '}
|
||||
</Text>
|
||||
<b>{speakingNames[1]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{', '}
|
||||
</Text>
|
||||
<b>{speakingNames[2]}</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' and '}
|
||||
</Text>
|
||||
<b>{speakingNames.length - 3} others</b>
|
||||
<Text as="span" size="Inherit" priority="300">
|
||||
{' are speaking...'}
|
||||
</Text>
|
||||
</>
|
||||
)}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
9
src/app/features/call-status/components.tsx
Normal file
9
src/app/features/call-status/components.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Line } from 'folds';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export function StatusDivider() {
|
||||
return (
|
||||
<Line variant="Background" size="300" direction="Vertical" className={css.ControlDivider} />
|
||||
);
|
||||
}
|
||||
1
src/app/features/call-status/index.ts
Normal file
1
src/app/features/call-status/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './CallStatus';
|
||||
21
src/app/features/call-status/styles.css.ts
Normal file
21
src/app/features/call-status/styles.css.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { color, config, toRem } from 'folds';
|
||||
|
||||
export const LiveChipText = style({
|
||||
color: color.Critical.Main,
|
||||
});
|
||||
|
||||
export const CallStatus = style([
|
||||
{
|
||||
padding: `${toRem(6)} ${config.space.S200}`,
|
||||
borderTop: `${config.borderWidth.B300} solid ${color.Background.ContainerLine}`,
|
||||
},
|
||||
]);
|
||||
|
||||
export const ControlDivider = style({
|
||||
height: toRem(16),
|
||||
});
|
||||
|
||||
export const SpeakerAvatarOutline = style({
|
||||
boxShadow: `0 0 0 ${config.borderWidth.B600} ${color.Success.Main}`,
|
||||
});
|
||||
203
src/app/features/call/CallControls.tsx
Normal file
203
src/app/features/call/CallControls.tsx
Normal file
@@ -0,0 +1,203 @@
|
||||
import React, { MouseEventHandler, useCallback, useRef, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
config,
|
||||
Icon,
|
||||
IconButton,
|
||||
Icons,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Spinner,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { SequenceCard } from '../../components/sequence-card';
|
||||
import * as css from './styles.css';
|
||||
import {
|
||||
ChatButton,
|
||||
ControlDivider,
|
||||
MicrophoneButton,
|
||||
ScreenShareButton,
|
||||
SoundButton,
|
||||
VideoButton,
|
||||
} from './Controls';
|
||||
import { CallEmbed, useCallControlState } from '../../plugins/call';
|
||||
import { useResizeObserver } from '../../hooks/useResizeObserver';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||
|
||||
type CallControlsProps = {
|
||||
callEmbed: CallEmbed;
|
||||
};
|
||||
export function CallControls({ callEmbed }: CallControlsProps) {
|
||||
const controlRef = useRef<HTMLDivElement>(null);
|
||||
const [compact, setCompact] = useState(document.body.clientWidth < 500);
|
||||
|
||||
useResizeObserver(
|
||||
useCallback(() => {
|
||||
const element = controlRef.current;
|
||||
if (!element) return;
|
||||
setCompact(element.clientWidth < 500);
|
||||
}, []),
|
||||
useCallback(() => controlRef.current, [])
|
||||
);
|
||||
|
||||
const { microphone, video, sound, screenshare, spotlight } = useCallControlState(
|
||||
callEmbed.control
|
||||
);
|
||||
|
||||
const [cords, setCords] = useState<RectCords>();
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSpotlightClick = () => {
|
||||
callEmbed.control.toggleSpotlight();
|
||||
setCords(undefined);
|
||||
};
|
||||
|
||||
const handleReactionsClick = () => {
|
||||
callEmbed.control.toggleReactions();
|
||||
setCords(undefined);
|
||||
};
|
||||
|
||||
const handleSettingsClick = () => {
|
||||
callEmbed.control.toggleSettings();
|
||||
setCords(undefined);
|
||||
};
|
||||
|
||||
const [hangupState, hangup] = useAsyncCallback(
|
||||
useCallback(() => callEmbed.hangup(), [callEmbed])
|
||||
);
|
||||
const exiting =
|
||||
hangupState.status === AsyncStatus.Loading || hangupState.status === AsyncStatus.Success;
|
||||
|
||||
return (
|
||||
<Box
|
||||
ref={controlRef}
|
||||
className={css.CallControlContainer}
|
||||
justifyContent="Center"
|
||||
alignItems="Center"
|
||||
>
|
||||
<SequenceCard
|
||||
className={css.ControlCard}
|
||||
variant="SurfaceVariant"
|
||||
gap="400"
|
||||
radii="500"
|
||||
alignItems="Center"
|
||||
justifyContent="SpaceBetween"
|
||||
>
|
||||
<Box alignItems="Center" gap="Inherit" grow="Yes" direction={compact ? 'Column' : 'Row'}>
|
||||
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
|
||||
<MicrophoneButton
|
||||
enabled={microphone}
|
||||
onToggle={() => callEmbed.control.toggleMicrophone()}
|
||||
/>
|
||||
<SoundButton enabled={sound} onToggle={() => callEmbed.control.toggleSound()} />
|
||||
</Box>
|
||||
{!compact && <ControlDivider />}
|
||||
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
|
||||
<VideoButton enabled={video} onToggle={() => callEmbed.control.toggleVideo()} />
|
||||
<ScreenShareButton
|
||||
enabled={screenshare}
|
||||
onToggle={() => callEmbed.control.toggleScreenshare()}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
{!compact && <ControlDivider />}
|
||||
<Box alignItems="Center" gap="Inherit" grow="Yes" direction={compact ? 'Column' : 'Row'}>
|
||||
<Box shrink="No" alignItems="Inherit" justifyContent="Inherit" gap="200">
|
||||
<ChatButton />
|
||||
<PopOut
|
||||
anchor={cords}
|
||||
position="Top"
|
||||
align="Center"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => evt.key === 'ArrowDown',
|
||||
isKeyBackward: (evt: KeyboardEvent) => evt.key === 'ArrowUp',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" style={{ padding: config.space.S100 }}>
|
||||
<MenuItem
|
||||
size="300"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
onClick={handleSpotlightClick}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
{spotlight ? 'Grid View' : 'Spotlight View'}
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
size="300"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
onClick={handleReactionsClick}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
Reactions
|
||||
</Text>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
size="300"
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
onClick={handleSettingsClick}
|
||||
>
|
||||
<Text size="B300" truncate>
|
||||
Settings
|
||||
</Text>
|
||||
</MenuItem>
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
>
|
||||
<IconButton
|
||||
variant="Surface"
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={handleOpenMenu}
|
||||
outlined
|
||||
aria-pressed={!!cords}
|
||||
>
|
||||
<Icon size="400" src={Icons.VerticalDots} />
|
||||
</IconButton>
|
||||
</PopOut>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column">
|
||||
<Button
|
||||
style={{ minWidth: toRem(88) }}
|
||||
variant="Critical"
|
||||
fill="Solid"
|
||||
onClick={hangup}
|
||||
before={
|
||||
exiting ? (
|
||||
<Spinner variant="Critical" fill="Solid" size="200" />
|
||||
) : (
|
||||
<Icon src={Icons.PhoneDown} size="200" filled />
|
||||
)
|
||||
}
|
||||
disabled={exiting}
|
||||
>
|
||||
<Text size="B400">End</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
121
src/app/features/call/CallMemberCard.tsx
Normal file
121
src/app/features/call/CallMemberCard.tsx
Normal file
@@ -0,0 +1,121 @@
|
||||
import { CallMembership, SessionMembershipData } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import React, { useState } from 'react';
|
||||
import { Avatar, Box, Icon, Icons, Text } from 'folds';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useOpenUserRoomProfile } from '../../state/hooks/userRoomProfile';
|
||||
import { SequenceCard } from '../../components/sequence-card';
|
||||
import { getMemberAvatarMxc, getMemberDisplayName } from '../../utils/room';
|
||||
import { useRoom } from '../../hooks/useRoom';
|
||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||
import { UserAvatar } from '../../components/user-avatar';
|
||||
import { getMouseEventCords } from '../../utils/dom';
|
||||
import * as css from './styles.css';
|
||||
|
||||
interface MemberWithMembershipData {
|
||||
membershipData?: SessionMembershipData & {
|
||||
'm.call.intent': 'video' | 'audio';
|
||||
};
|
||||
}
|
||||
|
||||
type CallMemberCardProps = {
|
||||
member: CallMembership;
|
||||
};
|
||||
export function CallMemberCard({ member }: CallMemberCardProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const room = useRoom();
|
||||
|
||||
const openUserProfile = useOpenUserRoomProfile();
|
||||
|
||||
const userId = member.sender;
|
||||
if (!userId) return null;
|
||||
|
||||
const name = getMemberDisplayName(room, userId) ?? getMxIdLocalPart(userId) ?? userId;
|
||||
const avatarMxc = getMemberAvatarMxc(room, userId);
|
||||
const avatarUrl = avatarMxc
|
||||
? mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96) ?? undefined
|
||||
: undefined;
|
||||
|
||||
const audioOnly =
|
||||
(member as unknown as MemberWithMembershipData).membershipData?.['m.call.intent'] === 'audio';
|
||||
|
||||
return (
|
||||
<SequenceCard
|
||||
as="button"
|
||||
key={member.membershipID}
|
||||
className={css.CallMemberCard}
|
||||
variant="SurfaceVariant"
|
||||
radii="500"
|
||||
onClick={(evt: any) =>
|
||||
openUserProfile(
|
||||
room.roomId,
|
||||
undefined,
|
||||
userId,
|
||||
getMouseEventCords(evt.nativeEvent),
|
||||
'Right'
|
||||
)
|
||||
}
|
||||
>
|
||||
<Box grow="Yes" gap="300" alignItems="Center">
|
||||
<Avatar size="200" radii="400">
|
||||
<UserAvatar
|
||||
userId={userId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => <Icon size="50" src={Icons.User} filled />}
|
||||
/>
|
||||
</Avatar>
|
||||
<Box grow="Yes">
|
||||
<Text size="L400" truncate>
|
||||
{name}
|
||||
</Text>
|
||||
</Box>
|
||||
{audioOnly && <Icon src={Icons.VideoCameraMute} size="100" />}
|
||||
</Box>
|
||||
</SequenceCard>
|
||||
);
|
||||
}
|
||||
|
||||
export function CallMemberRenderer({
|
||||
members,
|
||||
max = 4,
|
||||
}: {
|
||||
members: CallMembership[];
|
||||
max?: number;
|
||||
}) {
|
||||
const [viewMore, setViewMore] = useState(false);
|
||||
|
||||
const truncatedMembers = viewMore ? members : members.slice(0, 4);
|
||||
const remaining = members.length - truncatedMembers.length;
|
||||
|
||||
return (
|
||||
<>
|
||||
{truncatedMembers.map((member) => (
|
||||
<CallMemberCard key={member.membershipID} member={member} />
|
||||
))}
|
||||
{members.length > max && (
|
||||
<SequenceCard
|
||||
as="button"
|
||||
className={css.CallMemberCard}
|
||||
variant="SurfaceVariant"
|
||||
radii="500"
|
||||
onClick={() => setViewMore(!viewMore)}
|
||||
>
|
||||
<Box grow="Yes" gap="300" alignItems="Center">
|
||||
{viewMore ? (
|
||||
<Text size="L400" truncate>
|
||||
Collapse
|
||||
</Text>
|
||||
) : (
|
||||
<Text size="L400" truncate>
|
||||
{remaining === 0 ? `+${remaining} Other` : `+${remaining} Others`}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
<Icon src={viewMore ? Icons.ChevronTop : Icons.ChevronBottom} size="100" />
|
||||
</SequenceCard>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
150
src/app/features/call/CallView.tsx
Normal file
150
src/app/features/call/CallView.tsx
Normal file
@@ -0,0 +1,150 @@
|
||||
import React, { RefObject, useRef } from 'react';
|
||||
import { Badge, Box, color, Header, Scroll, Text, toRem } from 'folds';
|
||||
import { useCallEmbed, useCallJoined, useCallEmbedPlacementSync } from '../../hooks/useCallEmbed';
|
||||
import { ContainerColor } from '../../styles/ContainerColor.css';
|
||||
import { PrescreenControls } from './PrescreenControls';
|
||||
import { usePowerLevelsContext } from '../../hooks/usePowerLevels';
|
||||
import { useRoom } from '../../hooks/useRoom';
|
||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { StateEvent } from '../../../types/matrix/room';
|
||||
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
||||
import { CallMemberRenderer } from './CallMemberCard';
|
||||
import * as css from './styles.css';
|
||||
import { CallControls } from './CallControls';
|
||||
import { useLivekitSupport } from '../../hooks/useLivekitSupport';
|
||||
|
||||
function LivekitServerMissingMessage() {
|
||||
return (
|
||||
<Text style={{ margin: 'auto', color: color.Critical.Main }} size="L400" align="Center">
|
||||
Your homeserver does not support calling. But you can still join call started by others.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function JoinMessage({
|
||||
hasParticipant,
|
||||
livekitSupported,
|
||||
}: {
|
||||
hasParticipant?: boolean;
|
||||
livekitSupported?: boolean;
|
||||
}) {
|
||||
if (hasParticipant) return null;
|
||||
|
||||
if (livekitSupported === false) {
|
||||
return <LivekitServerMissingMessage />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Text style={{ margin: 'auto' }} size="L400" align="Center">
|
||||
Voice chat’s empty — Be the first to hop in!
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function NoPermissionMessage() {
|
||||
return (
|
||||
<Text style={{ margin: 'auto' }} size="L400" align="Center">
|
||||
You don't have permission to join!
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function AlreadyInCallMessage() {
|
||||
return (
|
||||
<Text style={{ margin: 'auto', color: color.Warning.Main }} size="L400" align="Center">
|
||||
Already in another call — End the current call to join!
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function CallPrescreen() {
|
||||
const mx = useMatrixClient();
|
||||
const room = useRoom();
|
||||
const livekitSupported = useLivekitSupport();
|
||||
|
||||
const powerLevels = usePowerLevelsContext();
|
||||
const creators = useRoomCreators(room);
|
||||
|
||||
const permissions = useRoomPermissions(creators, powerLevels);
|
||||
const hasPermission = permissions.event(StateEvent.GroupCallMemberPrefix, mx.getSafeUserId());
|
||||
|
||||
const callSession = useCallSession(room);
|
||||
const callMembers = useCallMembers(room, callSession);
|
||||
const hasParticipant = callMembers.length > 0;
|
||||
|
||||
const callEmbed = useCallEmbed();
|
||||
const inOtherCall = callEmbed && callEmbed.roomId !== room.roomId;
|
||||
|
||||
const canJoin = hasPermission && (livekitSupported || hasParticipant);
|
||||
|
||||
return (
|
||||
<Scroll variant="Surface" hideTrack>
|
||||
<Box className={css.CallViewContent} alignItems="Center" justifyContent="Center">
|
||||
<Box style={{ maxWidth: toRem(382), width: '100%' }} direction="Column" gap="100">
|
||||
{hasParticipant && (
|
||||
<Header size="300">
|
||||
<Box grow="Yes" alignItems="Center">
|
||||
<Text size="L400">Participant</Text>
|
||||
</Box>
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Text as="span" size="L400" truncate>
|
||||
{callMembers.length} Live
|
||||
</Text>
|
||||
</Badge>
|
||||
</Header>
|
||||
)}
|
||||
<CallMemberRenderer members={callMembers} />
|
||||
<PrescreenControls canJoin={canJoin} />
|
||||
<Box className={css.PrescreenMessage} alignItems="Center">
|
||||
{!inOtherCall &&
|
||||
(hasPermission ? (
|
||||
<JoinMessage hasParticipant={hasParticipant} livekitSupported={livekitSupported} />
|
||||
) : (
|
||||
<NoPermissionMessage />
|
||||
))}
|
||||
{inOtherCall && <AlreadyInCallMessage />}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
</Scroll>
|
||||
);
|
||||
}
|
||||
|
||||
type CallJoinedProps = {
|
||||
containerRef: RefObject<HTMLDivElement>;
|
||||
joined: boolean;
|
||||
};
|
||||
function CallJoined({ joined, containerRef }: CallJoinedProps) {
|
||||
const callEmbed = useCallEmbed();
|
||||
|
||||
return (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Box grow="Yes" ref={containerRef} />
|
||||
{callEmbed && joined && <CallControls callEmbed={callEmbed} />}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
export function CallView() {
|
||||
const room = useRoom();
|
||||
const callContainerRef = useRef<HTMLDivElement>(null);
|
||||
useCallEmbedPlacementSync(callContainerRef);
|
||||
|
||||
const callEmbed = useCallEmbed();
|
||||
const callJoined = useCallJoined(callEmbed);
|
||||
|
||||
const currentJoined = callEmbed?.roomId === room.roomId && callJoined;
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={ContainerColor({ variant: 'Surface' })}
|
||||
style={{ minWidth: toRem(280) }}
|
||||
grow="Yes"
|
||||
>
|
||||
{!currentJoined && <CallPrescreen />}
|
||||
<CallJoined joined={currentJoined} containerRef={callContainerRef} />
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
177
src/app/features/call/Controls.tsx
Normal file
177
src/app/features/call/Controls.tsx
Normal file
@@ -0,0 +1,177 @@
|
||||
import React from 'react';
|
||||
import { Icon, IconButton, Icons, Line, Text, Tooltip, TooltipProvider } from 'folds';
|
||||
import { useAtom } from 'jotai';
|
||||
import * as css from './styles.css';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
|
||||
export function ControlDivider() {
|
||||
return (
|
||||
<Line variant="SurfaceVariant" size="300" direction="Vertical" className={css.ControlDivider} />
|
||||
);
|
||||
}
|
||||
|
||||
type MicrophoneButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
};
|
||||
export function MicrophoneButton({ enabled, onToggle }: MicrophoneButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Turn Off Microphone' : 'Turn On Microphone'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Surface' : 'Warning'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
>
|
||||
<Icon size="400" src={enabled ? Icons.Mic : Icons.MicMute} filled={!enabled} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type SoundButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
};
|
||||
export function SoundButton({ enabled, onToggle }: SoundButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Turn Off Sound' : 'Turn On Sound'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Surface' : 'Warning'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
>
|
||||
<Icon
|
||||
size="400"
|
||||
src={enabled ? Icons.Headphone : Icons.HeadphoneMute}
|
||||
filled={!enabled}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type VideoButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
};
|
||||
export function VideoButton({ enabled, onToggle }: VideoButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Stop Camera' : 'Start Camera'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
>
|
||||
<Icon
|
||||
size="400"
|
||||
src={enabled ? Icons.VideoCamera : Icons.VideoCameraMute}
|
||||
filled={enabled}
|
||||
/>
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
type ScreenShareButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
};
|
||||
export function ScreenShareButton({ enabled, onToggle }: ScreenShareButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Stop Screenshare' : 'Start Screenshare'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
>
|
||||
<Icon size="400" src={Icons.ScreenShare} filled={enabled} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChatButton() {
|
||||
const [chat, setChat] = useAtom(callChatAtom);
|
||||
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{chat ? 'Close Chat' : 'Open Chat'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={chat ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => setChat(!chat)}
|
||||
outlined
|
||||
>
|
||||
<Icon size="400" src={Icons.Message} filled={chat} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
67
src/app/features/call/PrescreenControls.tsx
Normal file
67
src/app/features/call/PrescreenControls.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
import React from 'react';
|
||||
import { Box, Button, Icon, Icons, Spinner, Text } from 'folds';
|
||||
import { SequenceCard } from '../../components/sequence-card';
|
||||
import * as css from './styles.css';
|
||||
import { ChatButton, ControlDivider, MicrophoneButton, SoundButton, VideoButton } from './Controls';
|
||||
import { useIsDirectRoom, useRoom } from '../../hooks/useRoom';
|
||||
import { useCallEmbed, useCallJoined, useCallStart } from '../../hooks/useCallEmbed';
|
||||
import { useCallPreferences } from '../../state/hooks/callPreferences';
|
||||
|
||||
type PrescreenControlsProps = {
|
||||
canJoin?: boolean;
|
||||
};
|
||||
export function PrescreenControls({ canJoin }: PrescreenControlsProps) {
|
||||
const room = useRoom();
|
||||
const callEmbed = useCallEmbed();
|
||||
const callJoined = useCallJoined(callEmbed);
|
||||
const direct = useIsDirectRoom();
|
||||
|
||||
const inOtherCall = callEmbed && callEmbed.roomId !== room.roomId;
|
||||
|
||||
const startCall = useCallStart(direct);
|
||||
const joining = callEmbed?.roomId === room.roomId && !callJoined;
|
||||
|
||||
const disabled = inOtherCall || !canJoin;
|
||||
|
||||
const { microphone, video, sound, toggleMicrophone, toggleVideo, toggleSound } =
|
||||
useCallPreferences();
|
||||
|
||||
return (
|
||||
<SequenceCard
|
||||
className={css.ControlCard}
|
||||
variant="SurfaceVariant"
|
||||
gap="400"
|
||||
radii="500"
|
||||
alignItems="Center"
|
||||
justifyContent="SpaceBetween"
|
||||
wrap="Wrap"
|
||||
>
|
||||
<Box shrink="No" alignItems="Inherit" justifyContent="SpaceBetween" gap="200">
|
||||
<MicrophoneButton enabled={microphone} onToggle={toggleMicrophone} />
|
||||
<SoundButton enabled={sound} onToggle={toggleSound} />
|
||||
</Box>
|
||||
<ControlDivider />
|
||||
<Box shrink="No" alignItems="Inherit" justifyContent="SpaceBetween" gap="200">
|
||||
<VideoButton enabled={video} onToggle={toggleVideo} />
|
||||
<ChatButton />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Button
|
||||
variant={disabled ? 'Secondary' : 'Success'}
|
||||
fill={disabled ? 'Soft' : 'Solid'}
|
||||
onClick={() => startCall(room, { microphone, video, sound })}
|
||||
disabled={disabled || joining}
|
||||
before={
|
||||
joining ? (
|
||||
<Spinner variant="Success" fill="Solid" size="200" />
|
||||
) : (
|
||||
<Icon src={Icons.Phone} size="200" filled />
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text size="B400">Join</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</SequenceCard>
|
||||
);
|
||||
}
|
||||
28
src/app/features/call/styles.css.ts
Normal file
28
src/app/features/call/styles.css.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
|
||||
export const CallViewContent = style({
|
||||
padding: config.space.S400,
|
||||
paddingRight: 0,
|
||||
minHeight: '100%',
|
||||
});
|
||||
|
||||
export const ControlCard = style({
|
||||
padding: config.space.S300,
|
||||
});
|
||||
|
||||
export const ControlDivider = style({
|
||||
height: toRem(24),
|
||||
});
|
||||
|
||||
export const CallMemberCard = style({
|
||||
padding: config.space.S300,
|
||||
});
|
||||
|
||||
export const CallControlContainer = style({
|
||||
padding: config.space.S400,
|
||||
});
|
||||
|
||||
export const PrescreenMessage = style({
|
||||
padding: config.space.S200,
|
||||
});
|
||||
@@ -6,9 +6,8 @@ import { useAtomValue } from 'jotai';
|
||||
import {
|
||||
ExtendedJoinRules,
|
||||
JoinRulesSwitcher,
|
||||
useRoomJoinRuleIcon,
|
||||
useJoinRuleIcons,
|
||||
useRoomJoinRuleLabel,
|
||||
useSpaceJoinRuleIcon,
|
||||
} from '../../../components/JoinRulesSwitcher';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SequenceCardStyle } from '../../room-settings/styles.css';
|
||||
@@ -75,8 +74,7 @@ export function RoomJoinRules({ permissions }: RoomJoinRulesProps) {
|
||||
return r;
|
||||
}, [allowKnockRestricted, allowRestricted, allowKnock, space]);
|
||||
|
||||
const icons = useRoomJoinRuleIcon();
|
||||
const spaceIcons = useSpaceJoinRuleIcon();
|
||||
const icons = useJoinRuleIcons(room.getType());
|
||||
const labels = useRoomJoinRuleLabel();
|
||||
|
||||
const [submitState, submit] = useAsyncCallback(
|
||||
@@ -137,7 +135,7 @@ export function RoomJoinRules({ permissions }: RoomJoinRulesProps) {
|
||||
}
|
||||
after={
|
||||
<JoinRulesSwitcher
|
||||
icons={room.isSpaceRoom() ? spaceIcons : icons}
|
||||
icons={icons}
|
||||
labels={labels}
|
||||
rules={joinRules}
|
||||
value={rule}
|
||||
|
||||
@@ -199,7 +199,7 @@ export function RoomProfileEdit({
|
||||
alt={name}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
space={room.isSpaceRoom()}
|
||||
roomType={room.getType()}
|
||||
size="400"
|
||||
joinRule={joinRule?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
@@ -342,7 +342,7 @@ export function RoomProfile({ permissions }: RoomProfileProps) {
|
||||
alt={name}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
space={room.isSpaceRoom()}
|
||||
roomType={room.getType()}
|
||||
size="400"
|
||||
joinRule={joinRule?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { FormEventHandler, useCallback, useEffect, useState } from 'react';
|
||||
import { MatrixError, Room } from 'matrix-js-sdk';
|
||||
import { MatrixError, Room, JoinRule } from 'matrix-js-sdk';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
@@ -33,24 +33,43 @@ import {
|
||||
createRoom,
|
||||
CreateRoomAliasInput,
|
||||
CreateRoomData,
|
||||
CreateRoomKind,
|
||||
CreateRoomKindSelector,
|
||||
CreateRoomAccess,
|
||||
CreateRoomAccessSelector,
|
||||
RoomVersionSelector,
|
||||
useAdditionalCreators,
|
||||
CreateRoomType,
|
||||
} from '../../components/create-room';
|
||||
import { RoomType } from '../../../types/matrix/room';
|
||||
import { CreateRoomTypeSelector } from '../../components/create-room/CreateRoomTypeSelector';
|
||||
import { getRoomIconSrc } from '../../utils/room';
|
||||
|
||||
const getCreateRoomKindToIcon = (kind: CreateRoomKind) => {
|
||||
if (kind === CreateRoomKind.Private) return Icons.HashLock;
|
||||
if (kind === CreateRoomKind.Restricted) return Icons.Hash;
|
||||
return Icons.HashGlobe;
|
||||
const getCreateRoomAccessToIcon = (access: CreateRoomAccess, type?: CreateRoomType) => {
|
||||
const isVoiceRoom = type === CreateRoomType.VoiceRoom;
|
||||
|
||||
let joinRule: JoinRule = JoinRule.Public;
|
||||
if (access === CreateRoomAccess.Restricted) joinRule = JoinRule.Restricted;
|
||||
if (access === CreateRoomAccess.Private) joinRule = JoinRule.Knock;
|
||||
|
||||
return getRoomIconSrc(Icons, isVoiceRoom ? RoomType.Call : undefined, joinRule);
|
||||
};
|
||||
|
||||
const getCreateRoomTypeToIcon = (type: CreateRoomType) => {
|
||||
if (type === CreateRoomType.VoiceRoom) return Icons.VolumeHigh;
|
||||
return Icons.Hash;
|
||||
};
|
||||
|
||||
type CreateRoomFormProps = {
|
||||
defaultKind?: CreateRoomKind;
|
||||
defaultAccess?: CreateRoomAccess;
|
||||
defaultType?: CreateRoomType;
|
||||
space?: Room;
|
||||
onCreate?: (roomId: string) => void;
|
||||
};
|
||||
export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormProps) {
|
||||
export function CreateRoomForm({
|
||||
defaultAccess,
|
||||
defaultType,
|
||||
space,
|
||||
onCreate,
|
||||
}: CreateRoomFormProps) {
|
||||
const mx = useMatrixClient();
|
||||
const alive = useAlive();
|
||||
|
||||
@@ -64,8 +83,9 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
|
||||
const allowRestricted = space && restrictedSupported(selectedRoomVersion);
|
||||
|
||||
const [kind, setKind] = useState(
|
||||
defaultKind ?? allowRestricted ? CreateRoomKind.Restricted : CreateRoomKind.Private
|
||||
const [type, setType] = useState(defaultType ?? CreateRoomType.TextRoom);
|
||||
const [access, setAccess] = useState(
|
||||
defaultAccess ?? (allowRestricted ? CreateRoomAccess.Restricted : CreateRoomAccess.Private)
|
||||
);
|
||||
const allowAdditionalCreators = creatorsSupported(selectedRoomVersion);
|
||||
const { additionalCreators, addAdditionalCreator, removeAdditionalCreator } =
|
||||
@@ -75,13 +95,13 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
const [knock, setKnock] = useState(false);
|
||||
const [advance, setAdvance] = useState(false);
|
||||
|
||||
const allowKnock = kind === CreateRoomKind.Private && knockSupported(selectedRoomVersion);
|
||||
const allowKnock = access === CreateRoomAccess.Private && knockSupported(selectedRoomVersion);
|
||||
const allowKnockRestricted =
|
||||
kind === CreateRoomKind.Restricted && knockRestrictedSupported(selectedRoomVersion);
|
||||
access === CreateRoomAccess.Restricted && knockRestrictedSupported(selectedRoomVersion);
|
||||
|
||||
const handleRoomVersionChange = (version: string) => {
|
||||
if (!restrictedSupported(version)) {
|
||||
setKind(CreateRoomKind.Private);
|
||||
setAccess(CreateRoomAccess.Private);
|
||||
}
|
||||
selectRoomVersion(version);
|
||||
};
|
||||
@@ -107,19 +127,23 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
aliasInput && aliasInput.value ? replaceSpaceWithDash(aliasInput.value) : undefined;
|
||||
|
||||
if (!roomName) return;
|
||||
const publicRoom = kind === CreateRoomKind.Public;
|
||||
const publicRoom = access === CreateRoomAccess.Public;
|
||||
let roomKnock = false;
|
||||
if (allowKnock && kind === CreateRoomKind.Private) {
|
||||
if (allowKnock && access === CreateRoomAccess.Private) {
|
||||
roomKnock = knock;
|
||||
}
|
||||
if (allowKnockRestricted && kind === CreateRoomKind.Restricted) {
|
||||
if (allowKnockRestricted && access === CreateRoomAccess.Restricted) {
|
||||
roomKnock = knock;
|
||||
}
|
||||
|
||||
let roomType: RoomType | undefined;
|
||||
if (type === CreateRoomType.VoiceRoom) roomType = RoomType.Call;
|
||||
|
||||
create({
|
||||
version: selectedRoomVersion,
|
||||
type: roomType,
|
||||
parent: space,
|
||||
kind,
|
||||
access,
|
||||
name: roomName,
|
||||
topic: roomTopic || undefined,
|
||||
aliasLocalPart: publicRoom ? aliasLocalPart : undefined,
|
||||
@@ -136,21 +160,32 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
|
||||
return (
|
||||
<Box as="form" onSubmit={handleSubmit} grow="Yes" direction="Column" gap="500">
|
||||
{!space && (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Type</Text>
|
||||
<CreateRoomTypeSelector
|
||||
value={type}
|
||||
onSelect={setType}
|
||||
disabled={disabled}
|
||||
getIcon={getCreateRoomTypeToIcon}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Access</Text>
|
||||
<CreateRoomKindSelector
|
||||
value={kind}
|
||||
onSelect={setKind}
|
||||
<CreateRoomAccessSelector
|
||||
value={access}
|
||||
onSelect={setAccess}
|
||||
canRestrict={allowRestricted}
|
||||
disabled={disabled}
|
||||
getIcon={getCreateRoomKindToIcon}
|
||||
getIcon={(roomAccess) => getCreateRoomAccessToIcon(roomAccess, type)}
|
||||
/>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<Text size="L400">Name</Text>
|
||||
<Input
|
||||
required
|
||||
before={<Icon size="100" src={getCreateRoomKindToIcon(kind)} />}
|
||||
before={<Icon size="100" src={getCreateRoomAccessToIcon(access, type)} />}
|
||||
name="nameInput"
|
||||
autoFocus
|
||||
size="500"
|
||||
@@ -171,7 +206,7 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{kind === CreateRoomKind.Public && <CreateRoomAliasInput disabled={disabled} />}
|
||||
{access === CreateRoomAccess.Public && <CreateRoomAliasInput disabled={disabled} />}
|
||||
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<Box gap="200" alignItems="End">
|
||||
@@ -201,7 +236,7 @@ export function CreateRoomForm({ defaultKind, space, onCreate }: CreateRoomFormP
|
||||
/>
|
||||
</SequenceCard>
|
||||
)}
|
||||
{kind !== CreateRoomKind.Public && (
|
||||
{access !== CreateRoomAccess.Public && (
|
||||
<>
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
|
||||
@@ -23,12 +23,13 @@ import {
|
||||
} from '../../state/hooks/createRoomModal';
|
||||
import { CreateRoomModalState } from '../../state/createRoomModal';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { CreateRoomType } from '../../components/create-room/types';
|
||||
|
||||
type CreateRoomModalProps = {
|
||||
state: CreateRoomModalState;
|
||||
};
|
||||
function CreateRoomModal({ state }: CreateRoomModalProps) {
|
||||
const { spaceId } = state;
|
||||
const { spaceId, type } = state;
|
||||
const closeDialog = useCloseCreateRoomModal();
|
||||
|
||||
const allJoinedRooms = useAllJoinedRoomsSet();
|
||||
@@ -57,7 +58,9 @@ function CreateRoomModal({ state }: CreateRoomModalProps) {
|
||||
}}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">New Room</Text>
|
||||
<Text size="H4">
|
||||
{type === CreateRoomType.VoiceRoom ? 'New Voice Room' : 'New Chat Room'}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No">
|
||||
<IconButton size="300" radii="300" onClick={closeDialog}>
|
||||
@@ -74,7 +77,7 @@ function CreateRoomModal({ state }: CreateRoomModalProps) {
|
||||
direction="Column"
|
||||
gap="500"
|
||||
>
|
||||
<CreateRoomForm space={space} onCreate={closeDialog} />
|
||||
<CreateRoomForm space={space} onCreate={closeDialog} defaultType={type} />
|
||||
</Box>
|
||||
</Scroll>
|
||||
</Box>
|
||||
|
||||
@@ -33,25 +33,25 @@ import {
|
||||
createRoom,
|
||||
CreateRoomAliasInput,
|
||||
CreateRoomData,
|
||||
CreateRoomKind,
|
||||
CreateRoomKindSelector,
|
||||
CreateRoomAccess,
|
||||
CreateRoomAccessSelector,
|
||||
RoomVersionSelector,
|
||||
useAdditionalCreators,
|
||||
} from '../../components/create-room';
|
||||
import { RoomType } from '../../../types/matrix/room';
|
||||
|
||||
const getCreateSpaceKindToIcon = (kind: CreateRoomKind) => {
|
||||
if (kind === CreateRoomKind.Private) return Icons.SpaceLock;
|
||||
if (kind === CreateRoomKind.Restricted) return Icons.Space;
|
||||
const getCreateSpaceAccessToIcon = (access: CreateRoomAccess) => {
|
||||
if (access === CreateRoomAccess.Private) return Icons.SpaceLock;
|
||||
if (access === CreateRoomAccess.Restricted) return Icons.Space;
|
||||
return Icons.SpaceGlobe;
|
||||
};
|
||||
|
||||
type CreateSpaceFormProps = {
|
||||
defaultKind?: CreateRoomKind;
|
||||
defaultAccess?: CreateRoomAccess;
|
||||
space?: Room;
|
||||
onCreate?: (roomId: string) => void;
|
||||
};
|
||||
export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFormProps) {
|
||||
export function CreateSpaceForm({ defaultAccess, space, onCreate }: CreateSpaceFormProps) {
|
||||
const mx = useMatrixClient();
|
||||
const alive = useAlive();
|
||||
|
||||
@@ -65,8 +65,8 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
|
||||
const allowRestricted = space && restrictedSupported(selectedRoomVersion);
|
||||
|
||||
const [kind, setKind] = useState(
|
||||
defaultKind ?? allowRestricted ? CreateRoomKind.Restricted : CreateRoomKind.Private
|
||||
const [access, setAccess] = useState(
|
||||
defaultAccess ?? (allowRestricted ? CreateRoomAccess.Restricted : CreateRoomAccess.Private)
|
||||
);
|
||||
|
||||
const allowAdditionalCreators = creatorsSupported(selectedRoomVersion);
|
||||
@@ -76,13 +76,13 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
const [knock, setKnock] = useState(false);
|
||||
const [advance, setAdvance] = useState(false);
|
||||
|
||||
const allowKnock = kind === CreateRoomKind.Private && knockSupported(selectedRoomVersion);
|
||||
const allowKnock = access === CreateRoomAccess.Private && knockSupported(selectedRoomVersion);
|
||||
const allowKnockRestricted =
|
||||
kind === CreateRoomKind.Restricted && knockRestrictedSupported(selectedRoomVersion);
|
||||
access === CreateRoomAccess.Restricted && knockRestrictedSupported(selectedRoomVersion);
|
||||
|
||||
const handleRoomVersionChange = (version: string) => {
|
||||
if (!restrictedSupported(version)) {
|
||||
setKind(CreateRoomKind.Private);
|
||||
setAccess(CreateRoomAccess.Private);
|
||||
}
|
||||
selectRoomVersion(version);
|
||||
};
|
||||
@@ -108,12 +108,12 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
aliasInput && aliasInput.value ? replaceSpaceWithDash(aliasInput.value) : undefined;
|
||||
|
||||
if (!roomName) return;
|
||||
const publicRoom = kind === CreateRoomKind.Public;
|
||||
const publicRoom = access === CreateRoomAccess.Public;
|
||||
let roomKnock = false;
|
||||
if (allowKnock && kind === CreateRoomKind.Private) {
|
||||
if (allowKnock && access === CreateRoomAccess.Private) {
|
||||
roomKnock = knock;
|
||||
}
|
||||
if (allowKnockRestricted && kind === CreateRoomKind.Restricted) {
|
||||
if (allowKnockRestricted && access === CreateRoomAccess.Restricted) {
|
||||
roomKnock = knock;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
version: selectedRoomVersion,
|
||||
type: RoomType.Space,
|
||||
parent: space,
|
||||
kind,
|
||||
access,
|
||||
name: roomName,
|
||||
topic: roomTopic || undefined,
|
||||
aliasLocalPart: publicRoom ? aliasLocalPart : undefined,
|
||||
@@ -139,19 +139,19 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
<Box as="form" onSubmit={handleSubmit} grow="Yes" direction="Column" gap="500">
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Access</Text>
|
||||
<CreateRoomKindSelector
|
||||
value={kind}
|
||||
onSelect={setKind}
|
||||
<CreateRoomAccessSelector
|
||||
value={access}
|
||||
onSelect={setAccess}
|
||||
canRestrict={allowRestricted}
|
||||
disabled={disabled}
|
||||
getIcon={getCreateSpaceKindToIcon}
|
||||
getIcon={getCreateSpaceAccessToIcon}
|
||||
/>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<Text size="L400">Name</Text>
|
||||
<Input
|
||||
required
|
||||
before={<Icon size="100" src={getCreateSpaceKindToIcon(kind)} />}
|
||||
before={<Icon size="100" src={getCreateSpaceAccessToIcon(access)} />}
|
||||
name="nameInput"
|
||||
autoFocus
|
||||
size="500"
|
||||
@@ -172,7 +172,7 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
/>
|
||||
</Box>
|
||||
|
||||
{kind === CreateRoomKind.Public && <CreateRoomAliasInput disabled={disabled} />}
|
||||
{access === CreateRoomAccess.Public && <CreateRoomAliasInput disabled={disabled} />}
|
||||
|
||||
<Box shrink="No" direction="Column" gap="100">
|
||||
<Box gap="200" alignItems="End">
|
||||
@@ -202,7 +202,7 @@ export function CreateSpaceForm({ defaultKind, space, onCreate }: CreateSpaceFor
|
||||
/>
|
||||
</SequenceCard>
|
||||
)}
|
||||
{kind !== CreateRoomKind.Public && advance && (allowKnock || allowKnockRestricted) && (
|
||||
{access !== CreateRoomAccess.Public && advance && (allowKnock || allowKnockRestricted) && (
|
||||
<SequenceCard
|
||||
style={{ padding: config.space.S300 }}
|
||||
variant="SurfaceVariant"
|
||||
|
||||
@@ -165,7 +165,7 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) {
|
||||
<Box shrink="No">
|
||||
<BackRouteHandler>
|
||||
{(onBack) => (
|
||||
<IconButton onClick={onBack}>
|
||||
<IconButton fill="None" onClick={onBack}>
|
||||
<Icon src={Icons.ArrowLeft} />
|
||||
</IconButton>
|
||||
)}
|
||||
@@ -218,7 +218,11 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) {
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} onClick={() => setPeopleDrawer((drawer) => !drawer)}>
|
||||
<IconButton
|
||||
fill="None"
|
||||
ref={triggerRef}
|
||||
onClick={() => setPeopleDrawer((drawer) => !drawer)}
|
||||
>
|
||||
<Icon size="400" src={Icons.User} />
|
||||
</IconButton>
|
||||
)}
|
||||
@@ -235,7 +239,12 @@ export function LobbyHeader({ showProfile, powerLevels }: LobbyHeaderProps) {
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton onClick={handleOpenMenu} ref={triggerRef} aria-pressed={!!menuAnchor}>
|
||||
<IconButton
|
||||
fill="None"
|
||||
onClick={handleOpenMenu}
|
||||
ref={triggerRef}
|
||||
aria-pressed={!!menuAnchor}
|
||||
>
|
||||
<Icon size="400" src={Icons.VerticalDots} filled={!!menuAnchor} />
|
||||
</IconButton>
|
||||
)}
|
||||
|
||||
@@ -175,6 +175,7 @@ function RoomProfileError({ roomId, suggested, inaccessibleRoom, via }: RoomProf
|
||||
|
||||
type RoomProfileProps = {
|
||||
roomId: string;
|
||||
roomType?: string;
|
||||
name: string;
|
||||
topic?: string;
|
||||
avatarUrl?: string;
|
||||
@@ -185,6 +186,7 @@ type RoomProfileProps = {
|
||||
};
|
||||
function RoomProfile({
|
||||
roomId,
|
||||
roomType,
|
||||
name,
|
||||
topic,
|
||||
avatarUrl,
|
||||
@@ -200,9 +202,7 @@ function RoomProfile({
|
||||
roomId={roomId}
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => (
|
||||
<RoomIcon size="300" joinRule={joinRule ?? JoinRule.Restricted} filled />
|
||||
)}
|
||||
renderFallback={() => <RoomIcon size="300" joinRule={joinRule} roomType={roomType} />}
|
||||
/>
|
||||
</Avatar>
|
||||
<Box grow="Yes" direction="Column">
|
||||
@@ -338,6 +338,7 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
|
||||
{(localSummary) => (
|
||||
<RoomProfile
|
||||
roomId={roomId}
|
||||
roomType={localSummary.roomType}
|
||||
name={localSummary.name}
|
||||
topic={localSummary.topic}
|
||||
avatarUrl={
|
||||
@@ -396,6 +397,7 @@ export const RoomItemCard = as<'div', RoomItemCardProps>(
|
||||
{summary && (
|
||||
<RoomProfile
|
||||
roomId={roomId}
|
||||
roomType={summary.room_type}
|
||||
name={summary.name || summary.canonical_alias || roomId}
|
||||
topic={summary.topic}
|
||||
avatarUrl={
|
||||
|
||||
@@ -36,6 +36,8 @@ import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useOpenCreateRoomModal } from '../../state/hooks/createRoomModal';
|
||||
import { useOpenCreateSpaceModal } from '../../state/hooks/createSpaceModal';
|
||||
import { AddExistingModal } from '../add-existing';
|
||||
import { CreateRoomType } from '../../components/create-room/types';
|
||||
import { BetaNoticeBadge } from '../../components/BetaNoticeBadge';
|
||||
|
||||
function SpaceProfileLoading() {
|
||||
return (
|
||||
@@ -249,8 +251,8 @@ function AddRoomButton({ item }: { item: HierarchyItem }) {
|
||||
setCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleCreateRoom = () => {
|
||||
openCreateRoomModal(item.roomId);
|
||||
const handleCreateRoom = (type?: CreateRoomType) => {
|
||||
openCreateRoomModal(item.roomId, type);
|
||||
setCords(undefined);
|
||||
};
|
||||
|
||||
@@ -281,9 +283,19 @@ function AddRoomButton({ item }: { item: HierarchyItem }) {
|
||||
radii="300"
|
||||
variant="Primary"
|
||||
fill="None"
|
||||
onClick={handleCreateRoom}
|
||||
onClick={() => handleCreateRoom(CreateRoomType.TextRoom)}
|
||||
>
|
||||
<Text size="T300">New Room</Text>
|
||||
<Text size="T300">Chat Room</Text>
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
size="300"
|
||||
radii="300"
|
||||
variant="Primary"
|
||||
fill="None"
|
||||
onClick={() => handleCreateRoom(CreateRoomType.VoiceRoom)}
|
||||
after={<BetaNoticeBadge />}
|
||||
>
|
||||
<Text size="T300">Voice Room</Text>
|
||||
</MenuItem>
|
||||
<MenuItem size="300" radii="300" fill="None" onClick={handleAddExisting}>
|
||||
<Text size="T300">Existing Room</Text>
|
||||
|
||||
@@ -29,7 +29,7 @@ import { SearchOrderBy } from 'matrix-js-sdk';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useVirtualizer } from '@tanstack/react-virtual';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { joinRuleToIconSrc } from '../../utils/room';
|
||||
import { getRoomIconSrc } from '../../utils/room';
|
||||
import { factoryRoomIdByAtoZ } from '../../utils/sort';
|
||||
import {
|
||||
SearchItemStrGetter,
|
||||
@@ -274,9 +274,7 @@ function SelectRoomButton({ roomList, selectedRooms, onChange }: SelectRoomButto
|
||||
before={
|
||||
<Icon
|
||||
size="50"
|
||||
src={
|
||||
joinRuleToIconSrc(Icons, room.getJoinRule(), false) ?? Icons.Hash
|
||||
}
|
||||
src={getRoomIconSrc(Icons, room.getType(), room.getJoinRule())}
|
||||
/>
|
||||
}
|
||||
>
|
||||
@@ -392,10 +390,7 @@ export function SearchFilters({
|
||||
onClick={() => onSelectedRoomsChange(selectedRooms.filter((rId) => rId !== roomId))}
|
||||
radii="Pill"
|
||||
before={
|
||||
<Icon
|
||||
size="50"
|
||||
src={joinRuleToIconSrc(Icons, room.getJoinRule(), false) ?? Icons.Hash}
|
||||
/>
|
||||
<Icon size="50" src={getRoomIconSrc(Icons, room.getType(), room.getJoinRule())} />
|
||||
}
|
||||
after={<Icon size="50" src={Icons.Cross} />}
|
||||
>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import { Avatar, Box, Chip, Header, Icon, Icons, Text, config } from 'folds';
|
||||
import { Opts as LinkifyOpts } from 'linkifyjs';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useAllowExternalImages } from '../../../owl/hooks/useAllowExternalImages';
|
||||
import {
|
||||
factoryRenderLinkifyWithMention,
|
||||
getReactCustomHtmlParser,
|
||||
@@ -76,6 +77,7 @@ export function SearchResultGroup({
|
||||
}: SearchResultGroupProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const allowExternalImages = useAllowExternalImages(mx, room);
|
||||
const highlightRegex = useMemo(() => makeHighlightRegex(highlights), [highlights]);
|
||||
|
||||
const powerLevels = usePowerLevels(room);
|
||||
@@ -106,6 +108,7 @@ export function SearchResultGroup({
|
||||
linkifyOpts,
|
||||
highlightRegex,
|
||||
useAuthentication,
|
||||
allowExternalImages,
|
||||
handleSpoilerClick: spoilerClickHandler,
|
||||
handleMentionClick: mentionClickHandler,
|
||||
}),
|
||||
@@ -117,6 +120,7 @@ export function SearchResultGroup({
|
||||
mentionClickHandler,
|
||||
spoilerClickHandler,
|
||||
useAuthentication,
|
||||
allowExternalImages,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -203,7 +207,12 @@ export function SearchResultGroup({
|
||||
src={getRoomAvatarUrl(mx, room, 96, useAuthentication)}
|
||||
alt={room.name}
|
||||
renderFallback={() => (
|
||||
<RoomIcon size="50" joinRule={room.getJoinRule() ?? JoinRule.Restricted} filled />
|
||||
<RoomIcon
|
||||
size="50"
|
||||
roomType={room.getType()}
|
||||
joinRule={room.getJoinRule() ?? JoinRule.Restricted}
|
||||
filled
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from 'folds';
|
||||
import { useFocusWithin, useHover } from 'react-aria';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useAtom, useAtomValue } from 'jotai';
|
||||
import { NavItem, NavItemContent, NavItemOptions, NavLink } from '../../components/nav';
|
||||
import { UnreadBadge, UnreadBadgeCenter } from '../../components/unread-badge';
|
||||
import { RoomAvatar, RoomIcon } from '../../components/room-avatar';
|
||||
@@ -51,6 +52,13 @@ import { RoomNotificationModeSwitcher } from '../../components/RoomNotificationS
|
||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
||||
import { InviteUserPrompt } from '../../components/invite-user-prompt';
|
||||
import { useRoomName } from '../../hooks/useRoomMeta';
|
||||
import { useCallMembers, useCallSession } from '../../hooks/useCall';
|
||||
import { useCallEmbed, useCallStart } from '../../hooks/useCallEmbed';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
import { useCallPreferencesAtom } from '../../state/hooks/callPreferences';
|
||||
import { useAutoDiscoveryInfo } from '../../hooks/useAutoDiscoveryInfo';
|
||||
import { livekitSupport } from '../../hooks/useLivekitSupport';
|
||||
|
||||
type RoomNavItemMenuProps = {
|
||||
room: Room;
|
||||
@@ -209,6 +217,24 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||
}
|
||||
);
|
||||
|
||||
function CallChatToggle() {
|
||||
const [chat, setChat] = useAtom(callChatAtom);
|
||||
|
||||
return (
|
||||
<IconButton
|
||||
onClick={() => setChat(!chat)}
|
||||
aria-pressed={chat}
|
||||
aria-label="Toggle Chat"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="300"
|
||||
>
|
||||
<Icon size="50" src={Icons.Message} filled={chat} />
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
|
||||
type RoomNavItemProps = {
|
||||
room: Room;
|
||||
selected: boolean;
|
||||
@@ -236,6 +262,8 @@ export function RoomNavItem({
|
||||
(receipt) => receipt.userId !== mx.getUserId()
|
||||
);
|
||||
|
||||
const roomName = useRoomName(room);
|
||||
|
||||
const handleContextMenu: MouseEventHandler<HTMLElement> = (evt) => {
|
||||
evt.preventDefault();
|
||||
setMenuAnchor({
|
||||
@@ -251,6 +279,29 @@ export function RoomNavItem({
|
||||
};
|
||||
|
||||
const optionsVisible = hover || !!menuAnchor;
|
||||
const callSession = useCallSession(room);
|
||||
const callMembers = useCallMembers(room, callSession);
|
||||
const startCall = useCallStart(direct);
|
||||
const callEmbed = useCallEmbed();
|
||||
const callPref = useAtomValue(useCallPreferencesAtom());
|
||||
const autoDiscoveryInfo = useAutoDiscoveryInfo();
|
||||
|
||||
const handleStartCall: MouseEventHandler<HTMLAnchorElement> = (evt) => {
|
||||
// Do not join if no livekit support or call is not started by others
|
||||
if (!livekitSupport(autoDiscoveryInfo) && callMembers.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Do not join if already in call
|
||||
if (callEmbed) {
|
||||
return;
|
||||
}
|
||||
// Start call in second click
|
||||
if (selected) {
|
||||
evt.preventDefault();
|
||||
startCall(room, callPref);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<NavItem
|
||||
@@ -263,7 +314,7 @@ export function RoomNavItem({
|
||||
{...hoverProps}
|
||||
{...focusWithinProps}
|
||||
>
|
||||
<NavLink to={linkPath}>
|
||||
<NavLink to={linkPath} onClick={room.isCallRoom() ? handleStartCall : undefined}>
|
||||
<NavItemContent>
|
||||
<Box as="span" grow="Yes" alignItems="Center" gap="200">
|
||||
<Avatar size="200" radii="400">
|
||||
@@ -275,25 +326,28 @@ export function RoomNavItem({
|
||||
? getDirectRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
: getRoomAvatarUrl(mx, room, 96, useAuthentication)
|
||||
}
|
||||
alt={room.name}
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<Text as="span" size="H6">
|
||||
{nameInitials(room.name)}
|
||||
{nameInitials(roomName)}
|
||||
</Text>
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<RoomIcon
|
||||
style={{ opacity: unread ? config.opacity.P500 : config.opacity.P300 }}
|
||||
style={{
|
||||
opacity: unread ? config.opacity.P500 : config.opacity.P300,
|
||||
}}
|
||||
filled={selected}
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
<Box as="span" grow="Yes">
|
||||
<Text priority={unread ? '500' : '300'} as="span" size="Inherit" truncate>
|
||||
{room.name}
|
||||
{roomName}
|
||||
</Text>
|
||||
</Box>
|
||||
{!optionsVisible && !unread && !selected && typingMember.length > 0 && (
|
||||
@@ -307,14 +361,30 @@ export function RoomNavItem({
|
||||
</UnreadBadgeCenter>
|
||||
)}
|
||||
{!optionsVisible && notificationMode !== RoomNotificationMode.Unset && (
|
||||
<Icon size="50" src={getRoomNotificationModeIcon(notificationMode)} />
|
||||
<Icon
|
||||
size="50"
|
||||
src={getRoomNotificationModeIcon(notificationMode)}
|
||||
aria-label={notificationMode}
|
||||
/>
|
||||
)}
|
||||
{room.isCallRoom() && callMembers.length > 0 && (
|
||||
<Badge variant="Critical" fill="Solid" size="400">
|
||||
<Text as="span" size="L400" truncate>
|
||||
{callMembers.length} Live
|
||||
</Text>
|
||||
</Badge>
|
||||
)}
|
||||
</Box>
|
||||
</NavItemContent>
|
||||
</NavLink>
|
||||
{optionsVisible && (
|
||||
<NavItemOptions>
|
||||
{selected && (callEmbed?.roomId === room.roomId || room.isCallRoom()) && (
|
||||
<CallChatToggle />
|
||||
)}
|
||||
<PopOut
|
||||
id={`menu-${room.roomId}`}
|
||||
aria-expanded={!!menuAnchor}
|
||||
anchor={menuAnchor}
|
||||
offset={menuAnchor?.width === 0 ? 0 : undefined}
|
||||
alignOffset={menuAnchor?.width === 0 ? 0 : -5}
|
||||
@@ -343,6 +413,8 @@ export function RoomNavItem({
|
||||
<IconButton
|
||||
onClick={handleOpenMenu}
|
||||
aria-pressed={!!menuAnchor}
|
||||
aria-controls={`menu-${room.roomId}`}
|
||||
aria-label="More Options"
|
||||
variant="Background"
|
||||
fill="None"
|
||||
size="300"
|
||||
|
||||
@@ -104,6 +104,7 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) {
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
size="50"
|
||||
roomType={room.getType()}
|
||||
joinRule={joinRuleContent?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
/>
|
||||
|
||||
@@ -23,7 +23,7 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
||||
|
||||
const canEditPowers = permissions.stateEvent(StateEvent.PowerLevelTags, mx.getSafeUserId());
|
||||
const canEditPermissions = permissions.stateEvent(StateEvent.RoomPowerLevels, mx.getSafeUserId());
|
||||
const permissionGroups = usePermissionGroups();
|
||||
const permissionGroups = usePermissionGroups(room.isCallRoom());
|
||||
|
||||
const [powerEditor, setPowerEditor] = useState(false);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import { MessageEvent, StateEvent } from '../../../../types/matrix/room';
|
||||
import { PermissionGroup } from '../../common-settings/permissions';
|
||||
|
||||
export const usePermissionGroups = (): PermissionGroup[] => {
|
||||
export const usePermissionGroups = (isCallRoom: boolean): PermissionGroup[] => {
|
||||
const groups: PermissionGroup[] = useMemo(() => {
|
||||
const messagesGroup: PermissionGroup = {
|
||||
name: 'Messages',
|
||||
@@ -46,6 +46,19 @@ export const usePermissionGroups = (): PermissionGroup[] => {
|
||||
],
|
||||
};
|
||||
|
||||
const callSettingsGroup: PermissionGroup = {
|
||||
name: 'Calls',
|
||||
items: [
|
||||
{
|
||||
location: {
|
||||
state: true,
|
||||
key: StateEvent.GroupCallMemberPrefix,
|
||||
},
|
||||
name: 'Join Call',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const moderationGroup: PermissionGroup = {
|
||||
name: 'Moderation',
|
||||
items: [
|
||||
@@ -177,6 +190,13 @@ export const usePermissionGroups = (): PermissionGroup[] => {
|
||||
const otherSettingsGroup: PermissionGroup = {
|
||||
name: 'Other',
|
||||
items: [
|
||||
{
|
||||
location: {
|
||||
state: true,
|
||||
key: StateEvent.PoniesRoomEmotes,
|
||||
},
|
||||
name: 'Manage Emojis & Stickers',
|
||||
},
|
||||
{
|
||||
location: {
|
||||
state: true,
|
||||
@@ -196,12 +216,13 @@ export const usePermissionGroups = (): PermissionGroup[] => {
|
||||
|
||||
return [
|
||||
messagesGroup,
|
||||
...(isCallRoom ? [callSettingsGroup] : []),
|
||||
moderationGroup,
|
||||
roomOverviewGroup,
|
||||
roomSettingsGroup,
|
||||
otherSettingsGroup,
|
||||
];
|
||||
}, []);
|
||||
}, [isCallRoom]);
|
||||
|
||||
return groups;
|
||||
};
|
||||
|
||||
57
src/app/features/room/CallChatView.tsx
Normal file
57
src/app/features/room/CallChatView.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import React from 'react';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { Box, Text, TooltipProvider, Tooltip, Icon, Icons, IconButton, toRem } from 'folds';
|
||||
import { Page, PageHeader } from '../../components/page';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
import { RoomView } from './RoomView';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
|
||||
export function CallChatView() {
|
||||
const { eventId } = useParams();
|
||||
const setChat = useSetAtom(callChatAtom);
|
||||
const screenSize = useScreenSizeContext();
|
||||
|
||||
const handleClose = () => setChat(false);
|
||||
|
||||
return (
|
||||
<Page
|
||||
style={{
|
||||
width: screenSize === ScreenSize.Desktop ? toRem(456) : '100%',
|
||||
flexShrink: 0,
|
||||
flexGrow: 0,
|
||||
}}
|
||||
>
|
||||
<PageHeader>
|
||||
<Box grow="Yes" alignItems="Center" gap="200">
|
||||
<Box grow="Yes">
|
||||
<Text size="H5" truncate>
|
||||
Chat
|
||||
</Text>
|
||||
</Box>
|
||||
<Box shrink="No" alignItems="Center">
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>Close</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} variant="Surface" onClick={handleClose}>
|
||||
<Icon src={Icons.Cross} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
</Box>
|
||||
</Box>
|
||||
</PageHeader>
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomView eventId={eventId} />
|
||||
</Box>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
|
||||
import { Box, Line } from 'folds';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { RoomView } from './RoomView';
|
||||
import { MembersDrawer } from './MembersDrawer';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
@@ -13,6 +14,10 @@ import { useKeyDown } from '../../hooks/useKeyDown';
|
||||
import { markAsRead } from '../../utils/notifications';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useRoomMembers } from '../../hooks/useRoomMembers';
|
||||
import { CallView } from '../call/CallView';
|
||||
import { RoomViewHeader } from './RoomViewHeader';
|
||||
import { callChatAtom } from '../../state/callEmbed';
|
||||
import { CallChatView } from './CallChatView';
|
||||
|
||||
export function Room() {
|
||||
const { eventId } = useParams();
|
||||
@@ -24,6 +29,7 @@ export function Room() {
|
||||
const screenSize = useScreenSizeContext();
|
||||
const powerLevels = usePowerLevels(room);
|
||||
const members = useRoomMembers(mx, room.roomId);
|
||||
const chat = useAtomValue(callChatAtom);
|
||||
|
||||
useKeyDown(
|
||||
window,
|
||||
@@ -37,11 +43,37 @@ export function Room() {
|
||||
)
|
||||
);
|
||||
|
||||
const callView = room.isCallRoom();
|
||||
|
||||
return (
|
||||
<PowerLevelsContextProvider value={powerLevels}>
|
||||
<Box grow="Yes">
|
||||
<RoomView room={room} eventId={eventId} />
|
||||
{screenSize === ScreenSize.Desktop && isDrawer && (
|
||||
{callView && (screenSize === ScreenSize.Desktop || !chat) && (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomViewHeader callView />
|
||||
<Box grow="Yes">
|
||||
<CallView />
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
{!callView && (
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomViewHeader />
|
||||
<Box grow="Yes">
|
||||
<RoomView eventId={eventId} />
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{callView && chat && (
|
||||
<>
|
||||
{screenSize === ScreenSize.Desktop && (
|
||||
<Line variant="Background" direction="Vertical" size="300" />
|
||||
)}
|
||||
<CallChatView />
|
||||
</>
|
||||
)}
|
||||
{!callView && screenSize === ScreenSize.Desktop && isDrawer && (
|
||||
<>
|
||||
<Line variant="Background" direction="Vertical" size="300" />
|
||||
<MembersDrawer key={room.roomId} room={room} members={members} />
|
||||
|
||||
@@ -221,7 +221,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
const isComposing = useComposingCheck();
|
||||
|
||||
useElementSizeObserver(
|
||||
useCallback(() => document.body, []),
|
||||
useCallback(() => fileDropContainerRef.current, [fileDropContainerRef]),
|
||||
useCallback((width) => setHideStickerBtn(width < 500), [])
|
||||
);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import { HTMLReactParserOptions } from 'html-react-parser';
|
||||
import classNames from 'classnames';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { Editor } from 'slate';
|
||||
import { SessionMembershipData } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import to from 'await-to-js';
|
||||
import { useAtomValue, useSetAtom } from 'jotai';
|
||||
import {
|
||||
@@ -115,6 +116,8 @@ import { useMentionClickHandler } from '../../hooks/useMentionClickHandler';
|
||||
import { useSpoilerClickHandler } from '../../hooks/useSpoilerClickHandler';
|
||||
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||
import { useAllowExternalImages } from '../../../owl/hooks/useAllowExternalImages';
|
||||
import { useAllowExternalVideos } from '../../../owl/hooks/useAllowExternalVideos';
|
||||
import { useIgnoredUsers } from '../../hooks/useIgnoredUsers';
|
||||
import { useImagePackRooms } from '../../hooks/useImagePackRooms';
|
||||
import { useIsDirectRoom } from '../../hooks/useRoom';
|
||||
@@ -446,6 +449,8 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
|
||||
const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents');
|
||||
const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||
const allowExternalImages = useAllowExternalImages(mx, room);
|
||||
const allowExternalVideos = useAllowExternalVideos(mx, room);
|
||||
|
||||
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
||||
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
|
||||
@@ -527,10 +532,11 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
getReactCustomHtmlParser(mx, room.roomId, {
|
||||
linkifyOpts,
|
||||
useAuthentication,
|
||||
allowExternalImages,
|
||||
handleSpoilerClick: spoilerClickHandler,
|
||||
handleMentionClick: mentionClickHandler,
|
||||
}),
|
||||
[mx, room, linkifyOpts, spoilerClickHandler, mentionClickHandler, useAuthentication]
|
||||
[mx, room, linkifyOpts, spoilerClickHandler, mentionClickHandler, useAuthentication, allowExternalImages]
|
||||
);
|
||||
const parseMemberEvent = useMemberEventParser();
|
||||
|
||||
@@ -1103,6 +1109,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={showUrlPreview}
|
||||
allowExternalVideos={allowExternalVideos}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
outlineAttachment={messageLayout === MessageLayout.Bubble}
|
||||
@@ -1209,6 +1216,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
getContent={getContent}
|
||||
mediaAutoLoad={mediaAutoLoad}
|
||||
urlPreview={showUrlPreview}
|
||||
allowExternalVideos={allowExternalVideos}
|
||||
htmlReactParserOptions={htmlReactParserOptions}
|
||||
linkifyOpts={linkifyOpts}
|
||||
outlineAttachment={messageLayout === MessageLayout.Bubble}
|
||||
@@ -1469,6 +1477,57 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||
</Event>
|
||||
);
|
||||
},
|
||||
[StateEvent.GroupCallMemberPrefix]: (mEventId, mEvent, item) => {
|
||||
const highlighted = focusItem?.index === item && focusItem.highlight;
|
||||
const senderId = mEvent.getSender() ?? '';
|
||||
const senderName = getMemberDisplayName(room, senderId) || getMxIdLocalPart(senderId);
|
||||
|
||||
const content = mEvent.getContent<SessionMembershipData>();
|
||||
const prevContent = mEvent.getPrevContent();
|
||||
|
||||
const callJoined = content.application;
|
||||
if (callJoined && 'application' in prevContent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const timeJSX = (
|
||||
<Time
|
||||
ts={mEvent.getTs()}
|
||||
compact={messageLayout === MessageLayout.Compact}
|
||||
hour24Clock={hour24Clock}
|
||||
dateFormatString={dateFormatString}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Event
|
||||
key={mEvent.getId()}
|
||||
data-message-item={item}
|
||||
data-message-id={mEventId}
|
||||
room={room}
|
||||
mEvent={mEvent}
|
||||
highlight={highlighted}
|
||||
messageSpacing={messageSpacing}
|
||||
canDelete={canRedact || mEvent.getSender() === mx.getUserId()}
|
||||
hideReadReceipts={hideActivity}
|
||||
showDeveloperTools={showDeveloperTools}
|
||||
>
|
||||
<EventContent
|
||||
messageLayout={messageLayout}
|
||||
time={timeJSX}
|
||||
iconSrc={callJoined ? Icons.Phone : Icons.PhoneDown}
|
||||
content={
|
||||
<Box grow="Yes" direction="Column">
|
||||
<Text size="T300" priority="300">
|
||||
<b>{senderName}</b>
|
||||
{callJoined ? ' joined the call' : ' ended the call'}
|
||||
</Text>
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
</Event>
|
||||
);
|
||||
},
|
||||
},
|
||||
(mEventId, mEvent, item) => {
|
||||
if (!showHiddenEvents) return null;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import { Box, Text, config } from 'folds';
|
||||
import { EventType, Room } from 'matrix-js-sdk';
|
||||
import { EventType } from 'matrix-js-sdk';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { useStateEvent } from '../../hooks/useStateEvent';
|
||||
@@ -15,13 +15,13 @@ import { RoomTombstone } from './RoomTombstone';
|
||||
import { RoomInput } from './RoomInput';
|
||||
import { RoomViewFollowing, RoomViewFollowingPlaceholder } from './RoomViewFollowing';
|
||||
import { Page } from '../../components/page';
|
||||
import { RoomViewHeader } from './RoomViewHeader';
|
||||
import { useKeyDown } from '../../hooks/useKeyDown';
|
||||
import { editableActiveElement } from '../../utils/dom';
|
||||
import { settingsAtom } from '../../state/settings';
|
||||
import { useSetting } from '../../state/hooks/settings';
|
||||
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||
import { useRoom } from '../../hooks/useRoom';
|
||||
|
||||
const FN_KEYS_REGEX = /^F\d+$/;
|
||||
const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
||||
@@ -30,10 +30,8 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
||||
return false;
|
||||
}
|
||||
|
||||
// do not focus on F keys
|
||||
if (FN_KEYS_REGEX.test(code)) return false;
|
||||
|
||||
// do not focus on numlock/scroll lock
|
||||
if (
|
||||
code.startsWith('OS') ||
|
||||
code.startsWith('Meta') ||
|
||||
@@ -56,12 +54,13 @@ const shouldFocusMessageField = (evt: KeyboardEvent): boolean => {
|
||||
return true;
|
||||
};
|
||||
|
||||
export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
||||
export function RoomView({ eventId }: { eventId?: string }) {
|
||||
const roomInputRef = useRef<HTMLDivElement>(null);
|
||||
const roomViewRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const [hideActivity] = useSetting(settingsAtom, 'hideActivity');
|
||||
|
||||
const room = useRoom();
|
||||
const { roomId } = room;
|
||||
const editor = useEditor();
|
||||
|
||||
@@ -93,7 +92,6 @@ export function RoomView({ room, eventId }: { room: Room; eventId?: string }) {
|
||||
|
||||
return (
|
||||
<Page ref={roomViewRef}>
|
||||
<RoomViewHeader />
|
||||
<Box grow="Yes" direction="Column">
|
||||
<RoomTimeline
|
||||
key={roomId}
|
||||
|
||||
@@ -23,9 +23,7 @@ import {
|
||||
Spinner,
|
||||
} from 'folds';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { JoinRule, Room } from 'matrix-js-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { useStateEvent } from '../../hooks/useStateEvent';
|
||||
import { PageHeader } from '../../components/page';
|
||||
import { RoomAvatar, RoomIcon } from '../../components/room-avatar';
|
||||
@@ -33,7 +31,7 @@ import { UseStateProvider } from '../../components/UseStateProvider';
|
||||
import { RoomTopicViewer } from '../../components/room-topic-viewer';
|
||||
import { StateEvent } from '../../../types/matrix/room';
|
||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||
import { useRoom } from '../../hooks/useRoom';
|
||||
import { useIsDirectRoom, useRoom } from '../../hooks/useRoom';
|
||||
import { useSetting } from '../../state/hooks/settings';
|
||||
import { settingsAtom } from '../../state/settings';
|
||||
import { useSpaceOptionally } from '../../hooks/useSpace';
|
||||
@@ -48,7 +46,6 @@ import { roomToUnreadAtom } from '../../state/room/roomToUnread';
|
||||
import { copyToClipboard } from '../../utils/dom';
|
||||
import { LeaveRoomPrompt } from '../../components/leave-room-prompt';
|
||||
import { useRoomAvatar, useRoomName, useRoomTopic } from '../../hooks/useRoomMeta';
|
||||
import { mDirectAtom } from '../../state/mDirectList';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
import { stopPropagation } from '../../utils/keyboard';
|
||||
import { getMatrixToRoom } from '../../plugins/matrix-to';
|
||||
@@ -69,6 +66,8 @@ import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
||||
import { useRoomCreators } from '../../hooks/useRoomCreators';
|
||||
import { useRoomPermissions } from '../../hooks/useRoomPermissions';
|
||||
import { InviteUserPrompt } from '../../components/invite-user-prompt';
|
||||
import { ContainerColor } from '../../styles/ContainerColor.css';
|
||||
import { RoomSettingsPage } from '../../state/roomSettings';
|
||||
|
||||
type RoomMenuProps = {
|
||||
room: Room;
|
||||
@@ -254,7 +253,7 @@ const RoomMenu = forwardRef<HTMLDivElement, RoomMenuProps>(({ room, requestClose
|
||||
);
|
||||
});
|
||||
|
||||
export function RoomViewHeader() {
|
||||
export function RoomViewHeader({ callView }: { callView?: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
@@ -263,12 +262,12 @@ export function RoomViewHeader() {
|
||||
const space = useSpaceOptionally();
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
const [pinMenuAnchor, setPinMenuAnchor] = useState<RectCords>();
|
||||
const mDirects = useAtomValue(mDirectAtom);
|
||||
const direct = useIsDirectRoom();
|
||||
|
||||
const pinnedEvents = useRoomPinnedEvents(room);
|
||||
const encryptionEvent = useStateEvent(room, StateEvent.RoomEncryption);
|
||||
const ecryptedRoom = !!encryptionEvent;
|
||||
const avatarMxc = useRoomAvatar(room, mDirects.has(room.roomId));
|
||||
const encryptedRoom = !!encryptionEvent;
|
||||
const avatarMxc = useRoomAvatar(room, direct);
|
||||
const name = useRoomName(room);
|
||||
const topic = useRoomTopic(room);
|
||||
const avatarUrl = avatarMxc
|
||||
@@ -295,14 +294,27 @@ export function RoomViewHeader() {
|
||||
setPinMenuAnchor(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const openSettings = useOpenRoomSettings();
|
||||
const parentSpace = useSpaceOptionally();
|
||||
const handleMemberToggle = () => {
|
||||
if (callView) {
|
||||
openSettings(room.roomId, parentSpace?.roomId, RoomSettingsPage.MembersPage);
|
||||
return;
|
||||
}
|
||||
setPeopleDrawer(!peopleDrawer);
|
||||
};
|
||||
|
||||
return (
|
||||
<PageHeader balance={screenSize === ScreenSize.Mobile}>
|
||||
<PageHeader
|
||||
className={ContainerColor({ variant: 'Surface' })}
|
||||
balance={screenSize === ScreenSize.Mobile}
|
||||
>
|
||||
<Box grow="Yes" gap="300">
|
||||
{screenSize === ScreenSize.Mobile && (
|
||||
<BackRouteHandler>
|
||||
{(onBack) => (
|
||||
<Box shrink="No" alignItems="Center">
|
||||
<IconButton onClick={onBack}>
|
||||
<IconButton fill="None" onClick={onBack}>
|
||||
<Icon src={Icons.ArrowLeft} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
@@ -317,11 +329,7 @@ export function RoomViewHeader() {
|
||||
src={avatarUrl}
|
||||
alt={name}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
size="200"
|
||||
joinRule={room.getJoinRule() ?? JoinRule.Restricted}
|
||||
filled
|
||||
/>
|
||||
<RoomIcon size="200" joinRule={room.getJoinRule()} roomType={room.getType()} />
|
||||
)}
|
||||
/>
|
||||
</Avatar>
|
||||
@@ -369,8 +377,9 @@ export function RoomViewHeader() {
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
<Box shrink="No">
|
||||
{!ecryptedRoom && (
|
||||
{!encryptedRoom && (
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
offset={4}
|
||||
@@ -381,7 +390,7 @@ export function RoomViewHeader() {
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} onClick={handleSearchClick}>
|
||||
<IconButton fill="None" ref={triggerRef} onClick={handleSearchClick}>
|
||||
<Icon size="400" src={Icons.Search} />
|
||||
</IconButton>
|
||||
)}
|
||||
@@ -398,6 +407,7 @@ export function RoomViewHeader() {
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton
|
||||
fill="None"
|
||||
style={{ position: 'relative' }}
|
||||
onClick={handleOpenPinMenu}
|
||||
ref={triggerRef}
|
||||
@@ -443,23 +453,29 @@ export function RoomViewHeader() {
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
|
||||
{screenSize === ScreenSize.Desktop && (
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
offset={4}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text>{peopleDrawer ? 'Hide Members' : 'Show Members'}</Text>
|
||||
{callView ? (
|
||||
<Text>Members</Text>
|
||||
) : (
|
||||
<Text>{peopleDrawer ? 'Hide Members' : 'Show Members'}</Text>
|
||||
)}
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton ref={triggerRef} onClick={() => setPeopleDrawer((drawer) => !drawer)}>
|
||||
<IconButton fill="None" ref={triggerRef} onClick={handleMemberToggle}>
|
||||
<Icon size="400" src={Icons.User} />
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
)}
|
||||
|
||||
<TooltipProvider
|
||||
position="Bottom"
|
||||
align="End"
|
||||
@@ -471,7 +487,12 @@ export function RoomViewHeader() {
|
||||
}
|
||||
>
|
||||
{(triggerRef) => (
|
||||
<IconButton onClick={handleOpenMenu} ref={triggerRef} aria-pressed={!!menuAnchor}>
|
||||
<IconButton
|
||||
fill="None"
|
||||
onClick={handleOpenMenu}
|
||||
ref={triggerRef}
|
||||
aria-pressed={!!menuAnchor}
|
||||
>
|
||||
<Icon size="400" src={Icons.VerticalDots} filled={!!menuAnchor} />
|
||||
</IconButton>
|
||||
)}
|
||||
|
||||
@@ -79,6 +79,7 @@ import { MemberPowerTag, StateEvent } from '../../../../types/matrix/room';
|
||||
import { PowerIcon } from '../../../components/power';
|
||||
import colorMXID from '../../../../util/colorMXID';
|
||||
import { getPowerTagIconSrc } from '../../../hooks/useMemberPowerTag';
|
||||
import { timeHourMinute } from '../../../utils/time';
|
||||
|
||||
export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void;
|
||||
|
||||
@@ -327,11 +328,9 @@ export const MessageCopyLinkItem = as<
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const handleCopy = () => {
|
||||
const roomIdOrAlias = getCanonicalAliasOrRoomId(mx, room.roomId);
|
||||
const eventId = mEvent.getId();
|
||||
const viaServers = isRoomAlias(roomIdOrAlias) ? undefined : getViaServers(room);
|
||||
if (!eventId) return;
|
||||
copyToClipboard(getMatrixToRoomEvent(roomIdOrAlias, eventId, viaServers));
|
||||
copyToClipboard(getMatrixToRoomEvent(room.roomId, eventId, getViaServers(room)));
|
||||
onClose?.();
|
||||
};
|
||||
|
||||
@@ -815,6 +814,15 @@ export const Message = as<'div', MessageProps>(
|
||||
</AvatarBase>
|
||||
);
|
||||
|
||||
const visibleReactions = relations?.getSortedAnnotationsByKey();
|
||||
const hasVisibleReactions = !!visibleReactions && visibleReactions.some(
|
||||
([key, events]) => typeof key === 'string' && Array.from(events).length > 0
|
||||
);
|
||||
|
||||
const handleInlineAddReaction: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setEmojiBoardAnchor(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const msgContentJSX = (
|
||||
<Box direction="Column" alignSelf="Start" style={{ maxWidth: '100%' }}>
|
||||
{reply}
|
||||
@@ -833,7 +841,11 @@ export const Message = as<'div', MessageProps>(
|
||||
) : (
|
||||
children
|
||||
)}
|
||||
{reactions}
|
||||
{reactions && React.isValidElement(reactions)
|
||||
? React.cloneElement(reactions as React.ReactElement<any>, {
|
||||
onAddReaction: handleInlineAddReaction,
|
||||
})
|
||||
: reactions}
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -1131,6 +1143,17 @@ export const Message = as<'div', MessageProps>(
|
||||
</Menu>
|
||||
</div>
|
||||
)}
|
||||
{!edit && collapse && messageLayout !== MessageLayout.Compact
|
||||
&& (hover || !!emojiBoardAnchor) && (
|
||||
<Text
|
||||
className={css.CollapsedTime}
|
||||
as="time"
|
||||
size="T200"
|
||||
priority="300"
|
||||
>
|
||||
{timeHourMinute(mEvent.getTs(), hour24Clock)}
|
||||
</Text>
|
||||
)}
|
||||
{messageLayout === MessageLayout.Compact && (
|
||||
<CompactLayout before={headerJSX} onContextMenu={handleContextMenu}>
|
||||
{msgContentJSX}
|
||||
|
||||
@@ -23,6 +23,7 @@ import * as css from './styles.css';
|
||||
import { ReactionViewer } from '../reaction-viewer';
|
||||
import { stopPropagation } from '../../../utils/keyboard';
|
||||
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||
import { AddReactionButton } from '../../../../owl/components/AddReactionButton';
|
||||
|
||||
export type ReactionsProps = {
|
||||
room: Room;
|
||||
@@ -30,9 +31,10 @@ export type ReactionsProps = {
|
||||
canSendReaction?: boolean;
|
||||
relations: Relations;
|
||||
onReactionToggle: (targetEventId: string, key: string, shortcode?: string) => void;
|
||||
onAddReaction?: MouseEventHandler<HTMLButtonElement>;
|
||||
};
|
||||
export const Reactions = as<'div', ReactionsProps>(
|
||||
({ className, room, relations, mEventId, canSendReaction, onReactionToggle, ...props }, ref) => {
|
||||
({ className, room, relations, mEventId, canSendReaction, onReactionToggle, onAddReaction, ...props }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const [viewer, setViewer] = useState<boolean | string>(false);
|
||||
@@ -41,6 +43,9 @@ export const Reactions = as<'div', ReactionsProps>(
|
||||
relations,
|
||||
useCallback((rel) => [...(rel.getSortedAnnotationsByKey() ?? [])], [])
|
||||
);
|
||||
const visibleCount = reactions.filter(
|
||||
([key, events]) => typeof key === 'string' && Array.from(events).length > 0
|
||||
).length;
|
||||
|
||||
const handleViewReaction: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
evt.stopPropagation();
|
||||
@@ -94,7 +99,10 @@ export const Reactions = as<'div', ReactionsProps>(
|
||||
</TooltipProvider>
|
||||
);
|
||||
})}
|
||||
{reactions.length > 0 && (
|
||||
{visibleCount > 0 && canSendReaction && onAddReaction && (
|
||||
<AddReactionButton onClick={onAddReaction} />
|
||||
)}
|
||||
{visibleCount > 0 && (
|
||||
<Overlay
|
||||
onContextMenu={(evt: any) => {
|
||||
evt.stopPropagation();
|
||||
|
||||
@@ -55,3 +55,13 @@ export const ReactionsContainer = style({
|
||||
export const ReactionsTooltipText = style({
|
||||
wordBreak: 'break-word',
|
||||
});
|
||||
|
||||
export const CollapsedTime = style({
|
||||
position: 'absolute',
|
||||
left: config.space.S400,
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
opacity: 0.6,
|
||||
userSelect: 'none',
|
||||
pointerEvents: 'none',
|
||||
});
|
||||
|
||||
@@ -63,6 +63,7 @@ import { RenderMatrixEvent, useMatrixEventRenderer } from '../../../hooks/useMat
|
||||
import { RenderMessageContent } from '../../../components/RenderMessageContent';
|
||||
import { useSetting } from '../../../state/hooks/settings';
|
||||
import { settingsAtom } from '../../../state/settings';
|
||||
import { useAllowExternalImages } from '../../../../owl/hooks/useAllowExternalImages';
|
||||
import * as customHtmlCss from '../../../styles/CustomHtml.css';
|
||||
import { EncryptedContent } from '../message';
|
||||
import { Image } from '../../../components/media';
|
||||
@@ -273,6 +274,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const [mediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||
const [urlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||
const allowExternalImages = useAllowExternalImages(mx, room);
|
||||
|
||||
const direct = useIsDirectRoom();
|
||||
const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor');
|
||||
@@ -307,10 +309,11 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
|
||||
getReactCustomHtmlParser(mx, room.roomId, {
|
||||
linkifyOpts,
|
||||
useAuthentication,
|
||||
allowExternalImages,
|
||||
handleSpoilerClick: spoilerClickHandler,
|
||||
handleMentionClick: mentionClickHandler,
|
||||
}),
|
||||
[mx, room, linkifyOpts, mentionClickHandler, spoilerClickHandler, useAuthentication]
|
||||
[mx, room, linkifyOpts, mentionClickHandler, spoilerClickHandler, useAuthentication, allowExternalImages]
|
||||
);
|
||||
|
||||
const renderMatrixEvent = useMatrixEventRenderer<[MatrixEvent, string, GetContentCallback]>(
|
||||
|
||||
@@ -286,7 +286,7 @@ export function Search({ requestClose }: SearchProps) {
|
||||
gap="100"
|
||||
>
|
||||
<Text size="H6" align="Center">
|
||||
{result ? 'No Match Found' : `No Rooms'}`}
|
||||
{result ? 'No Match Found' : 'No Rooms'}
|
||||
</Text>
|
||||
<Text size="T200" align="Center">
|
||||
{result
|
||||
@@ -373,7 +373,7 @@ export function Search({ requestClose }: SearchProps) {
|
||||
<RoomIcon
|
||||
size="100"
|
||||
joinRule={room.getJoinRule()}
|
||||
space={room.isSpaceRoom()}
|
||||
roomType={room.getType()}
|
||||
/>
|
||||
)}
|
||||
</Avatar>
|
||||
|
||||
@@ -46,7 +46,7 @@ export function About({ requestClose }: AboutProps) {
|
||||
<Box direction="Column" gap="100">
|
||||
<Box gap="100" alignItems="End">
|
||||
<Text size="H3">Cinny</Text>
|
||||
<Text size="T200">v4.10.3</Text>
|
||||
<Text size="T200">v4.11.1</Text>
|
||||
</Box>
|
||||
<Text>Yet another matrix client.</Text>
|
||||
</Box>
|
||||
|
||||
@@ -32,7 +32,7 @@ import FocusTrap from 'focus-trap-react';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { useSetting } from '../../../state/hooks/settings';
|
||||
import { DateFormat, MessageLayout, MessageSpacing, settingsAtom } from '../../../state/settings';
|
||||
import { DateFormat, ExternalImageMode, ExternalVideoMode, MessageLayout, MessageSpacing, settingsAtom } from '../../../state/settings';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { KeySymbol } from '../../../utils/key-symbol';
|
||||
import { isMacOS } from '../../../utils/user-agent';
|
||||
@@ -879,6 +879,154 @@ function SelectMessageSpacing() {
|
||||
);
|
||||
}
|
||||
|
||||
const externalImageItems: { mode: ExternalImageMode; name: string }[] = [
|
||||
{ mode: 'never', name: 'Never' },
|
||||
{ mode: 'homeserver', name: 'Homeserver Only' },
|
||||
{ mode: 'always', name: 'Always' },
|
||||
];
|
||||
|
||||
function SelectExternalImages() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [externalImages, setExternalImages] = useSetting(settingsAtom, 'externalImages');
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (mode: ExternalImageMode) => {
|
||||
setExternalImages(mode);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">
|
||||
{externalImageItems.find((i) => i.mode === externalImages)?.name ?? externalImages}
|
||||
</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{externalImageItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.mode}
|
||||
size="300"
|
||||
variant={externalImages === item.mode ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item.mode)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const externalVideoItems: { mode: ExternalVideoMode; name: string }[] = [
|
||||
{ mode: 'never', name: 'Never' },
|
||||
{ mode: 'homeserver', name: 'Homeserver Only' },
|
||||
{ mode: 'always', name: 'Always' },
|
||||
];
|
||||
|
||||
function SelectExternalVideos() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [externalVideos, setExternalVideos] = useSetting(settingsAtom, 'externalVideos');
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (mode: ExternalVideoMode) => {
|
||||
setExternalVideos(mode);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
outlined
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
after={<Icon size="300" src={Icons.ChevronBottom} />}
|
||||
onClick={handleMenu}
|
||||
>
|
||||
<Text size="T300">
|
||||
{externalVideoItems.find((i) => i.mode === externalVideos)?.name ?? externalVideos}
|
||||
</Text>
|
||||
</Button>
|
||||
<PopOut
|
||||
anchor={menuCords}
|
||||
offset={5}
|
||||
position="Bottom"
|
||||
align="End"
|
||||
content={
|
||||
<FocusTrap
|
||||
focusTrapOptions={{
|
||||
initialFocus: false,
|
||||
onDeactivate: () => setMenuCords(undefined),
|
||||
clickOutsideDeactivates: true,
|
||||
isKeyForward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowDown' || evt.key === 'ArrowRight',
|
||||
isKeyBackward: (evt: KeyboardEvent) =>
|
||||
evt.key === 'ArrowUp' || evt.key === 'ArrowLeft',
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<Menu>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{externalVideoItems.map((item) => (
|
||||
<MenuItem
|
||||
key={item.mode}
|
||||
size="300"
|
||||
variant={externalVideos === item.mode ? 'Primary' : 'Surface'}
|
||||
radii="300"
|
||||
onClick={() => handleSelect(item.mode)}
|
||||
>
|
||||
<Text size="T300">{item.name}</Text>
|
||||
</MenuItem>
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Messages() {
|
||||
const [legacyUsernameColor, setLegacyUsernameColor] = useSetting(
|
||||
settingsAtom,
|
||||
@@ -966,6 +1114,19 @@ function Messages() {
|
||||
after={<Switch variant="Primary" value={encUrlPreview} onChange={setEncUrlPreview} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="External Images"
|
||||
after={<SelectExternalImages />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="External Videos"
|
||||
description="Embed YouTube links and play direct video URLs (mp4, webm) inline."
|
||||
after={<SelectExternalVideos />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Hidden Events"
|
||||
|
||||
@@ -103,7 +103,7 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps)
|
||||
alt={roomName}
|
||||
renderFallback={() => (
|
||||
<RoomIcon
|
||||
space
|
||||
roomType={room.getType()}
|
||||
size="50"
|
||||
joinRule={joinRuleContent?.join_rule ?? JoinRule.Invite}
|
||||
filled
|
||||
|
||||
@@ -125,6 +125,13 @@ export const usePermissionGroups = (): PermissionGroup[] => {
|
||||
const otherSettingsGroup: PermissionGroup = {
|
||||
name: 'Other',
|
||||
items: [
|
||||
{
|
||||
location: {
|
||||
state: true,
|
||||
key: StateEvent.PoniesRoomEmotes,
|
||||
},
|
||||
name: 'Manage Emojis & Stickers',
|
||||
},
|
||||
{
|
||||
location: {
|
||||
state: true,
|
||||
|
||||
@@ -18,7 +18,7 @@ export const useSelectedSpace = (): string | undefined => {
|
||||
|
||||
export const useSpaceLobbySelected = (spaceIdOrAlias: string): boolean => {
|
||||
const match = useMatch({
|
||||
path: getSpaceLobbyPath(spaceIdOrAlias),
|
||||
path: decodeURIComponent(getSpaceLobbyPath(spaceIdOrAlias)),
|
||||
caseSensitive: true,
|
||||
end: false,
|
||||
});
|
||||
@@ -28,7 +28,7 @@ export const useSpaceLobbySelected = (spaceIdOrAlias: string): boolean => {
|
||||
|
||||
export const useSpaceSearchSelected = (spaceIdOrAlias: string): boolean => {
|
||||
const match = useMatch({
|
||||
path: getSpaceSearchPath(spaceIdOrAlias),
|
||||
path: decodeURIComponent(getSpaceSearchPath(spaceIdOrAlias)),
|
||||
caseSensitive: true,
|
||||
end: false,
|
||||
});
|
||||
|
||||
64
src/app/hooks/useCall.ts
Normal file
64
src/app/hooks/useCall.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import {
|
||||
MatrixRTCSession,
|
||||
MatrixRTCSessionEvent,
|
||||
} from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSession';
|
||||
import { CallMembership } from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { MatrixRTCSessionManagerEvents } from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSessionManager';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
|
||||
export const useCallSession = (room: Room): MatrixRTCSession => {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [session, setSession] = useState(mx.matrixRTC.getRoomSession(room));
|
||||
|
||||
useEffect(() => {
|
||||
const start = (roomId: string) => {
|
||||
if (roomId !== room.roomId) return;
|
||||
setSession(mx.matrixRTC.getRoomSession(room));
|
||||
};
|
||||
const end = (roomId: string) => {
|
||||
if (roomId !== room.roomId) return;
|
||||
setSession(mx.matrixRTC.getRoomSession(room));
|
||||
};
|
||||
mx.matrixRTC.on(MatrixRTCSessionManagerEvents.SessionStarted, start);
|
||||
mx.matrixRTC.on(MatrixRTCSessionManagerEvents.SessionEnded, end);
|
||||
return () => {
|
||||
mx.matrixRTC.off(MatrixRTCSessionManagerEvents.SessionStarted, start);
|
||||
mx.matrixRTC.off(MatrixRTCSessionManagerEvents.SessionEnded, end);
|
||||
};
|
||||
}, [mx, room]);
|
||||
|
||||
return session;
|
||||
};
|
||||
|
||||
export const useCallMembers = (room: Room, session: MatrixRTCSession): CallMembership[] => {
|
||||
const [memberships, setMemberships] = useState<CallMembership[]>(
|
||||
MatrixRTCSession.sessionMembershipsForRoom(room, session.sessionDescription)
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const updateMemberships = () => {
|
||||
setMemberships(MatrixRTCSession.sessionMembershipsForRoom(room, session.sessionDescription));
|
||||
};
|
||||
|
||||
updateMemberships();
|
||||
|
||||
session.on(MatrixRTCSessionEvent.MembershipsChanged, updateMemberships);
|
||||
return () => {
|
||||
session.removeListener(MatrixRTCSessionEvent.MembershipsChanged, updateMemberships);
|
||||
};
|
||||
}, [session, room]);
|
||||
|
||||
return memberships;
|
||||
};
|
||||
|
||||
export const useCallMembersChange = (session: MatrixRTCSession, callback: () => void): void => {
|
||||
useEffect(() => {
|
||||
session.on(MatrixRTCSessionEvent.MembershipsChanged, callback);
|
||||
return () => {
|
||||
session.removeListener(MatrixRTCSessionEvent.MembershipsChanged, callback);
|
||||
};
|
||||
}, [session, callback]);
|
||||
};
|
||||
142
src/app/hooks/useCallEmbed.ts
Normal file
142
src/app/hooks/useCallEmbed.ts
Normal file
@@ -0,0 +1,142 @@
|
||||
import { createContext, RefObject, useCallback, useContext, useEffect, useState } from 'react';
|
||||
import { MatrixRTCSession } from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSession';
|
||||
import { MatrixClient, Room } from 'matrix-js-sdk';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import {
|
||||
CallEmbed,
|
||||
ElementCallThemeKind,
|
||||
ElementWidgetActions,
|
||||
useClientWidgetApiEvent,
|
||||
} from '../plugins/call';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
import { ThemeKind, useTheme } from './useTheme';
|
||||
import { callEmbedAtom } from '../state/callEmbed';
|
||||
import { useResizeObserver } from './useResizeObserver';
|
||||
import { CallControlState } from '../plugins/call/CallControlState';
|
||||
import { useCallMembersChange, useCallSession } from './useCall';
|
||||
import { CallPreferences } from '../state/callPreferences';
|
||||
|
||||
const CallEmbedContext = createContext<CallEmbed | undefined>(undefined);
|
||||
|
||||
export const CallEmbedContextProvider = CallEmbedContext.Provider;
|
||||
|
||||
export const useCallEmbed = (): CallEmbed | undefined => {
|
||||
const callEmbed = useContext(CallEmbedContext);
|
||||
|
||||
return callEmbed;
|
||||
};
|
||||
|
||||
const CallEmbedRefContext = createContext<RefObject<HTMLDivElement> | undefined>(undefined);
|
||||
export const CallEmbedRefContextProvider = CallEmbedRefContext.Provider;
|
||||
export const useCallEmbedRef = (): RefObject<HTMLDivElement> => {
|
||||
const ref = useContext(CallEmbedRefContext);
|
||||
if (!ref) {
|
||||
throw new Error('CallEmbedRef is not provided!');
|
||||
}
|
||||
return ref;
|
||||
};
|
||||
|
||||
export const createCallEmbed = (
|
||||
mx: MatrixClient,
|
||||
room: Room,
|
||||
dm: boolean,
|
||||
themeKind: ElementCallThemeKind,
|
||||
container: HTMLElement,
|
||||
pref?: CallPreferences
|
||||
): CallEmbed => {
|
||||
const rtcSession = mx.matrixRTC.getRoomSession(room);
|
||||
const ongoing =
|
||||
MatrixRTCSession.sessionMembershipsForRoom(room, rtcSession.sessionDescription).length > 0;
|
||||
|
||||
const intent = CallEmbed.getIntent(dm, ongoing);
|
||||
const widget = CallEmbed.getWidget(mx, room, intent, themeKind);
|
||||
const controlState = pref && new CallControlState(pref.microphone, pref.video, pref.sound);
|
||||
|
||||
const embed = new CallEmbed(mx, room, widget, container, controlState);
|
||||
|
||||
return embed;
|
||||
};
|
||||
|
||||
export const useCallStart = (dm = false) => {
|
||||
const mx = useMatrixClient();
|
||||
const theme = useTheme();
|
||||
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||
const callEmbedRef = useCallEmbedRef();
|
||||
|
||||
const startCall = useCallback(
|
||||
(room: Room, pref?: CallPreferences) => {
|
||||
const container = callEmbedRef.current;
|
||||
if (!container) {
|
||||
throw new Error('Failed to start call, No embed container element found!');
|
||||
}
|
||||
const callEmbed = createCallEmbed(mx, room, dm, theme.kind, container, pref);
|
||||
|
||||
setCallEmbed(callEmbed);
|
||||
},
|
||||
[mx, dm, theme, setCallEmbed, callEmbedRef]
|
||||
);
|
||||
|
||||
return startCall;
|
||||
};
|
||||
|
||||
export const useCallJoined = (embed?: CallEmbed): boolean => {
|
||||
const [joined, setJoined] = useState(embed?.joined ?? false);
|
||||
|
||||
useClientWidgetApiEvent(
|
||||
embed?.call,
|
||||
ElementWidgetActions.JoinCall,
|
||||
useCallback(() => {
|
||||
setJoined(true);
|
||||
}, [])
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!embed) {
|
||||
setJoined(false);
|
||||
}
|
||||
}, [embed]);
|
||||
|
||||
return joined;
|
||||
};
|
||||
|
||||
export const useCallHangupEvent = (embed: CallEmbed, callback: () => void) => {
|
||||
useClientWidgetApiEvent(embed.call, ElementWidgetActions.HangupCall, callback);
|
||||
};
|
||||
|
||||
export const useCallMemberSoundSync = (embed: CallEmbed) => {
|
||||
const callSession = useCallSession(embed.room);
|
||||
useCallMembersChange(
|
||||
callSession,
|
||||
useCallback(() => embed.control.applySound(), [embed])
|
||||
);
|
||||
};
|
||||
|
||||
export const useCallThemeSync = (embed: CallEmbed) => {
|
||||
const theme = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
const name: ElementCallThemeKind = theme.kind === ThemeKind.Dark ? 'dark' : 'light';
|
||||
|
||||
embed.setTheme(name);
|
||||
}, [theme.kind, embed]);
|
||||
};
|
||||
|
||||
export const useCallEmbedPlacementSync = (containerViewRef: RefObject<HTMLDivElement>): void => {
|
||||
const callEmbedRef = useCallEmbedRef();
|
||||
|
||||
const syncCallEmbedPlacement = useCallback(() => {
|
||||
const embedEl = callEmbedRef.current;
|
||||
const container = containerViewRef.current;
|
||||
if (!embedEl || !container) return;
|
||||
|
||||
embedEl.style.top = `${container.offsetTop}px`;
|
||||
embedEl.style.left = `${container.offsetLeft}px`;
|
||||
embedEl.style.width = `${container.clientWidth}px`;
|
||||
embedEl.style.height = `${container.clientHeight}px`;
|
||||
}, [callEmbedRef, containerViewRef]);
|
||||
|
||||
useResizeObserver(
|
||||
syncCallEmbedPlacement,
|
||||
useCallback(() => containerViewRef.current, [containerViewRef])
|
||||
);
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user