forked from abner/for-legacy-web
Compare commits
1 Commits
handmade
...
delete-cha
| Author | SHA1 | Date |
|---|---|---|
|
|
fe0d0501fa |
4
.env
4
.env
|
|
@ -1,5 +1,5 @@
|
||||||
# VITE_API_URL=https://api.revolt.chat
|
# VITE_API_URL=https://api.revolt.chat
|
||||||
# VITE_API_URL=https://app.revolt.chat/api
|
|
||||||
# VITE_API_URL=http://local.revolt.chat:8000
|
|
||||||
VITE_API_URL=https://app.revolt.chat/api
|
VITE_API_URL=https://app.revolt.chat/api
|
||||||
|
# VITE_API_URL=http://local.revolt.chat:8000
|
||||||
|
# VITE_API_URL=https://revolt.chat/api
|
||||||
VITE_THEMES_URL=https://themes.revolt.chat
|
VITE_THEMES_URL=https://themes.revolt.chat
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
## Please make sure to check the following tasks before opening and submitting a PR
|
## Please make sure to check the following tasks before opening and submitting a PR
|
||||||
|
|
||||||
* [ ] I understand and have followed the [contribution guide](https://developers.revolt.chat/contrib.html)
|
* [ ] I understand and have followed the [contribution guide](https://github.com/revoltchat/revolt/discussions/282)
|
||||||
* [ ] I have tested my changes locally and they are working as intended
|
* [ ] I have tested my changes locally and they are working as intended
|
||||||
* [ ] These changes do not have any notable side effects on other Revolt projects
|
* [ ] These changes do not have any notable side effects on other Revolt projects
|
||||||
* [ ] (optional) I have opened a pull request on [the translation repository](https://github.com/revoltchat/translations)
|
* [ ] (optional) I have opened a pull request on [the translation repository](https://github.com/revoltchat/translations)
|
||||||
|
|
|
||||||
|
|
@ -3,66 +3,109 @@ name: Docker
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- "handmade"
|
- "master"
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- "*"
|
||||||
# TODO: Bring back once gitea is updated past 1.21
|
paths-ignore:
|
||||||
# paths-ignore:
|
- ".github/**"
|
||||||
# - ".github/**"
|
- "!.github/workflows/docker.yml"
|
||||||
# - "!.github/workflows/docker.yml"
|
- "!.github/workflows/preview_*.yml"
|
||||||
# - ".vscode/**"
|
- ".vscode/**"
|
||||||
# - ".gitignore"
|
- ".gitignore"
|
||||||
# - ".gitlab-ci.yml"
|
- ".gitlab-ci.yml"
|
||||||
# - "LICENSE"
|
- "LICENSE"
|
||||||
# - "README"
|
- "README"
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "handmade"
|
- "master"
|
||||||
# TODO: Bring back once gitea is updated past 1.21
|
paths-ignore:
|
||||||
# paths-ignore:
|
- ".github/**"
|
||||||
# - ".github/**"
|
- "!.github/workflows/docker.yml"
|
||||||
# - "!.github/workflows/docker.yml"
|
- "!.github/workflows/preview_*.yml"
|
||||||
# - "!.github/workflows/preview_*.yml"
|
- ".vscode/**"
|
||||||
# - ".vscode/**"
|
- ".gitignore"
|
||||||
# - ".gitignore"
|
- ".gitlab-ci.yml"
|
||||||
# - ".gitlab-ci.yml"
|
- "LICENSE"
|
||||||
# - "LICENSE"
|
- "README"
|
||||||
# - "README"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# NOTE: Running on pull requests for now, but without pushing.
|
strategy:
|
||||||
# if: github.event_name != 'pull_request'
|
matrix:
|
||||||
|
architecture: [linux/amd64]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: "recursive"
|
submodules: "recursive"
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v1
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache/${{ matrix.architecture }}
|
||||||
|
key: ${{ runner.os }}-buildx-${{ matrix.architecture }}-${{ github.sha }}
|
||||||
|
- name: Build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: ${{ matrix.architecture }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache/${{ matrix.architecture }}
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new/${{ matrix.architecture }},mode=max
|
||||||
|
- name: Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache/${{ matrix.architecture }}
|
||||||
|
mv /tmp/.buildx-cache-new/${{ matrix.architecture }} /tmp/.buildx-cache/${{ matrix.architecture }}
|
||||||
|
|
||||||
|
publish:
|
||||||
|
needs: [test]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
submodules: "recursive"
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Cache amd64 Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache/linux/amd64
|
||||||
|
key: ${{ runner.os }}-buildx-linux/amd64-${{ github.sha }}
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: handmadecities/handmade-revolt-web-client
|
images: revoltchat/client, ghcr.io/revoltchat/client
|
||||||
env:
|
|
||||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- name: Login to Github Container Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
- name: Build and publish
|
- name: Build and publish
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: true
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
annotations: ${{ steps.meta.outputs.annotations }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache/linux/amd64
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
|
- name: Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
name: Mirroring
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
to_gitlab:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: pixta-dev/repository-mirroring-action@v1
|
||||||
|
with:
|
||||||
|
target_repo_url: git@gitlab.com:insert/revolt-vite.git
|
||||||
|
ssh_private_key: ${{ secrets.GITLAB_SSH_PRIVATE_KEY }}
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
name: Add Issue to Board
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
track_issue:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Get project data
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
query {
|
||||||
|
organization(login: "revoltchat"){
|
||||||
|
projectV2(number: 3) {
|
||||||
|
id
|
||||||
|
fields(first:20) {
|
||||||
|
nodes {
|
||||||
|
... on ProjectV2SingleSelectField {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
options {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'TODO_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Todo") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Add issue to project
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||||
|
run: |
|
||||||
|
item_id="$( gh api graphql -f query='
|
||||||
|
mutation($project:ID!, $issue:ID!) {
|
||||||
|
addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
|
||||||
|
item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')"
|
||||||
|
|
||||||
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
name: Add PR to Board
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, synchronize, ready_for_review, review_requested]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
track_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Get project data
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
query {
|
||||||
|
organization(login: "revoltchat"){
|
||||||
|
projectV2(number: 3) {
|
||||||
|
id
|
||||||
|
fields(first:20) {
|
||||||
|
nodes {
|
||||||
|
... on ProjectV2SingleSelectField {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
options {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > project_data.json
|
||||||
|
|
||||||
|
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||||
|
echo 'INCOMING_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Incoming PRs") |.id' project_data.json) >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Add PR to project
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
PR_ID: ${{ github.event.pull_request.node_id }}
|
||||||
|
run: |
|
||||||
|
item_id="$( gh api graphql -f query='
|
||||||
|
mutation($project:ID!, $pr:ID!) {
|
||||||
|
addProjectV2ItemById(input: {projectId: $project, contentId: $pr}) {
|
||||||
|
item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f pr=$PR_ID --jq '.data.addProjectV2ItemById.item.id')"
|
||||||
|
|
||||||
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set fields
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
||||||
|
run: |
|
||||||
|
gh api graphql -f query='
|
||||||
|
mutation (
|
||||||
|
$project: ID!
|
||||||
|
$item: ID!
|
||||||
|
$status_field: ID!
|
||||||
|
$status_value: String!
|
||||||
|
) {
|
||||||
|
set_status: updateProjectV2ItemFieldValue(input: {
|
||||||
|
projectId: $project
|
||||||
|
itemId: $item
|
||||||
|
fieldId: $status_field
|
||||||
|
value: {
|
||||||
|
singleSelectOptionId: $status_value
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
projectV2Item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.INCOMING_OPTION_ID }} --silent
|
||||||
|
|
@ -15,5 +15,3 @@ public/assets_*
|
||||||
!public/assets_default
|
!public/assets_default
|
||||||
|
|
||||||
.vscode/chrome_data
|
.vscode/chrome_data
|
||||||
|
|
||||||
.direnv
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
# syntax=docker.io/docker/dockerfile:1.7-labs
|
FROM node:16-buster AS builder
|
||||||
FROM --platform=$BUILDPLATFORM node:16-buster AS builder
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
@ -11,11 +10,9 @@ RUN yarn build:deps
|
||||||
RUN yarn build:highmem
|
RUN yarn build:highmem
|
||||||
RUN yarn workspaces focus --production --all
|
RUN yarn workspaces focus --production --all
|
||||||
|
|
||||||
FROM node:24-alpine
|
FROM node:16-alpine
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
COPY docker/package.json docker/yarn.lock .
|
COPY --from=builder /usr/src/app .
|
||||||
RUN yarn install --frozen-lockfile
|
|
||||||
COPY --from=builder --exclude=package.json --exclude=yarn.lock --exclude=.yarn* --exclude=.git --exclude=external --exclude=node_modules /usr/src/app .
|
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
CMD [ "yarn", "start:inject" ]
|
CMD [ "yarn", "start:inject" ]
|
||||||
|
|
|
||||||
27
README.md
27
README.md
|
|
@ -1,30 +1,3 @@
|
||||||
# Deprecation Notice
|
|
||||||
|
|
||||||
This project is deprecated, however it still may receive maintenance updates.
|
|
||||||
|
|
||||||
PRs for small fixes are more than welcome.
|
|
||||||
|
|
||||||
## Deploying a new release
|
|
||||||
|
|
||||||
Ensure `.env.local` points to `https://app.revolt.chat/api`.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ~/deployments/revite
|
|
||||||
git pull
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# check:
|
|
||||||
git status
|
|
||||||
|
|
||||||
export REVOLT_SAAS_BRANCH=revite/main
|
|
||||||
export REMOTE=root@production
|
|
||||||
scripts/publish.sh
|
|
||||||
|
|
||||||
# SSH in and restart revite:
|
|
||||||
ssh $REMOTE
|
|
||||||
tmux a -t 4
|
|
||||||
```
|
|
||||||
|
|
||||||
# Revite
|
# Revite
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
|
||||||
|
|
||||||
pkgs.mkShell rec {
|
|
||||||
buildInputs = [
|
|
||||||
pkgs.nodejs
|
|
||||||
pkgs.nodejs.pkgs.yarn
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 828 B After Width: | Height: | Size: 828 B |
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
"name": "inject-and-sirv",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"scripts": {
|
|
||||||
"start:inject": "node scripts/inject.js && sirv dist_injected --port 5000 --cors --single --host"
|
|
||||||
},
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"fs-extra": "^11.3.0",
|
|
||||||
"klaw": "^4.1.0",
|
|
||||||
"sirv-cli": "^3.0.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
116
docker/yarn.lock
116
docker/yarn.lock
|
|
@ -1,116 +0,0 @@
|
||||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
||||||
# yarn lockfile v1
|
|
||||||
|
|
||||||
|
|
||||||
"@polka/url@^1.0.0-next.24":
|
|
||||||
version "1.0.0-next.29"
|
|
||||||
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.29.tgz#5a40109a1ab5f84d6fd8fc928b19f367cbe7e7b1"
|
|
||||||
integrity sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==
|
|
||||||
|
|
||||||
console-clear@^1.1.0:
|
|
||||||
version "1.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/console-clear/-/console-clear-1.1.1.tgz#995e20cbfbf14dd792b672cde387bd128d674bf7"
|
|
||||||
integrity sha512-pMD+MVR538ipqkG5JXeOEbKWS5um1H4LUUccUQG68qpeqBYbzYy79Gh55jkd2TtPdRfUaLWdv6LPP//5Zt0aPQ==
|
|
||||||
|
|
||||||
fs-extra@^11.3.0:
|
|
||||||
version "11.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.3.0.tgz#0daced136bbaf65a555a326719af931adc7a314d"
|
|
||||||
integrity sha512-Z4XaCL6dUDHfP/jT25jJKMmtxvuwbkrD1vNSMFlo9lNLY2c5FHYSQgHPRZUjAB26TpDEoW9HCOgplrdbaPV/ew==
|
|
||||||
dependencies:
|
|
||||||
graceful-fs "^4.2.0"
|
|
||||||
jsonfile "^6.0.1"
|
|
||||||
universalify "^2.0.0"
|
|
||||||
|
|
||||||
get-port@^5.1.1:
|
|
||||||
version "5.1.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193"
|
|
||||||
integrity sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==
|
|
||||||
|
|
||||||
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
|
||||||
version "4.2.11"
|
|
||||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
|
|
||||||
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
|
|
||||||
|
|
||||||
jsonfile@^6.0.1:
|
|
||||||
version "6.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
|
|
||||||
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
|
|
||||||
dependencies:
|
|
||||||
universalify "^2.0.0"
|
|
||||||
optionalDependencies:
|
|
||||||
graceful-fs "^4.1.6"
|
|
||||||
|
|
||||||
klaw@^4.1.0:
|
|
||||||
version "4.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/klaw/-/klaw-4.1.0.tgz#5df608067d8cb62bbfb24374f8e5d956323338f3"
|
|
||||||
integrity sha512-1zGZ9MF9H22UnkpVeuaGKOjfA2t6WrfdrJmGjy16ykcjnKQDmHVX+KI477rpbGevz/5FD4MC3xf1oxylBgcaQw==
|
|
||||||
|
|
||||||
kleur@^4.1.4:
|
|
||||||
version "4.1.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/kleur/-/kleur-4.1.5.tgz#95106101795f7050c6c650f350c683febddb1780"
|
|
||||||
integrity sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==
|
|
||||||
|
|
||||||
local-access@^1.0.1:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/local-access/-/local-access-1.1.0.tgz#e007c76ba2ca83d5877ba1a125fc8dfe23ba4798"
|
|
||||||
integrity sha512-XfegD5pyTAfb+GY6chk283Ox5z8WexG56OvM06RWLpAc/UHozO8X6xAxEkIitZOtsSMM1Yr3DkHgW5W+onLhCw==
|
|
||||||
|
|
||||||
mri@^1.1.0:
|
|
||||||
version "1.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b"
|
|
||||||
integrity sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==
|
|
||||||
|
|
||||||
mrmime@^2.0.0:
|
|
||||||
version "2.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-2.0.1.tgz#bc3e87f7987853a54c9850eeb1f1078cd44adddc"
|
|
||||||
integrity sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==
|
|
||||||
|
|
||||||
sade@^1.6.0:
|
|
||||||
version "1.8.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/sade/-/sade-1.8.1.tgz#0a78e81d658d394887be57d2a409bf703a3b2701"
|
|
||||||
integrity sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==
|
|
||||||
dependencies:
|
|
||||||
mri "^1.1.0"
|
|
||||||
|
|
||||||
semiver@^1.0.0:
|
|
||||||
version "1.1.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/semiver/-/semiver-1.1.0.tgz#9c97fb02c21c7ce4fcf1b73e2c7a24324bdddd5f"
|
|
||||||
integrity sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==
|
|
||||||
|
|
||||||
sirv-cli@^3.0.1:
|
|
||||||
version "3.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/sirv-cli/-/sirv-cli-3.0.1.tgz#9a53e4fa85fdc08d54a76fd76a7c866cd4c3988b"
|
|
||||||
integrity sha512-ICXaF2u6IQhLZ0EXF6nqUF4YODfSQSt+mGykt4qqO5rY+oIiwdg7B8w2PVDBJlQulaS2a3J8666CUoDoAuCGvg==
|
|
||||||
dependencies:
|
|
||||||
console-clear "^1.1.0"
|
|
||||||
get-port "^5.1.1"
|
|
||||||
kleur "^4.1.4"
|
|
||||||
local-access "^1.0.1"
|
|
||||||
sade "^1.6.0"
|
|
||||||
semiver "^1.0.0"
|
|
||||||
sirv "^3.0.0"
|
|
||||||
tinydate "^1.0.0"
|
|
||||||
|
|
||||||
sirv@^3.0.0:
|
|
||||||
version "3.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/sirv/-/sirv-3.0.1.tgz#32a844794655b727f9e2867b777e0060fbe07bf3"
|
|
||||||
integrity sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==
|
|
||||||
dependencies:
|
|
||||||
"@polka/url" "^1.0.0-next.24"
|
|
||||||
mrmime "^2.0.0"
|
|
||||||
totalist "^3.0.0"
|
|
||||||
|
|
||||||
tinydate@^1.0.0:
|
|
||||||
version "1.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/tinydate/-/tinydate-1.3.0.tgz#e6ca8e5a22b51bb4ea1c3a2a4fd1352dbd4c57fb"
|
|
||||||
integrity sha512-7cR8rLy2QhYHpsBDBVYnnWXm8uRTr38RoZakFSW7Bs7PzfMPNZthuMLkwqZv7MTu8lhQ91cOFYS5a7iFj2oR3w==
|
|
||||||
|
|
||||||
totalist@^3.0.0:
|
|
||||||
version "3.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8"
|
|
||||||
integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==
|
|
||||||
|
|
||||||
universalify@^2.0.0:
|
|
||||||
version "2.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d"
|
|
||||||
integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 788261ef41e083ec917ee9bee37bc5b0e4f8d153
|
Subproject commit 7e6c475f6930c122e224cc2a0fbe218005e434a4
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit a45710f80cd7b4424a2114d2a32cbb83a4d95761
|
Subproject commit 783c8d1a3e3ad6071d268b18077569262ea61602
|
||||||
64
flake.lock
64
flake.lock
|
|
@ -1,64 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": [
|
|
||||||
"systems"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1770169770,
|
|
||||||
"narHash": "sha256-awR8qIwJxJJiOmcEGgP2KUqYmHG4v/z8XpL9z8FnT1A=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "aa290c9891fa4ebe88f8889e59633d20cc06a5f2",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"systems": "systems"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
||||||
28
flake.nix
28
flake.nix
|
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
description = "Node+yarn dev shell flake";
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
||||||
systems.url = "github:nix-systems/default";
|
|
||||||
flake-utils = {
|
|
||||||
url = "github:numtide/flake-utils";
|
|
||||||
inputs.systems.follows = "systems";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs =
|
|
||||||
{ nixpkgs, flake-utils, ... }:
|
|
||||||
flake-utils.lib.eachDefaultSystem (
|
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
nodejs_24
|
|
||||||
yarn
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -8,10 +8,10 @@ if [ -z "$REMOTE" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remote Directory
|
# Remote Directory
|
||||||
REMOTE_DIR=/root/deployments/revite
|
REMOTE_DIR=/root/revite
|
||||||
|
|
||||||
# Post-install script
|
# Post-install script
|
||||||
POST_INSTALL=""
|
POST_INSTALL="pm2 restart revite"
|
||||||
|
|
||||||
# Assets
|
# Assets
|
||||||
export REVOLT_SAAS=https://github.com/revoltchat/assets
|
export REVOLT_SAAS=https://github.com/revoltchat/assets
|
||||||
|
|
|
||||||
|
|
@ -1848,109 +1848,107 @@ export const emojiDictionary = {
|
||||||
england: "🏴",
|
england: "🏴",
|
||||||
scotland: "🏴",
|
scotland: "🏴",
|
||||||
wales: "🏴",
|
wales: "🏴",
|
||||||
// ...{
|
...{
|
||||||
// 1984: "custom:1984.gif",
|
1984: "custom:1984.gif",
|
||||||
// KekW: "custom:KekW.png",
|
KekW: "custom:KekW.png",
|
||||||
// amogus: "custom:amogus.gif",
|
amogus: "custom:amogus.gif",
|
||||||
// awaa: "custom:awaa.png",
|
awaa: "custom:awaa.png",
|
||||||
// boohoo: "custom:boohoo.png",
|
boohoo: "custom:boohoo.png",
|
||||||
// boohoo_goes_hard: "custom:boohoo_goes_hard.png",
|
boohoo_goes_hard: "custom:boohoo_goes_hard.png",
|
||||||
// boohoo_shaken: "custom:boohoo_shaken.png",
|
boohoo_shaken: "custom:boohoo_shaken.png",
|
||||||
// cat_arrival: "custom:cat_arrival.gif",
|
cat_arrival: "custom:cat_arrival.gif",
|
||||||
// cat_awson: "custom:cat_awson.png",
|
cat_awson: "custom:cat_awson.png",
|
||||||
// cat_blob: "custom:cat_blob.png",
|
cat_blob: "custom:cat_blob.png",
|
||||||
// cat_bonk: "custom:cat_bonk.png",
|
cat_bonk: "custom:cat_bonk.png",
|
||||||
// cat_concern: "custom:cat_concern.png",
|
cat_concern: "custom:cat_concern.png",
|
||||||
// cat_fast: "custom:cat_fast.gif",
|
cat_fast: "custom:cat_fast.gif",
|
||||||
// cat_kitty: "custom:cat_kitty.png",
|
cat_kitty: "custom:cat_kitty.png",
|
||||||
// cat_lick: "custom:cat_lick.gif",
|
cat_lick: "custom:cat_lick.gif",
|
||||||
// cat_not_like: "custom:cat_not_like.png",
|
cat_not_like: "custom:cat_not_like.png",
|
||||||
// cat_put: "custom:cat_put.gif",
|
cat_put: "custom:cat_put.gif",
|
||||||
// cat_pwease: "custom:cat_pwease.png",
|
cat_pwease: "custom:cat_pwease.png",
|
||||||
// cat_rage: "custom:cat_rage.png",
|
cat_rage: "custom:cat_rage.png",
|
||||||
// cat_sad: "custom:cat_sad.png",
|
cat_sad: "custom:cat_sad.png",
|
||||||
// cat_snuff: "custom:cat_snuff.gif",
|
cat_snuff: "custom:cat_snuff.gif",
|
||||||
// cat_spin: "custom:cat_spin.gif",
|
cat_spin: "custom:cat_spin.gif",
|
||||||
// cat_squish: "custom:cat_squish.gif",
|
cat_squish: "custom:cat_squish.gif",
|
||||||
// cat_stare: "custom:cat_stare.gif",
|
cat_stare: "custom:cat_stare.gif",
|
||||||
// cat_steal: "custom:cat_steal.gif",
|
cat_steal: "custom:cat_steal.gif",
|
||||||
// cat_sussy: "custom:cat_sussy.gif",
|
cat_sussy: "custom:cat_sussy.gif",
|
||||||
// clueless: "custom:clueless.png",
|
clueless: "custom:clueless.png",
|
||||||
// death: "custom:death.gif",
|
death: "custom:death.gif",
|
||||||
// developers: "custom:developers.gif",
|
developers: "custom:developers.gif",
|
||||||
// fastwawa: "custom:fastwawa.gif",
|
fastwawa: "custom:fastwawa.gif",
|
||||||
// ferris: "custom:ferris.png",
|
ferris: "custom:ferris.png",
|
||||||
// ferris_bongo: "custom:ferris_bongo.gif",
|
ferris_bongo: "custom:ferris_bongo.gif",
|
||||||
// ferris_nom: "custom:ferris_nom.png",
|
ferris_nom: "custom:ferris_nom.png",
|
||||||
// ferris_pensive: "custom:ferris_pensive.png",
|
ferris_pensive: "custom:ferris_pensive.png",
|
||||||
// ferris_unsafe: "custom:ferris_unsafe.png",
|
ferris_unsafe: "custom:ferris_unsafe.png",
|
||||||
// flesh: "custom:flesh.png",
|
flesh: "custom:flesh.png",
|
||||||
// flooshed: "custom:flooshed.png",
|
flooshed: "custom:flooshed.png",
|
||||||
// flosh: "custom:flosh.png",
|
flosh: "custom:flosh.png",
|
||||||
// flushee: "custom:flushee.png",
|
flushee: "custom:flushee.png",
|
||||||
// forgor: "custom:forgor.png",
|
forgor: "custom:forgor.png",
|
||||||
// hollow: "custom:hollow.png",
|
hollow: "custom:hollow.png",
|
||||||
// john: "custom:john.png",
|
john: "custom:john.png",
|
||||||
// lightspeed: "custom:lightspeed.png",
|
lightspeed: "custom:lightspeed.png",
|
||||||
// little_guy: "custom:little_guy.png",
|
little_guy: "custom:little_guy.png",
|
||||||
// lmaoooo: "custom:lmaoooo.gif",
|
lmaoooo: "custom:lmaoooo.gif",
|
||||||
// lol: "custom:lol.png",
|
lol: "custom:lol.png",
|
||||||
// looking: "custom:looking.gif",
|
looking: "custom:looking.gif",
|
||||||
// marie: "custom:marie.png",
|
marie: "custom:marie.png",
|
||||||
// marie_furret: "custom:marie_furret.gif",
|
marie_furret: "custom:marie_furret.gif",
|
||||||
// marie_smug: "custom:marie_smug.png",
|
marie_smug: "custom:marie_smug.png",
|
||||||
// megumin: "custom:megumin.png",
|
megumin: "custom:megumin.png",
|
||||||
// michi_above: "custom:michi_above.png",
|
michi_above: "custom:michi_above.png",
|
||||||
// michi_awww: "custom:michi_awww.gif",
|
michi_awww: "custom:michi_awww.gif",
|
||||||
// michi_drag: "custom:michi_drag.gif",
|
michi_drag: "custom:michi_drag.gif",
|
||||||
// michi_flustered: "custom:michi_flustered.png",
|
michi_flustered: "custom:michi_flustered.png",
|
||||||
// michi_glare: "custom:michi_glare.png",
|
michi_glare: "custom:michi_glare.png",
|
||||||
// michi_sus: "custom:michi_sus.png",
|
michi_sus: "custom:michi_sus.png",
|
||||||
// monkaS: "custom:monkaS.png",
|
monkaS: "custom:monkaS.png",
|
||||||
// monkaStare: "custom:monkaStare.png",
|
monkaStare: "custom:monkaStare.png",
|
||||||
// monkey_grr: "custom:monkey_grr.png",
|
monkey_grr: "custom:monkey_grr.png",
|
||||||
// monkey_pensive: "custom:monkey_pensive.png",
|
monkey_pensive: "custom:monkey_pensive.png",
|
||||||
// monkey_zany: "custom:monkey_zany.png",
|
monkey_zany: "custom:monkey_zany.png",
|
||||||
// nazu_sit: "custom:nazu_sit.png",
|
nazu_sit: "custom:nazu_sit.png",
|
||||||
// nazu_sus: "custom:nazu_sus.png",
|
nazu_sus: "custom:nazu_sus.png",
|
||||||
// ok_and: "custom:ok_and.gif",
|
ok_and: "custom:ok_and.gif",
|
||||||
// owo: "custom:owo.png",
|
owo: "custom:owo.png",
|
||||||
// pat: "custom:pat.png",
|
pat: "custom:pat.png",
|
||||||
// pointThink: "custom:pointThink.png",
|
pointThink: "custom:pointThink.png",
|
||||||
// rainbowHype: "custom:rainbowHype.gif",
|
rainbowHype: "custom:rainbowHype.gif",
|
||||||
// rawr: "custom:rawr.png",
|
rawr: "custom:rawr.png",
|
||||||
// rember: "custom:rember.png",
|
rember: "custom:rember.png",
|
||||||
// revolt: "custom:revolt.png",
|
revolt: "custom:revolt.png",
|
||||||
// sickly: "custom:sickly.png",
|
sickly: "custom:sickly.png",
|
||||||
// stare: "custom:stare.png",
|
stare: "custom:stare.png",
|
||||||
// tfyoulookingat: "custom:tfyoulookingat.png",
|
tfyoulookingat: "custom:tfyoulookingat.png",
|
||||||
// thanks: "custom:thanks.png",
|
thanks: "custom:thanks.png",
|
||||||
// thonk: "custom:thonk.png",
|
thonk: "custom:thonk.png",
|
||||||
// trol: "custom:trol.png",
|
trol: "custom:trol.png",
|
||||||
// troll_smile: "custom:troll_smile.gif",
|
troll_smile: "custom:troll_smile.gif",
|
||||||
// uber: "custom:uber.png",
|
uber: "custom:uber.png",
|
||||||
// ubertroll: "custom:ubertroll.png",
|
ubertroll: "custom:ubertroll.png",
|
||||||
// verycool: "custom:verycool.png",
|
verycool: "custom:verycool.png",
|
||||||
// verygood: "custom:verygood.png",
|
verygood: "custom:verygood.png",
|
||||||
// wawafast: "custom:wawafast.gif",
|
wawafast: "custom:wawafast.gif",
|
||||||
// wawastance: "custom:wawastance.png",
|
wawastance: "custom:wawastance.png",
|
||||||
// yeahokayyy: "custom:yeahokayyy.png",
|
yeahokayyy: "custom:yeahokayyy.png",
|
||||||
// yed: "custom:yed.png",
|
yed: "custom:yed.png",
|
||||||
// yems: "custom:yems.png",
|
yems: "custom:yems.png",
|
||||||
// michael: "custom:michael.gif",
|
michael: "custom:michael.gif",
|
||||||
// charle: "custom:charle.gif",
|
charle: "custom:charle.gif",
|
||||||
// sadge: "custom:sadge.webp",
|
sadge: "custom:sadge.webp",
|
||||||
// sus: "custom:sus.webp",
|
sus: "custom:sus.webp",
|
||||||
// chade: "custom:chade.gif",
|
sippy: "custom:sippy.webp",
|
||||||
// gigachad: "custom:gigachad.webp",
|
ayame_heart: "custom:ayame_heart.png",
|
||||||
// sippy: "custom:sippy.webp",
|
catgirl_peek: "custom:catgirl_peek.png",
|
||||||
// ayame_heart: "custom:ayame_heart.png",
|
girl_happy: "custom:girl_happy.png",
|
||||||
// catgirl_peek: "custom:catgirl_peek.png",
|
hug_plushie: "custom:hug_plushie.png",
|
||||||
// girl_happy: "custom:girl_happy.png",
|
huggies: "custom:huggies.png",
|
||||||
// hug_plushie: "custom:hug_plushie.png",
|
noted: "custom:noted.gif",
|
||||||
// huggies: "custom:huggies.png",
|
waving: "custom:waving.png",
|
||||||
// noted: "custom:noted.gif",
|
mogusvented: "custom:mogusvented.png",
|
||||||
// waving: "custom:waving.png",
|
},
|
||||||
// mogusvented: "custom:mogusvented.png",
|
|
||||||
// },
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@ import { Channel } from "revolt.js";
|
||||||
import styled from "styled-components/macro";
|
import styled from "styled-components/macro";
|
||||||
|
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useEffect, useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
|
|
||||||
import { Button, Checkbox, Preloader } from "@revoltchat/ui";
|
import { Button, Checkbox } from "@revoltchat/ui";
|
||||||
|
|
||||||
import { useApplicationState } from "../../mobx/State";
|
import { useApplicationState } from "../../mobx/State";
|
||||||
import { SECTION_NSFW } from "../../mobx/stores/Layout";
|
import { SECTION_NSFW } from "../../mobx/stores/Layout";
|
||||||
|
|
@ -45,36 +45,14 @@ type Props = {
|
||||||
channel: Channel;
|
channel: Channel;
|
||||||
};
|
};
|
||||||
|
|
||||||
let geoBlock:
|
|
||||||
| undefined
|
|
||||||
| {
|
|
||||||
countryCode: string;
|
|
||||||
isAgeRestrictedGeo: true;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default observer((props: Props) => {
|
export default observer((props: Props) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const layout = useApplicationState().layout;
|
const layout = useApplicationState().layout;
|
||||||
const [geoLoaded, setGeoLoaded] = useState(typeof geoBlock !== "undefined");
|
|
||||||
const [ageGate, setAgeGate] = useState(false);
|
const [ageGate, setAgeGate] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
if (ageGate || !props.gated) {
|
||||||
if (!geoLoaded) {
|
|
||||||
fetch("https://geo.revolt.chat")
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then((data) => {
|
|
||||||
geoBlock = data;
|
|
||||||
setGeoLoaded(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (!geoBlock) return <Preloader type="spinner" />;
|
|
||||||
|
|
||||||
if ((ageGate && !geoBlock.isAgeRestrictedGeo) || !props.gated) {
|
|
||||||
return <>{props.children}</>;
|
return <>{props.children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
props.channel.channel_type === "Group" ||
|
props.channel.channel_type === "Group" ||
|
||||||
|
|
@ -98,40 +76,23 @@ export default observer((props: Props) => {
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
{geoBlock.isAgeRestrictedGeo ? (
|
<Checkbox
|
||||||
<div style={{ maxWidth: "420px", textAlign: "center" }}>
|
title={<Text id="app.main.channel.nsfw.confirm" />}
|
||||||
{geoBlock.countryCode === "GB"
|
value={layout.getSectionState(SECTION_NSFW, false)}
|
||||||
? "This channel is not available in your region while we review options on legal compliance."
|
onChange={() => layout.toggleSectionState(SECTION_NSFW, false)}
|
||||||
: "This content is not available in your region."}
|
/>
|
||||||
</div>
|
<div className="actions">
|
||||||
) : (
|
<Button palette="secondary" onClick={() => history.goBack()}>
|
||||||
<>
|
<Text id="app.special.modals.actions.back" />
|
||||||
<Checkbox
|
</Button>
|
||||||
title={<Text id="app.main.channel.nsfw.confirm" />}
|
<Button
|
||||||
value={layout.getSectionState(SECTION_NSFW, false)}
|
palette="secondary"
|
||||||
onChange={() =>
|
onClick={() =>
|
||||||
layout.toggleSectionState(SECTION_NSFW, false)
|
layout.getSectionState(SECTION_NSFW) && setAgeGate(true)
|
||||||
}
|
}>
|
||||||
/>
|
<Text id={`app.main.channel.nsfw.${props.type}.confirm`} />
|
||||||
<div className="actions">
|
</Button>
|
||||||
<Button
|
</div>
|
||||||
palette="secondary"
|
|
||||||
onClick={() => history.goBack()}>
|
|
||||||
<Text id="app.special.modals.actions.back" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
palette="secondary"
|
|
||||||
onClick={() =>
|
|
||||||
layout.getSectionState(SECTION_NSFW) &&
|
|
||||||
setAgeGate(true)
|
|
||||||
}>
|
|
||||||
<Text
|
|
||||||
id={`app.main.channel.nsfw.${props.type}.confirm`}
|
|
||||||
/>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Base>
|
</Base>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -43,11 +43,11 @@ function toCodePoint(rune: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseEmoji(emoji: string) {
|
export function parseEmoji(emoji: string) {
|
||||||
// if (emoji.startsWith("custom:")) {
|
if (emoji.startsWith("custom:")) {
|
||||||
// return `https://dl.insrt.uk/projects/revolt/emotes/${emoji.substring(
|
return `https://dl.insrt.uk/projects/revolt/emotes/${emoji.substring(
|
||||||
// 7,
|
7,
|
||||||
// )}`;
|
)}`;
|
||||||
// }
|
}
|
||||||
|
|
||||||
const codepoint = toCodePoint(emoji);
|
const codepoint = toCodePoint(emoji);
|
||||||
return `https://static.revolt.chat/emoji/${EMOJI_PACK}/${codepoint}.svg?rev=${REVISION}`;
|
return `https://static.revolt.chat/emoji/${EMOJI_PACK}/${codepoint}.svg?rev=${REVISION}`;
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ export default observer(({ channel }: Props) => {
|
||||||
if (!state.draft.has(channel._id)) {
|
if (!state.draft.has(channel._id)) {
|
||||||
setMessage(text);
|
setMessage(text);
|
||||||
} else {
|
} else {
|
||||||
setMessage(`${state.draft.get(channel._id)?.content}\n${text}`);
|
setMessage(`${state.draft.get(channel._id)}\n${text}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ export default observer(({ channel }: Props) => {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const content = state.draft.get(channel._id)?.content?.trim() ?? "";
|
const content = state.draft.get(channel._id)?.content?.trim() ?? "";
|
||||||
if (uploadState.type !== "none") return sendFile(content);
|
if (uploadState.type === "attached") return sendFile(content);
|
||||||
if (content.length === 0) return;
|
if (content.length === 0) return;
|
||||||
|
|
||||||
internalEmit("NewMessages", "hide");
|
internalEmit("NewMessages", "hide");
|
||||||
|
|
@ -406,9 +406,7 @@ export default observer(({ channel }: Props) => {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async function sendFile(content: string) {
|
async function sendFile(content: string) {
|
||||||
if (uploadState.type !== "attached" && uploadState.type !== "failed")
|
if (uploadState.type !== "attached") return;
|
||||||
return;
|
|
||||||
|
|
||||||
const attachments: string[] = [];
|
const attachments: string[] = [];
|
||||||
setMessage;
|
setMessage;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ export default function AttachmentActions({ attachment }: Props) {
|
||||||
const { filename, metadata, size } = attachment;
|
const { filename, metadata, size } = attachment;
|
||||||
|
|
||||||
const url = client.generateFileURL(attachment);
|
const url = client.generateFileURL(attachment);
|
||||||
const open_url = url;
|
const open_url = `${url}/${filename}`;
|
||||||
const download_url = `${url}/${filename}`;
|
const download_url = url?.replace("attachments", "attachments/download");
|
||||||
|
|
||||||
const filesize = determineFileSize(size);
|
const filesize = determineFileSize(size);
|
||||||
|
|
||||||
|
|
@ -49,11 +49,10 @@ export default function AttachmentActions({ attachment }: Props) {
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
|
||||||
href={download_url}
|
href={download_url}
|
||||||
className={styles.downloadIcon}
|
className={styles.downloadIcon}
|
||||||
download
|
download
|
||||||
// target={isFirefox || window.native ? "_blank" : "_self"}
|
target={isFirefox || window.native ? "_blank" : "_self"}
|
||||||
rel="noreferrer">
|
rel="noreferrer">
|
||||||
<IconButton>
|
<IconButton>
|
||||||
<Download size={24} />
|
<Download size={24} />
|
||||||
|
|
|
||||||
|
|
@ -126,16 +126,8 @@ export function EmbedInvite({ code }: Props) {
|
||||||
<EmbedInviteName>{invite.server_name}</EmbedInviteName>
|
<EmbedInviteName>{invite.server_name}</EmbedInviteName>
|
||||||
<EmbedInviteMemberCount>
|
<EmbedInviteMemberCount>
|
||||||
<Group size={12} />
|
<Group size={12} />
|
||||||
{invite.member_count != null ? (
|
{invite.member_count.toLocaleString()}{" "}
|
||||||
<>
|
{invite.member_count === 1 ? "member" : "members"}
|
||||||
{invite.member_count.toLocaleString()}{" "}
|
|
||||||
{invite.member_count === 1
|
|
||||||
? "member"
|
|
||||||
: "members"}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
"N/A"
|
|
||||||
)}
|
|
||||||
</EmbedInviteMemberCount>
|
</EmbedInviteMemberCount>
|
||||||
</EmbedInviteDetails>
|
</EmbedInviteDetails>
|
||||||
{processing ? (
|
{processing ? (
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ export default function UserBadges({ badges, uid }: Props) {
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(
|
window.open(
|
||||||
"https://wiki.revolt.chat/notes/project/financial-support/",
|
"https://insrt.uk/donate",
|
||||||
"_blank",
|
"_blank",
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -185,8 +185,7 @@ const Container = styled.div<{ largeEmoji: boolean }>`
|
||||||
/**
|
/**
|
||||||
* Regex for matching execessive recursion of blockquotes and lists
|
* Regex for matching execessive recursion of blockquotes and lists
|
||||||
*/
|
*/
|
||||||
const RE_RECURSIVE =
|
const RE_RECURSIVE = /(^(?:[>*+-][^\S\r\n]*){5})(?:[>*+-][^\S\r\n]*)+(.*$)/gm;
|
||||||
/(^(?:(?:[>*+-]|\d+\.)[^\S\r\n]*){5})(?:(?:[>*+-]|\d+\.)[^\S\r\n]*)+(.*$)/gm;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regex for matching multi-line blockquotes
|
* Regex for matching multi-line blockquotes
|
||||||
|
|
@ -248,13 +247,9 @@ export default memo(({ content, disallowBigEmoji }: MarkdownProps) => {
|
||||||
const [Content, setContent] = useState<React.ReactElement>(null!);
|
const [Content, setContent] = useState<React.ReactElement>(null!);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
try {
|
render
|
||||||
render
|
.process(sanitisedContent)
|
||||||
.process(sanitisedContent)
|
.then((file) => setContent(file.result));
|
||||||
.then((file) => setContent(file.result));
|
|
||||||
} catch (err) {
|
|
||||||
setContent("Message failed to render." as never);
|
|
||||||
}
|
|
||||||
}, [sanitisedContent]);
|
}, [sanitisedContent]);
|
||||||
|
|
||||||
const largeEmoji = useMemo(
|
const largeEmoji = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export function RenderEmoji({ match }: CustomComponentProps) {
|
||||||
? `${
|
? `${
|
||||||
clientController.getAvailableClient().configuration?.features
|
clientController.getAvailableClient().configuration?.features
|
||||||
.autumn.url
|
.autumn.url
|
||||||
}/emojis/${match}/original`
|
}/emojis/${match}`
|
||||||
: parseEmoji(
|
: parseEmoji(
|
||||||
match in emojiDictionary
|
match in emojiDictionary
|
||||||
? emojiDictionary[match as keyof typeof emojiDictionary]
|
? emojiDictionary[match as keyof typeof emojiDictionary]
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,8 @@ const ServerList = styled.div`
|
||||||
export default observer(() => {
|
export default observer(() => {
|
||||||
const client = useClient();
|
const client = useClient();
|
||||||
const state = useApplicationState();
|
const state = useApplicationState();
|
||||||
const { server: server_id, channel: channel_id } = useParams<{
|
const { server: server_id, channel: channel_id } =
|
||||||
server: string;
|
useParams<{ server: string; channel?: string }>();
|
||||||
channel?: string;
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const server = client.servers.get(server_id);
|
const server = client.servers.get(server_id);
|
||||||
if (!server) return <Redirect to="/" />;
|
if (!server) return <Redirect to="/" />;
|
||||||
|
|
@ -121,18 +119,14 @@ export default observer(() => {
|
||||||
channels.push(addChannel(id));
|
channels.push(addChannel(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (category.title === "Default") {
|
elements.push(
|
||||||
elements.push(...channels);
|
<CollapsibleSection
|
||||||
} else {
|
id={`category_${category.id}`}
|
||||||
elements.push(
|
defaultValue
|
||||||
<CollapsibleSection
|
summary={<Category>{category.title}</Category>}>
|
||||||
id={`category_${category.id}`}
|
{channels}
|
||||||
defaultValue
|
</CollapsibleSection>,
|
||||||
summary={<Category>{category.title}</Category>}>
|
);
|
||||||
{channels}
|
|
||||||
</CollapsibleSection>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,25 +76,17 @@ function useEntries(
|
||||||
|
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
let u;
|
let u;
|
||||||
let member;
|
|
||||||
|
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
const { server, user } = JSON.parse(key);
|
const { server, user } = JSON.parse(key);
|
||||||
if (server !== channel.server_id) return;
|
if (server !== channel.server_id) return;
|
||||||
|
|
||||||
u = client.users.get(user);
|
u = client.users.get(user);
|
||||||
member = client.members.get(key);
|
|
||||||
|
|
||||||
if (!member?.hasPermission(channel, "ViewChannel")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
u = client.users.get(key);
|
u = client.users.get(key);
|
||||||
member = client.members.get(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u) return;
|
if (!u) return;
|
||||||
|
|
||||||
|
const member = client.members.get(key);
|
||||||
const sort = member?.nickname ?? u.username;
|
const sort = member?.nickname ?? u.username;
|
||||||
const entry = [u, sort] as [User, string];
|
const entry = [u, sort] as [User, string];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ export default function AccountManagement() {
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
icon={<Block size={24} color="var(--error)" />}
|
icon={<Block size={24} color="var(--error)" />}
|
||||||
description={
|
description={
|
||||||
<Text id="app.settings.pages.account.manage.disable_description" />
|
"Disable your account. You won't be able to access it unless you contact support."
|
||||||
}
|
}
|
||||||
action="chevron"
|
action="chevron"
|
||||||
onClick={callback("disable")}>
|
onClick={callback("disable")}>
|
||||||
|
|
@ -49,7 +49,7 @@ export default function AccountManagement() {
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
icon={<Trash size={24} color="var(--error)" />}
|
icon={<Trash size={24} color="var(--error)" />}
|
||||||
description={
|
description={
|
||||||
<Text id="app.settings.pages.account.manage.delete_description" />
|
"Your account will be queued for deletion, a confirmation email will be sent."
|
||||||
}
|
}
|
||||||
action="chevron"
|
action="chevron"
|
||||||
onClick={callback("delete")}>
|
onClick={callback("delete")}>
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ class ClientController {
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
const error = takeError(err);
|
const error = takeError(err);
|
||||||
if (error === "Unauthorized") {
|
if (error === "Forbidden" || error === "Unauthorized") {
|
||||||
this.sessions.delete(user_id);
|
this.sessions.delete(user_id);
|
||||||
this.current = null;
|
this.current = null;
|
||||||
this.pickNextSession();
|
this.pickNextSession();
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ type Transition =
|
||||||
| "SUCCESS"
|
| "SUCCESS"
|
||||||
| "DISCONNECT"
|
| "DISCONNECT"
|
||||||
| "RETRY"
|
| "RETRY"
|
||||||
| "RETRY_FAILED"
|
|
||||||
| "LOGOUT"
|
| "LOGOUT"
|
||||||
| "ONLINE"
|
| "ONLINE"
|
||||||
| "OFFLINE";
|
| "OFFLINE";
|
||||||
|
|
@ -41,7 +40,6 @@ export default class Session {
|
||||||
state: State = window.navigator.onLine ? "Ready" : "Offline";
|
state: State = window.navigator.onLine ? "Ready" : "Offline";
|
||||||
user_id: string | null = null;
|
user_id: string | null = null;
|
||||||
client: Client | null = null;
|
client: Client | null = null;
|
||||||
retryAttempts: number = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Session
|
* Create a new Session
|
||||||
|
|
@ -91,11 +89,9 @@ export default class Session {
|
||||||
* Called when the client signals it has disconnected
|
* Called when the client signals it has disconnected
|
||||||
*/
|
*/
|
||||||
private onDropped() {
|
private onDropped() {
|
||||||
if (this.state === "Connecting") {
|
this.emit({
|
||||||
this.emit({ action: "RETRY_FAILED" });
|
action: "DISCONNECT",
|
||||||
} else {
|
});
|
||||||
this.emit({ action: "DISCONNECT" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -215,7 +211,6 @@ export default class Session {
|
||||||
// Ready successfully received
|
// Ready successfully received
|
||||||
case "SUCCESS": {
|
case "SUCCESS": {
|
||||||
this.assert("Connecting");
|
this.assert("Connecting");
|
||||||
this.retryAttempts = 0;
|
|
||||||
this.state = "Online";
|
this.state = "Online";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -244,18 +239,6 @@ export default class Session {
|
||||||
this.state = "Connecting";
|
this.state = "Connecting";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Reconnect attempt failed, schedule another with backoff
|
|
||||||
case "RETRY_FAILED": {
|
|
||||||
this.assert("Connecting");
|
|
||||||
this.retryAttempts++;
|
|
||||||
const delay = Math.min(500 * Math.pow(2, this.retryAttempts), 16000);
|
|
||||||
setTimeout(() => {
|
|
||||||
if (this.state === "Connecting") {
|
|
||||||
this.client!.websocket.connect();
|
|
||||||
}
|
|
||||||
}, delay);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// User instructed logout
|
// User instructed logout
|
||||||
case "LOGOUT": {
|
case "LOGOUT": {
|
||||||
this.assert("Connecting", "Online", "Disconnected");
|
this.assert("Connecting", "Online", "Disconnected");
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ export function takeError(error: any): string {
|
||||||
case 429:
|
case 429:
|
||||||
return "TooManyRequests";
|
return "TooManyRequests";
|
||||||
case 401:
|
case 401:
|
||||||
return "Unauthorized"
|
|
||||||
case 403:
|
case 403:
|
||||||
return "Forbidden";
|
return "Unauthorized";
|
||||||
default:
|
default:
|
||||||
return "UnknownError";
|
return "UnknownError";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { IconButton, Preloader } from "@revoltchat/ui";
|
||||||
import { determineFileSize } from "../../../../lib/fileSize";
|
import { determineFileSize } from "../../../../lib/fileSize";
|
||||||
|
|
||||||
import { modalController } from "../../../modals/ModalController";
|
import { modalController } from "../../../modals/ModalController";
|
||||||
import { clientController, useClient } from "../../ClientController";
|
import { useClient } from "../../ClientController";
|
||||||
import { takeError } from "../error";
|
import { takeError } from "../error";
|
||||||
|
|
||||||
type BehaviourType =
|
type BehaviourType =
|
||||||
|
|
@ -67,16 +67,9 @@ export async function uploadFile(
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
|
|
||||||
const client = clientController.getActiveSession()?.client;
|
|
||||||
const sesToken =
|
|
||||||
typeof client?.session === "string"
|
|
||||||
? client.session
|
|
||||||
: client?.session?.token;
|
|
||||||
|
|
||||||
const res = await Axios.post(`${autumnURL}/${tag}`, formData, {
|
const res = await Axios.post(`${autumnURL}/${tag}`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
"X-Session-Token": sesToken,
|
|
||||||
},
|
},
|
||||||
...config,
|
...config,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import CreateRole from "./components/CreateRole";
|
||||||
import CreateServer from "./components/CreateServer";
|
import CreateServer from "./components/CreateServer";
|
||||||
import CustomStatus from "./components/CustomStatus";
|
import CustomStatus from "./components/CustomStatus";
|
||||||
import DeleteMessage from "./components/DeleteMessage";
|
import DeleteMessage from "./components/DeleteMessage";
|
||||||
import ReactMessage from "./components/ReactMessage";
|
|
||||||
import Error from "./components/Error";
|
import Error from "./components/Error";
|
||||||
import ImageViewer from "./components/ImageViewer";
|
import ImageViewer from "./components/ImageViewer";
|
||||||
import KickMember from "./components/KickMember";
|
import KickMember from "./components/KickMember";
|
||||||
|
|
@ -276,7 +275,6 @@ export const modalController = new ModalControllerExtended({
|
||||||
create_bot: CreateBot,
|
create_bot: CreateBot,
|
||||||
custom_status: CustomStatus,
|
custom_status: CustomStatus,
|
||||||
delete_message: DeleteMessage,
|
delete_message: DeleteMessage,
|
||||||
react_message: ReactMessage,
|
|
||||||
error: Error,
|
error: Error,
|
||||||
image_viewer: ImageViewer,
|
image_viewer: ImageViewer,
|
||||||
kick_member: KickMember,
|
kick_member: KickMember,
|
||||||
|
|
@ -299,5 +297,4 @@ export const modalController = new ModalControllerExtended({
|
||||||
report_success: ReportSuccess,
|
report_success: ReportSuccess,
|
||||||
modify_displayname: ModifyDisplayname,
|
modify_displayname: ModifyDisplayname,
|
||||||
changelog_usernames: ChangelogUsernames,
|
changelog_usernames: ChangelogUsernames,
|
||||||
reset_bot_token: Confirmation
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ export default function Confirmation(
|
||||||
| "delete_bot"
|
| "delete_bot"
|
||||||
| "block_user"
|
| "block_user"
|
||||||
| "unfriend_user"
|
| "unfriend_user"
|
||||||
| "reset_bot_token"
|
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
@ -32,7 +31,6 @@ export default function Confirmation(
|
||||||
delete_bot: ["confirm_delete", "delete"],
|
delete_bot: ["confirm_delete", "delete"],
|
||||||
unfriend_user: ["unfriend_user", "remove"],
|
unfriend_user: ["unfriend_user", "remove"],
|
||||||
block_user: ["block_user", "block"],
|
block_user: ["block_user", "block"],
|
||||||
reset_bot_token: ["reset_bot_token", "reset"],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const event = EVENTS[props.type];
|
const event = EVENTS[props.type];
|
||||||
|
|
@ -90,12 +88,6 @@ export default function Confirmation(
|
||||||
.bots.delete(props.target);
|
.bots.delete(props.target);
|
||||||
props.cb?.();
|
props.cb?.();
|
||||||
break;
|
break;
|
||||||
case "reset_bot_token":
|
|
||||||
clientController
|
|
||||||
.getAvailableClient()
|
|
||||||
.bots
|
|
||||||
.edit(props.target.id, { remove: ["Token"] })
|
|
||||||
.then(props.callback)
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
submit={{
|
submit={{
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
import styled from "styled-components";
|
|
||||||
|
|
||||||
import { Modal } from "@revoltchat/ui";
|
|
||||||
import { ModalProps } from "../types"
|
|
||||||
|
|
||||||
import { Message } from "revolt.js";
|
|
||||||
import { emojiDictionary } from "../../../assets/emojis"
|
|
||||||
import { HackAlertThisFileWillBeReplaced } from "../../../components/common/messaging/MessageBox"
|
|
||||||
|
|
||||||
const PickerContainer = styled.div`
|
|
||||||
max-height: 420px;
|
|
||||||
max-width: 370px;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
> div {
|
|
||||||
position: unset;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
|
|
||||||
export default function ReactMessage({
|
|
||||||
target: message,
|
|
||||||
onClose,
|
|
||||||
...props
|
|
||||||
}: ModalProps<"react_message">) {
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
{...props}
|
|
||||||
padding={false}
|
|
||||||
maxWidth="370px"
|
|
||||||
>
|
|
||||||
<PickerContainer>
|
|
||||||
<HackAlertThisFileWillBeReplaced
|
|
||||||
onSelect={(emoji) =>{
|
|
||||||
message.react(
|
|
||||||
emojiDictionary[
|
|
||||||
emoji as keyof typeof emojiDictionary
|
|
||||||
] ?? emoji,
|
|
||||||
);
|
|
||||||
onClose();
|
|
||||||
}}
|
|
||||||
onClose={onClose}
|
|
||||||
/>
|
|
||||||
</PickerContainer>
|
|
||||||
</Modal>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { Text } from "preact-i18n";
|
||||||
import { Column, H1, IconButton, Modal, Row } from "@revoltchat/ui";
|
import { Column, H1, IconButton, Modal, Row } from "@revoltchat/ui";
|
||||||
|
|
||||||
import Markdown from "../../../components/markdown/Markdown";
|
import Markdown from "../../../components/markdown/Markdown";
|
||||||
import { useClient } from "../../client/ClientController";
|
|
||||||
import { report } from "../../safety";
|
import { report } from "../../safety";
|
||||||
import { modalController } from "../ModalController";
|
import { modalController } from "../ModalController";
|
||||||
import { ModalProps } from "../types";
|
import { ModalProps } from "../types";
|
||||||
|
|
@ -14,49 +13,6 @@ export default function ServerInfo({
|
||||||
server,
|
server,
|
||||||
...props
|
...props
|
||||||
}: ModalProps<"server_info">) {
|
}: ModalProps<"server_info">) {
|
||||||
const client = useClient();
|
|
||||||
const isOwner = server.owner === client.user?._id;
|
|
||||||
|
|
||||||
const actions = [
|
|
||||||
{
|
|
||||||
onClick: () => {
|
|
||||||
modalController.push({
|
|
||||||
type: "server_identity",
|
|
||||||
member: server.member!,
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
children: "Edit Identity",
|
|
||||||
palette: "primary",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!isOwner) {
|
|
||||||
actions.push({
|
|
||||||
onClick: () => {
|
|
||||||
modalController.push({
|
|
||||||
type: "leave_server",
|
|
||||||
target: server,
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
children: "Leave Server",
|
|
||||||
palette: "error",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
actions.push({
|
|
||||||
onClick: () => {
|
|
||||||
modalController.push({
|
|
||||||
type: "report",
|
|
||||||
target: server,
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
children: <Text id="app.special.modals.actions.report" />,
|
|
||||||
palette: "error",
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
{...props}
|
{...props}
|
||||||
|
|
@ -70,7 +26,30 @@ export default function ServerInfo({
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Row>
|
</Row>
|
||||||
}
|
}
|
||||||
actions={actions}>
|
actions={[
|
||||||
|
{
|
||||||
|
onClick: () => {
|
||||||
|
modalController.push({
|
||||||
|
type: "server_identity",
|
||||||
|
member: server.member!,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
children: "Edit Identity",
|
||||||
|
palette: "primary",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => {
|
||||||
|
modalController.push({
|
||||||
|
type: "report",
|
||||||
|
target: server,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
children: <Text id="app.special.modals.actions.report" />,
|
||||||
|
palette: "error",
|
||||||
|
},
|
||||||
|
]}>
|
||||||
<Markdown content={server.description!} />
|
<Markdown content={server.description!} />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import {
|
||||||
UserX,
|
UserX,
|
||||||
Group,
|
Group,
|
||||||
InfoCircle,
|
InfoCircle,
|
||||||
Flag,
|
|
||||||
} from "@styled-icons/boxicons-solid";
|
} from "@styled-icons/boxicons-solid";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Link, useHistory } from "react-router-dom";
|
import { Link, useHistory } from "react-router-dom";
|
||||||
|
|
@ -247,24 +246,6 @@ export const UserProfile = observer(
|
||||||
<UserX size={28} />
|
<UserX size={28} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
{!user.bot && flags != 2 && flags != 4 && (
|
|
||||||
<Localizer>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
<Text id="app.context_menu.report_user" />
|
|
||||||
}>
|
|
||||||
<IconButton
|
|
||||||
onClick={() =>
|
|
||||||
modalController.push({
|
|
||||||
type: "report",
|
|
||||||
target: user,
|
|
||||||
})
|
|
||||||
}>
|
|
||||||
<Flag size={28} />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
</Localizer>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{badges > 0 && (
|
{badges > 0 && (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,6 @@ export type Modal = {
|
||||||
type: "delete_message";
|
type: "delete_message";
|
||||||
target: Message;
|
target: Message;
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
type: "react_message",
|
|
||||||
target: Message;
|
|
||||||
}
|
|
||||||
| {
|
| {
|
||||||
type: "kick_member";
|
type: "kick_member";
|
||||||
member: Member;
|
member: Member;
|
||||||
|
|
@ -194,11 +190,6 @@ export type Modal = {
|
||||||
type: "report_success";
|
type: "report_success";
|
||||||
user?: User;
|
user?: User;
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
type: "reset_bot_token";
|
|
||||||
target: { name: string, id: string },
|
|
||||||
callback: () => Promise<void>;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export type ModalProps<T extends Modal["type"]> = Modal & { type: T } & {
|
export type ModalProps<T extends Modal["type"]> = Modal & { type: T } & {
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,32 @@ import { ChevronRight, Trash } from "@styled-icons/boxicons-regular";
|
||||||
import { Cog, UserVoice } from "@styled-icons/boxicons-solid";
|
import { Cog, UserVoice } from "@styled-icons/boxicons-solid";
|
||||||
import { isFirefox } from "react-device-detect";
|
import { isFirefox } from "react-device-detect";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
import { Channel, Message, Server, User, API, Permission, UserPermission, Member } from "revolt.js";
|
import {
|
||||||
|
Channel,
|
||||||
|
Message,
|
||||||
|
Server,
|
||||||
|
User,
|
||||||
|
API,
|
||||||
|
Permission,
|
||||||
|
UserPermission,
|
||||||
|
Member,
|
||||||
|
} from "revolt.js";
|
||||||
|
|
||||||
|
import {
|
||||||
|
ContextMenuWithData,
|
||||||
import { ContextMenuWithData, MenuItem, openContextMenu } from "preact-context-menu";
|
MenuItem,
|
||||||
|
openContextMenu,
|
||||||
|
} from "preact-context-menu";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { Column, IconButton, LineDivider } from "@revoltchat/ui";
|
import { Column, IconButton, LineDivider } from "@revoltchat/ui";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import { useApplicationState } from "../mobx/State";
|
import { useApplicationState } from "../mobx/State";
|
||||||
import { QueuedMessage } from "../mobx/stores/MessageQueue";
|
import { QueuedMessage } from "../mobx/stores/MessageQueue";
|
||||||
import { NotificationState } from "../mobx/stores/NotificationOptions";
|
import { NotificationState } from "../mobx/stores/NotificationOptions";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import CMNotifications from "./contextmenu/CMNotifications";
|
import CMNotifications from "./contextmenu/CMNotifications";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import Tooltip from "../components/common/Tooltip";
|
import Tooltip from "../components/common/Tooltip";
|
||||||
import UserStatus from "../components/common/user/UserStatus";
|
import UserStatus from "../components/common/user/UserStatus";
|
||||||
import { useSession } from "../controllers/client/ClientController";
|
import { useSession } from "../controllers/client/ClientController";
|
||||||
|
|
@ -33,7 +36,6 @@ import { modalController } from "../controllers/modals/ModalController";
|
||||||
import { internalEmit } from "./eventEmitter";
|
import { internalEmit } from "./eventEmitter";
|
||||||
import { getRenderer } from "./renderer/Singleton";
|
import { getRenderer } from "./renderer/Singleton";
|
||||||
|
|
||||||
|
|
||||||
interface ContextMenuData {
|
interface ContextMenuData {
|
||||||
user?: string;
|
user?: string;
|
||||||
server?: string;
|
server?: string;
|
||||||
|
|
@ -51,7 +53,6 @@ interface ContextMenuData {
|
||||||
type Action =
|
type Action =
|
||||||
| { action: "copy_id"; id: string }
|
| { action: "copy_id"; id: string }
|
||||||
| { action: "admin"; id: string; type: "channel" | "message" | "user" }
|
| { action: "admin"; id: string; type: "channel" | "message" | "user" }
|
||||||
| { action: "admin_system"; id: string }
|
|
||||||
| { action: "copy_message_link"; message: Message }
|
| { action: "copy_message_link"; message: Message }
|
||||||
| { action: "copy_selection" }
|
| { action: "copy_selection" }
|
||||||
| { action: "copy_text"; content: string }
|
| { action: "copy_text"; content: string }
|
||||||
|
|
@ -65,7 +66,6 @@ type Action =
|
||||||
| { action: "quote_message"; content: string }
|
| { action: "quote_message"; content: string }
|
||||||
| { action: "edit_message"; id: string }
|
| { action: "edit_message"; id: string }
|
||||||
| { action: "delete_message"; target: Message }
|
| { action: "delete_message"; target: Message }
|
||||||
| { action: "react_message"; target: Message }
|
|
||||||
| { action: "open_file"; attachment: API.File }
|
| { action: "open_file"; attachment: API.File }
|
||||||
| { action: "save_file"; attachment: API.File }
|
| { action: "save_file"; attachment: API.File }
|
||||||
| { action: "copy_file_link"; attachment: API.File }
|
| { action: "copy_file_link"; attachment: API.File }
|
||||||
|
|
@ -140,12 +140,6 @@ export default function ContextMenus() {
|
||||||
"_blank",
|
"_blank",
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "admin_system":
|
|
||||||
window.open(
|
|
||||||
`https://admin.revolt.chat/panel/inspect/user/${data.id}`,
|
|
||||||
"_blank",
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case "copy_message_link":
|
case "copy_message_link":
|
||||||
{
|
{
|
||||||
let pathname = `/channel/${data.message.channel_id}/${data.message._id}`;
|
let pathname = `/channel/${data.message.channel_id}/${data.message._id}`;
|
||||||
|
|
@ -289,7 +283,11 @@ export default function ContextMenus() {
|
||||||
window.open(
|
window.open(
|
||||||
// ! FIXME: do this from revolt.js
|
// ! FIXME: do this from revolt.js
|
||||||
client
|
client
|
||||||
.generateFileURL(data.attachment),
|
.generateFileURL(data.attachment)
|
||||||
|
?.replace(
|
||||||
|
"attachments",
|
||||||
|
"attachments/download",
|
||||||
|
),
|
||||||
isFirefox || window.native ? "_blank" : "_self",
|
isFirefox || window.native ? "_blank" : "_self",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -403,13 +401,6 @@ export default function ContextMenus() {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "react_message":
|
|
||||||
modalController.push({
|
|
||||||
type: "react_message",
|
|
||||||
target: data.target,
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "leave_group":
|
case "leave_group":
|
||||||
case "close_dm":
|
case "close_dm":
|
||||||
case "delete_channel":
|
case "delete_channel":
|
||||||
|
|
@ -514,10 +505,6 @@ export default function ContextMenus() {
|
||||||
<span style={{ color }}>
|
<span style={{ color }}>
|
||||||
{locale === "admin" ? (
|
{locale === "admin" ? (
|
||||||
"Open in Admin Panel"
|
"Open in Admin Panel"
|
||||||
) : locale === "admin_system" ? (
|
|
||||||
"Open User in Admin Panel"
|
|
||||||
) : locale === "react_message" ? (
|
|
||||||
"React"
|
|
||||||
) : (
|
) : (
|
||||||
<Text
|
<Text
|
||||||
id={`app.context_menu.${
|
id={`app.context_menu.${
|
||||||
|
|
@ -843,16 +830,6 @@ export default function ContextMenus() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.channel?.havePermission("React")) {
|
|
||||||
generateAction(
|
|
||||||
{
|
|
||||||
action: "react_message",
|
|
||||||
target: message,
|
|
||||||
},
|
|
||||||
"react_message",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.author_id !== userId) {
|
if (message.author_id !== userId) {
|
||||||
generateAction(
|
generateAction(
|
||||||
{
|
{
|
||||||
|
|
@ -1154,22 +1131,6 @@ export default function ContextMenus() {
|
||||||
},
|
},
|
||||||
"admin",
|
"admin",
|
||||||
);
|
);
|
||||||
|
|
||||||
switch (message?.system?.type) {
|
|
||||||
case "user_added":
|
|
||||||
case "user_remove":
|
|
||||||
case "user_joined":
|
|
||||||
case "user_left":
|
|
||||||
case "user_kicked":
|
|
||||||
case "user_banned":
|
|
||||||
generateAction(
|
|
||||||
{
|
|
||||||
action: "admin_system",
|
|
||||||
id: message.system.id,
|
|
||||||
},
|
|
||||||
"admin_system",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
generateAction(
|
generateAction(
|
||||||
|
|
|
||||||
|
|
@ -66,16 +66,11 @@ export default class Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
@action hydrate(data: ISettings) {
|
@action hydrate(data: ISettings) {
|
||||||
Object.keys(data).forEach((key) => {
|
Object.keys(data).forEach(
|
||||||
const val = (data as any)[key];
|
(key) =>
|
||||||
if (typeof val !== "undefined") {
|
typeof (data as any)[key] !== "undefined" &&
|
||||||
if (key === "appearance:emoji") {
|
this.data.set(key, (data as any)[key]),
|
||||||
setGlobalEmojiPack(val);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
this.data.set(key, val);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { Hash } from "@styled-icons/boxicons-regular";
|
import { Hash } from "@styled-icons/boxicons-regular";
|
||||||
import { Ghost } from "@styled-icons/boxicons-solid";
|
import { Ghost } from "@styled-icons/boxicons-solid";
|
||||||
import dayjs from "dayjs";
|
|
||||||
import { reaction } from "mobx";
|
import { reaction } from "mobx";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Redirect, useParams } from "react-router-dom";
|
import { Redirect, useParams } from "react-router-dom";
|
||||||
|
|
@ -164,7 +163,6 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||||
|
|
||||||
const checkUnread = () =>
|
const checkUnread = () =>
|
||||||
channel.unread &&
|
channel.unread &&
|
||||||
document.hasFocus() &&
|
|
||||||
channel.client.unreads!.markRead(
|
channel.client.unreads!.markRead(
|
||||||
channel._id,
|
channel._id,
|
||||||
channel.last_message_id!,
|
channel.last_message_id!,
|
||||||
|
|
@ -178,46 +176,6 @@ const TextChannel = observer(({ channel }: { channel: ChannelI }) => {
|
||||||
);
|
);
|
||||||
}, [channel]);
|
}, [channel]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
let lastSubscribed: number | undefined;
|
|
||||||
function subscribe() {
|
|
||||||
if (document.hasFocus()) {
|
|
||||||
if (
|
|
||||||
!lastSubscribed ||
|
|
||||||
dayjs().subtract(10, "minutes").isAfter(lastSubscribed)
|
|
||||||
) {
|
|
||||||
lastSubscribed = +new Date();
|
|
||||||
channel.server?.subscribe();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger logic every minute
|
|
||||||
const subTimer = setInterval(subscribe, 60e3);
|
|
||||||
subscribe();
|
|
||||||
|
|
||||||
function onFocus() {
|
|
||||||
// Mark channel as read if it's unread
|
|
||||||
if (channel.unread) {
|
|
||||||
channel.client.unreads!.markRead(
|
|
||||||
channel._id,
|
|
||||||
channel.last_message_id!,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subscribe to channel if expired
|
|
||||||
subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
addEventListener("focus", onFocus);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
removeEventListener("focus", onFocus);
|
|
||||||
clearInterval(subTimer);
|
|
||||||
};
|
|
||||||
}, [channel]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AgeGate
|
<AgeGate
|
||||||
type="channel"
|
type="channel"
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
a {
|
a {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 6em;
|
|
||||||
div {
|
div {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
@ -54,4 +54,3 @@
|
||||||
[data-light="true"] .home svg {
|
[data-light="true"] .home svg {
|
||||||
filter: invert(100%);
|
filter: invert(100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export default observer(() => {
|
||||||
state.settings.set("appearance:seasonal", !seasonalTheme);
|
state.settings.set("appearance:seasonal", !seasonalTheme);
|
||||||
|
|
||||||
const isDecember = !isTouchscreenDevice && new Date().getMonth() === 11;
|
const isDecember = !isTouchscreenDevice && new Date().getMonth() === 11;
|
||||||
const isOctober = !isTouchscreenDevice && new Date().getMonth() === 9;
|
const isOctober = !isTouchscreenDevice && new Date().getMonth() === 9
|
||||||
const snowflakes = useMemo(() => {
|
const snowflakes = useMemo(() => {
|
||||||
const flakes: string[] = [];
|
const flakes: string[] = [];
|
||||||
|
|
||||||
|
|
@ -175,7 +175,7 @@ export default observer(() => {
|
||||||
</CategoryButton>
|
</CategoryButton>
|
||||||
</Link>
|
</Link>
|
||||||
<a
|
<a
|
||||||
href="https://wiki.revolt.chat/notes/project/financial-support/"
|
href="https://insrt.uk/donate"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer">
|
rel="noreferrer">
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,6 @@ import UserIcon from "../../components/common/user/UserIcon";
|
||||||
import Markdown from "../../components/markdown/Markdown";
|
import Markdown from "../../components/markdown/Markdown";
|
||||||
import { useClient } from "../../controllers/client/ClientController";
|
import { useClient } from "../../controllers/client/ClientController";
|
||||||
|
|
||||||
const Page = styled.div`
|
|
||||||
padding: 6em;
|
|
||||||
min-height: 100vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
box-sizing: border-box;
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
padding: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const BotInfo = styled.div`
|
const BotInfo = styled.div`
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -58,7 +42,7 @@ export default function InviteBot() {
|
||||||
const [group, setGroup] = useState("none");
|
const [group, setGroup] = useState("none");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<div style={{ padding: "6em" }}>
|
||||||
<Tip palette="warning">This section is under construction.</Tip>
|
<Tip palette="warning">This section is under construction.</Tip>
|
||||||
{typeof data === "undefined" && <Preloader type="spinner" />}
|
{typeof data === "undefined" && <Preloader type="spinner" />}
|
||||||
{data && (
|
{data && (
|
||||||
|
|
@ -122,7 +106,6 @@ export default function InviteBot() {
|
||||||
</Option>
|
</Option>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Page>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,9 +202,11 @@ export const Form = observer(({ page, callback }: Props) => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{error && (
|
{error && (
|
||||||
<p style={{ fontSize: "0.8em", color: "var(--error)" }}>
|
<Category>
|
||||||
<Text id={`error.${error}`} children={error} />
|
<I18nError error={error}>
|
||||||
</p>
|
<Text id={`login.error.${page}`} />
|
||||||
|
</I18nError>
|
||||||
|
</Category>
|
||||||
)}
|
)}
|
||||||
<Button>
|
<Button>
|
||||||
<Text
|
<Text
|
||||||
|
|
@ -257,7 +259,7 @@ export const Form = observer(({ page, callback }: Props) => {
|
||||||
<span>
|
<span>
|
||||||
<Text id="login.unofficial_instance" />{" "}
|
<Text id="login.unofficial_instance" />{" "}
|
||||||
<a
|
<a
|
||||||
href="https://developers.revolt.chat/faq.html"
|
href="https://developers.revolt.chat/faq/instances#what-is-a-third-party-instance"
|
||||||
style={{ color: "var(--accent)" }}
|
style={{ color: "var(--accent)" }}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer">
|
rel="noreferrer">
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ export default observer(() => {
|
||||||
</ButtonItem>
|
</ButtonItem>
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
href="https://wiki.revolt.chat/notes/project/financial-support/"
|
href="https://insrt.uk/donate"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noreferrer">
|
rel="noreferrer">
|
||||||
<ButtonItem className={styles.donate} compact>
|
<ButtonItem className={styles.donate} compact>
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@ import { modalController } from "../../../controllers/modals/ModalController";
|
||||||
|
|
||||||
interface Data {
|
interface Data {
|
||||||
_id: string;
|
_id: string;
|
||||||
token: string;
|
|
||||||
username: string;
|
username: string;
|
||||||
public: boolean;
|
public: boolean;
|
||||||
interactions_url?: string;
|
interactions_url?: string;
|
||||||
|
|
@ -75,7 +74,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
const [user, setUser] = useState<User>(client.users.get(bot._id)!);
|
const [user, setUser] = useState<User>(client.users.get(bot._id)!);
|
||||||
const [data, setData] = useState<Data>({
|
const [data, setData] = useState<Data>({
|
||||||
_id: bot._id,
|
_id: bot._id,
|
||||||
token: bot.token,
|
|
||||||
username: user.username,
|
username: user.username,
|
||||||
public: bot.public,
|
public: bot.public,
|
||||||
interactions_url: bot.interactions_url as any,
|
interactions_url: bot.interactions_url as any,
|
||||||
|
|
@ -96,7 +94,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
const refreshProfile = useCallback(() => {
|
const refreshProfile = useCallback(() => {
|
||||||
client.api
|
client.api
|
||||||
.get(`/users/${bot._id as ""}/profile`, undefined, {
|
.get(`/users/${bot._id as ""}/profile`, undefined, {
|
||||||
headers: { "x-bot-token": data.token },
|
headers: { "x-bot-token": bot.token },
|
||||||
})
|
})
|
||||||
.then((profile) => setProfile(profile ?? {}));
|
.then((profile) => setProfile(profile ?? {}));
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|
@ -151,7 +149,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
"/users/@me",
|
"/users/@me",
|
||||||
avatar ? { avatar } : { remove: ["Avatar"] },
|
avatar ? { avatar } : { remove: ["Avatar"] },
|
||||||
{
|
{
|
||||||
headers: { "x-bot-token": data.token },
|
headers: { "x-bot-token": bot.token },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -170,7 +168,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
? { profile: { background } }
|
? { profile: { background } }
|
||||||
: { remove: ["ProfileBackground"] },
|
: { remove: ["ProfileBackground"] },
|
||||||
{
|
{
|
||||||
headers: { "x-bot-token": data.token },
|
headers: { "x-bot-token": bot.token },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -186,7 +184,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
"/users/@me",
|
"/users/@me",
|
||||||
content ? { profile: { content } } : { remove: ["ProfileContent"] },
|
content ? { profile: { content } } : { remove: ["ProfileContent"] },
|
||||||
{
|
{
|
||||||
headers: { "x-bot-token": data.token },
|
headers: { "x-bot-token": bot.token },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -314,7 +312,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
if (editMode) {
|
if (editMode) {
|
||||||
setData({
|
setData({
|
||||||
_id: bot._id,
|
_id: bot._id,
|
||||||
token: data.token,
|
|
||||||
username: user!.username,
|
username: user!.username,
|
||||||
public: bot.public,
|
public: bot.public,
|
||||||
interactions_url: bot.interactions_url as any,
|
interactions_url: bot.interactions_url as any,
|
||||||
|
|
@ -337,7 +334,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
account
|
account
|
||||||
icon={<Key size={24} />}
|
icon={<Key size={24} />}
|
||||||
onClick={() => modalController.writeText(data.token)}
|
onClick={() => modalController.writeText(bot.token)}
|
||||||
description={
|
description={
|
||||||
<>
|
<>
|
||||||
{"••••• "}
|
{"••••• "}
|
||||||
|
|
@ -347,7 +344,7 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
ev,
|
ev,
|
||||||
modalController.push({
|
modalController.push({
|
||||||
type: "show_token",
|
type: "show_token",
|
||||||
token: data.token,
|
token: bot.token,
|
||||||
name: user!.username,
|
name: user!.username,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
@ -493,25 +490,6 @@ function BotCard({ bot, onDelete, onUpdate }: Props) {
|
||||||
}>
|
}>
|
||||||
<Text id="app.settings.pages.bots.add" />
|
<Text id="app.settings.pages.bots.add" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
palette="error"
|
|
||||||
onClick={ async () => {
|
|
||||||
modalController.push({
|
|
||||||
type: "reset_bot_token",
|
|
||||||
target: { name: user.username, id: bot._id },
|
|
||||||
callback: async () => {
|
|
||||||
const updatedBot = await client.bots.fetch(bot._id);
|
|
||||||
setData({
|
|
||||||
...data,
|
|
||||||
token: updatedBot.bot.token
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
<Text id="app.settings.pages.bots.reset_token" />
|
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ export function Native() {
|
||||||
</Button>
|
</Button>
|
||||||
</p>
|
</p>
|
||||||
<h3 style={{ marginTop: "4em" }}>Local Development Mode</h3>
|
<h3 style={{ marginTop: "4em" }}>Local Development Mode</h3>
|
||||||
{/*config.build === "dev" ? (
|
{config.build === "dev" ? (
|
||||||
<>
|
<>
|
||||||
<h5>Development mode is currently on.</h5>
|
<h5>Development mode is currently on.</h5>
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -197,7 +197,7 @@ export function Native() {
|
||||||
</Button>
|
</Button>
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
)*/}
|
)}
|
||||||
<hr />
|
<hr />
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
icon={<img src={RLogo} draggable={false} />}
|
icon={<img src={RLogo} draggable={false} />}
|
||||||
|
|
|
||||||
|
|
@ -369,9 +369,7 @@ function ListElement({
|
||||||
<KanbanList last={false} key={category.id}>
|
<KanbanList last={false} key={category.id}>
|
||||||
<div className="inner">
|
<div className="inner">
|
||||||
<Row>
|
<Row>
|
||||||
<KanbanListHeader
|
<KanbanListHeader {...provided.dragHandleProps}>
|
||||||
{...provided.dragHandleProps}
|
|
||||||
onClick={startEditing}>
|
|
||||||
{editing !== undefined ? (
|
{editing !== undefined ? (
|
||||||
<input
|
<input
|
||||||
value={editing}
|
value={editing}
|
||||||
|
|
@ -386,7 +384,7 @@ function ListElement({
|
||||||
id={category.id}
|
id={category.id}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span>
|
<span onClick={startEditing}>
|
||||||
{category.title}
|
{category.title}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -103,43 +103,10 @@ export const Members = ({ server }: Props) => {
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function fetch() {
|
server
|
||||||
server
|
.fetchMembers()
|
||||||
.fetchMembers()
|
.then((data) => data.members)
|
||||||
.then((data) => data.members)
|
.then(setData);
|
||||||
.then(setData);
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch();
|
|
||||||
|
|
||||||
// Members may be invalidated if we stop receiving events
|
|
||||||
// This is not very accurate, this should be tracked within
|
|
||||||
// revolt.js so we know the true validity.
|
|
||||||
let valid = true,
|
|
||||||
invalidationTimer: number;
|
|
||||||
|
|
||||||
function waitToInvalidate() {
|
|
||||||
invalidationTimer = setTimeout(() => {
|
|
||||||
valid = false;
|
|
||||||
}, 15 * 60e3) as never; // 15 minutes
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelInvalidation() {
|
|
||||||
if (!valid) {
|
|
||||||
fetch();
|
|
||||||
valid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTimeout(invalidationTimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
addEventListener("blur", waitToInvalidate);
|
|
||||||
addEventListener("focus", cancelInvalidation);
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
removeEventListener("blur", waitToInvalidate);
|
|
||||||
removeEventListener("focus", cancelInvalidation);
|
|
||||||
};
|
|
||||||
}, [server, setData]);
|
}, [server, setData]);
|
||||||
|
|
||||||
const members = useMemo(
|
const members = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { HelpCircle } from "@styled-icons/boxicons-solid";
|
||||||
HelpCircle,
|
|
||||||
ChevronUp,
|
|
||||||
ChevronDown,
|
|
||||||
} from "@styled-icons/boxicons-solid";
|
|
||||||
import isEqual from "lodash.isequal";
|
import isEqual from "lodash.isequal";
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import { Server } from "revolt.js";
|
import { Server } from "revolt.js";
|
||||||
|
|
@ -20,208 +16,17 @@ import {
|
||||||
ColourSwatches,
|
ColourSwatches,
|
||||||
InputBox,
|
InputBox,
|
||||||
Category,
|
Category,
|
||||||
Row,
|
|
||||||
} from "@revoltchat/ui";
|
} from "@revoltchat/ui";
|
||||||
|
|
||||||
import Tooltip from "../../../components/common/Tooltip";
|
import Tooltip from "../../../components/common/Tooltip";
|
||||||
import { PermissionList } from "../../../components/settings/roles/PermissionList";
|
import { PermissionList } from "../../../components/settings/roles/PermissionList";
|
||||||
import { RoleOrDefault } from "../../../components/settings/roles/RoleSelection";
|
import { RoleOrDefault } from "../../../components/settings/roles/RoleSelection";
|
||||||
import { useSession } from "../../../controllers/client/ClientController";
|
|
||||||
import { modalController } from "../../../controllers/modals/ModalController";
|
import { modalController } from "../../../controllers/modals/ModalController";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
server: Server;
|
server: Server;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RoleReorderContainer = styled.div`
|
|
||||||
margin: 16px 0;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RoleItem = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 12px 16px;
|
|
||||||
margin: 12px 0;
|
|
||||||
background: var(--secondary-background);
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RoleInfo = styled.div`
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RoleName = styled.div`
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--foreground);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RoleRank = styled.div`
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--secondary-foreground);
|
|
||||||
`;
|
|
||||||
|
|
||||||
const RoleControls = styled.div`
|
|
||||||
display: flex;
|
|
||||||
gap: 4px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const MoveButton = styled(Button)`
|
|
||||||
padding: 4px 8px;
|
|
||||||
min-width: auto;
|
|
||||||
`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hook to memo-ize role information with proper ordering
|
|
||||||
* @param server Target server
|
|
||||||
* @returns Role array with default at bottom
|
|
||||||
*/
|
|
||||||
export function useRolesForReorder(server: Server) {
|
|
||||||
return useMemo(() => {
|
|
||||||
const roles = [...server.orderedRoles] as RoleOrDefault[];
|
|
||||||
|
|
||||||
roles.push({
|
|
||||||
id: "default",
|
|
||||||
name: "Default",
|
|
||||||
permissions: server.default_permissions,
|
|
||||||
});
|
|
||||||
|
|
||||||
return roles;
|
|
||||||
}, [server.roles, server.default_permissions]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Role reordering component
|
|
||||||
*/
|
|
||||||
const RoleReorderPanel = observer(
|
|
||||||
({ server, onExit }: Props & { onExit: () => void }) => {
|
|
||||||
const initialRoles = useRolesForReorder(server);
|
|
||||||
const [roles, setRoles] = useState(initialRoles);
|
|
||||||
const [isReordering, setIsReordering] = useState(false);
|
|
||||||
|
|
||||||
// Update local state when server roles change
|
|
||||||
useMemo(() => {
|
|
||||||
setRoles(useRolesForReorder(server));
|
|
||||||
}, [server.roles, server.default_permissions]);
|
|
||||||
|
|
||||||
const moveRoleUp = (index: number) => {
|
|
||||||
if (index === 0 || roles[index].id === "default") return;
|
|
||||||
|
|
||||||
const newRoles = [...roles];
|
|
||||||
[newRoles[index - 1], newRoles[index]] = [
|
|
||||||
newRoles[index],
|
|
||||||
newRoles[index - 1],
|
|
||||||
];
|
|
||||||
setRoles(newRoles);
|
|
||||||
};
|
|
||||||
|
|
||||||
const moveRoleDown = (index: number) => {
|
|
||||||
// Can't move down if it's the last non-default role or if it's default
|
|
||||||
if (index >= roles.length - 2 || roles[index].id === "default")
|
|
||||||
return;
|
|
||||||
|
|
||||||
const newRoles = [...roles];
|
|
||||||
[newRoles[index], newRoles[index + 1]] = [
|
|
||||||
newRoles[index + 1],
|
|
||||||
newRoles[index],
|
|
||||||
];
|
|
||||||
setRoles(newRoles);
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveReorder = async () => {
|
|
||||||
setIsReordering(true);
|
|
||||||
try {
|
|
||||||
const nonDefaultRoles = roles.filter(
|
|
||||||
(role) => role.id !== "default",
|
|
||||||
);
|
|
||||||
const roleIds = nonDefaultRoles.map((role) => role.id);
|
|
||||||
|
|
||||||
const session = useSession()!;
|
|
||||||
const client = session.client!;
|
|
||||||
|
|
||||||
// Make direct API request since it's not in r.js as of writing
|
|
||||||
await client.api.patch(`/servers/${server._id}/roles/ranks`, {
|
|
||||||
ranks: roleIds,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("Roles reordered successfully");
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to reorder roles:", error);
|
|
||||||
setRoles(initialRoles);
|
|
||||||
} finally {
|
|
||||||
setIsReordering(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const hasChanges = !isEqual(
|
|
||||||
roles.filter((r) => r.id !== "default").map((r) => r.id),
|
|
||||||
initialRoles.filter((r) => r.id !== "default").map((r) => r.id),
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<SpaceBetween>
|
|
||||||
<H1>
|
|
||||||
<Text id="app.settings.permissions.role_ranking" />
|
|
||||||
</H1>
|
|
||||||
<Row>
|
|
||||||
<Button
|
|
||||||
palette="secondary"
|
|
||||||
onClick={onExit}
|
|
||||||
style={{ marginBottom: "16px" }}>
|
|
||||||
<Text id="app.special.modals.actions.back" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
palette="secondary"
|
|
||||||
disabled={!hasChanges || isReordering}
|
|
||||||
onClick={saveReorder}>
|
|
||||||
<Text id="app.special.modals.actions.save" />
|
|
||||||
</Button>
|
|
||||||
</Row>
|
|
||||||
</SpaceBetween>
|
|
||||||
|
|
||||||
<RoleReorderContainer>
|
|
||||||
{roles.map((role, index) => (
|
|
||||||
<RoleItem key={role.id}>
|
|
||||||
<RoleInfo>
|
|
||||||
<RoleName>{role.name}</RoleName>
|
|
||||||
<RoleRank>
|
|
||||||
{role.id === "default" ? (
|
|
||||||
<Text id="app.settings.permissions.default_desc" />
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<Text id="app.settings.permissions.role_ranking" />{" "}
|
|
||||||
{index}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</RoleRank>
|
|
||||||
</RoleInfo>
|
|
||||||
|
|
||||||
{role.id !== "default" && (
|
|
||||||
<RoleControls>
|
|
||||||
<MoveButton
|
|
||||||
palette="secondary"
|
|
||||||
disabled={index === 0}
|
|
||||||
onClick={() => moveRoleUp(index)}>
|
|
||||||
<ChevronUp size={16} />
|
|
||||||
</MoveButton>
|
|
||||||
<MoveButton
|
|
||||||
palette="secondary"
|
|
||||||
disabled={index >= roles.length - 2}
|
|
||||||
onClick={() => moveRoleDown(index)}>
|
|
||||||
<ChevronDown size={16} />
|
|
||||||
</MoveButton>
|
|
||||||
</RoleControls>
|
|
||||||
)}
|
|
||||||
</RoleItem>
|
|
||||||
))}
|
|
||||||
</RoleReorderContainer>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook to memo-ize role information.
|
* Hook to memo-ize role information.
|
||||||
* @param server Target server
|
* @param server Target server
|
||||||
|
|
@ -245,11 +50,9 @@ export function useRoles(server: Server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated Roles settings menu with reordering panel
|
* Roles settings menu
|
||||||
*/
|
*/
|
||||||
export const Roles = observer(({ server }: Props) => {
|
export const Roles = observer(({ server }: Props) => {
|
||||||
const [showReorderPanel, setShowReorderPanel] = useState(false);
|
|
||||||
|
|
||||||
// Consolidate all permissions that we can change right now.
|
// Consolidate all permissions that we can change right now.
|
||||||
const currentRoles = useRoles(server);
|
const currentRoles = useRoles(server);
|
||||||
|
|
||||||
|
|
@ -271,219 +74,213 @@ export const Roles = observer(({ server }: Props) => {
|
||||||
margin: 16px 0;
|
margin: 16px 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ReorderButton = styled(Button)`
|
|
||||||
margin-inline: auto 8px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
if (showReorderPanel) {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<RoleReorderPanel
|
|
||||||
server={server}
|
|
||||||
onExit={() => setShowReorderPanel(false)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<PermissionsLayout
|
||||||
<PermissionsLayout
|
server={server}
|
||||||
server={server}
|
rank={server.member?.ranking ?? Infinity}
|
||||||
rank={server.member?.ranking ?? Infinity}
|
onCreateRole={(callback) =>
|
||||||
onCreateRole={(callback) =>
|
modalController.push({
|
||||||
modalController.push({
|
type: "create_role",
|
||||||
type: "create_role",
|
server,
|
||||||
server,
|
callback,
|
||||||
callback,
|
})
|
||||||
})
|
}
|
||||||
|
editor={({ selected }) => {
|
||||||
|
const currentRole = currentRoles.find(
|
||||||
|
(x) => x.id === selected,
|
||||||
|
)!;
|
||||||
|
|
||||||
|
if (!currentRole) return null;
|
||||||
|
|
||||||
|
// Keep track of whatever role we're editing right now.
|
||||||
|
const [value, setValue] = useState<Partial<RoleOrDefault>>({});
|
||||||
|
|
||||||
|
const currentRoleValue = { ...currentRole, ...value };
|
||||||
|
|
||||||
|
// Calculate permissions we have access to on this server.
|
||||||
|
const current = server.permission;
|
||||||
|
|
||||||
|
// Upload new role information to server.
|
||||||
|
function save() {
|
||||||
|
const { permissions: permsCurrent, ...current } =
|
||||||
|
currentRole;
|
||||||
|
const { permissions: permsValue, ...value } =
|
||||||
|
currentRoleValue;
|
||||||
|
|
||||||
|
if (!isEqual(permsCurrent, permsValue)) {
|
||||||
|
server.setPermissions(
|
||||||
|
selected,
|
||||||
|
typeof permsValue === "number"
|
||||||
|
? permsValue
|
||||||
|
: {
|
||||||
|
allow: permsValue.a,
|
||||||
|
deny: permsValue.d,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isEqual(current, value)) {
|
||||||
|
server.editRole(selected, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
editor={({ selected }) => {
|
|
||||||
const currentRole = currentRoles.find(
|
|
||||||
(x) => x.id === selected,
|
|
||||||
)!;
|
|
||||||
|
|
||||||
if (!currentRole) return null;
|
// Delete the role from this server.
|
||||||
|
function deleteRole() {
|
||||||
|
server.deleteRole(selected);
|
||||||
|
}
|
||||||
|
|
||||||
const [value, setValue] = useState<Partial<RoleOrDefault>>(
|
return (
|
||||||
{},
|
<div>
|
||||||
);
|
<SpaceBetween>
|
||||||
|
<H1>
|
||||||
const currentRoleValue = { ...currentRole, ...value };
|
<Text
|
||||||
|
id="app.settings.actions.edit"
|
||||||
function save() {
|
fields={{ name: currentRole.name }}
|
||||||
const { permissions: permsCurrent, ...current } =
|
/>
|
||||||
currentRole;
|
</H1>
|
||||||
const { permissions: permsValue, ...value } =
|
<Button
|
||||||
currentRoleValue;
|
palette="secondary"
|
||||||
|
disabled={isEqual(
|
||||||
if (!isEqual(permsCurrent, permsValue)) {
|
currentRole,
|
||||||
server.setPermissions(
|
currentRoleValue,
|
||||||
selected,
|
)}
|
||||||
typeof permsValue === "number"
|
onClick={save}>
|
||||||
? permsValue
|
<Text id="app.special.modals.actions.save" />
|
||||||
: {
|
</Button>
|
||||||
allow: permsValue.a,
|
</SpaceBetween>
|
||||||
deny: permsValue.d,
|
<hr />
|
||||||
},
|
{selected !== "default" && (
|
||||||
);
|
<>
|
||||||
}
|
<section>
|
||||||
|
<Category>
|
||||||
if (!isEqual(current, value)) {
|
<Text id="app.settings.permissions.role_name" />
|
||||||
server.editRole(selected, value);
|
</Category>
|
||||||
}
|
<p>
|
||||||
}
|
<InputBox
|
||||||
|
value={currentRoleValue.name}
|
||||||
function deleteRole() {
|
onChange={(e) =>
|
||||||
server.deleteRole(selected);
|
setValue({
|
||||||
}
|
...value,
|
||||||
|
name: e.currentTarget.value,
|
||||||
return (
|
})
|
||||||
<div>
|
}
|
||||||
<SpaceBetween>
|
palette="secondary"
|
||||||
<H1>
|
/>
|
||||||
<Text
|
</p>
|
||||||
id="app.settings.actions.edit"
|
</section>
|
||||||
fields={{ name: currentRole.name }}
|
<section>
|
||||||
/>
|
<Category>{"Role ID"}</Category>
|
||||||
</H1>
|
<RoleId>
|
||||||
<ReorderButton
|
<Tooltip
|
||||||
palette="secondary"
|
content={
|
||||||
onClick={() => setShowReorderPanel(true)}>
|
"This is a unique identifier for this role."
|
||||||
<Text id="app.settings.permissions.role_ranking" />
|
}>
|
||||||
</ReorderButton>
|
<HelpCircle size={16} />
|
||||||
<Button
|
</Tooltip>
|
||||||
palette="secondary"
|
<Tooltip
|
||||||
disabled={isEqual(
|
content={
|
||||||
currentRole,
|
<Text id="app.special.copy" />
|
||||||
currentRoleValue,
|
}>
|
||||||
)}
|
<a
|
||||||
onClick={save}>
|
onClick={() =>
|
||||||
<Text id="app.special.modals.actions.save" />
|
modalController.writeText(
|
||||||
</Button>
|
currentRole.id,
|
||||||
</SpaceBetween>
|
)
|
||||||
<hr />
|
|
||||||
{selected !== "default" && (
|
|
||||||
<>
|
|
||||||
<section>
|
|
||||||
<Category>
|
|
||||||
<Text id="app.settings.permissions.role_name" />
|
|
||||||
</Category>
|
|
||||||
<p>
|
|
||||||
<InputBox
|
|
||||||
value={currentRoleValue.name}
|
|
||||||
onChange={(e) =>
|
|
||||||
setValue({
|
|
||||||
...value,
|
|
||||||
name: e.currentTarget
|
|
||||||
.value,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
palette="secondary"
|
|
||||||
/>
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<Category>{"Role ID"}</Category>
|
|
||||||
<RoleId>
|
|
||||||
<Tooltip
|
|
||||||
content={
|
|
||||||
"This is a unique identifier for this role."
|
|
||||||
}>
|
}>
|
||||||
<HelpCircle size={16} />
|
{currentRole.id}
|
||||||
</Tooltip>
|
</a>
|
||||||
<Tooltip
|
</Tooltip>
|
||||||
content={
|
</RoleId>
|
||||||
<Text id="app.special.copy" />
|
</section>
|
||||||
}>
|
<section>
|
||||||
<a
|
<Category>
|
||||||
onClick={() =>
|
<Text id="app.settings.permissions.role_colour" />
|
||||||
modalController.writeText(
|
</Category>
|
||||||
currentRole.id,
|
<p>
|
||||||
)
|
<ColourSwatches
|
||||||
}>
|
value={
|
||||||
{currentRole.id}
|
currentRoleValue.colour ??
|
||||||
</a>
|
"gray"
|
||||||
</Tooltip>
|
}
|
||||||
</RoleId>
|
onChange={(colour) =>
|
||||||
</section>
|
setValue({ ...value, colour })
|
||||||
<section>
|
}
|
||||||
<Category>
|
/>
|
||||||
<Text id="app.settings.permissions.role_colour" />
|
</p>
|
||||||
</Category>
|
</section>
|
||||||
<p>
|
<section>
|
||||||
<ColourSwatches
|
<Category>
|
||||||
value={
|
<Text id="app.settings.permissions.role_options" />
|
||||||
currentRoleValue.colour ??
|
</Category>
|
||||||
"gray"
|
<p>
|
||||||
}
|
<Checkbox
|
||||||
onChange={(colour) =>
|
value={
|
||||||
setValue({
|
currentRoleValue.hoist ?? false
|
||||||
...value,
|
}
|
||||||
colour,
|
onChange={(hoist) =>
|
||||||
})
|
setValue({ ...value, hoist })
|
||||||
}
|
}
|
||||||
/>
|
title={
|
||||||
</p>
|
<Text id="app.settings.permissions.hoist_role" />
|
||||||
</section>
|
}
|
||||||
<section>
|
description={
|
||||||
<Category>
|
<Text id="app.settings.permissions.hoist_desc" />
|
||||||
<Text id="app.settings.permissions.role_options" />
|
}
|
||||||
</Category>
|
/>
|
||||||
<p>
|
</p>
|
||||||
<Checkbox
|
</section>
|
||||||
value={
|
<section>
|
||||||
currentRoleValue.hoist ??
|
<Category>
|
||||||
false
|
<Text id="app.settings.permissions.role_ranking" />
|
||||||
}
|
</Category>
|
||||||
onChange={(hoist) =>
|
<p>
|
||||||
setValue({
|
<InputBox
|
||||||
...value,
|
type="number"
|
||||||
hoist,
|
value={currentRoleValue.rank ?? 0}
|
||||||
})
|
onChange={(e) =>
|
||||||
}
|
setValue({
|
||||||
title={
|
...value,
|
||||||
<Text id="app.settings.permissions.hoist_role" />
|
rank: parseInt(
|
||||||
}
|
e.currentTarget.value,
|
||||||
description={
|
),
|
||||||
<Text id="app.settings.permissions.hoist_desc" />
|
})
|
||||||
}
|
}
|
||||||
/>
|
palette="secondary"
|
||||||
</p>
|
/>
|
||||||
</section>
|
</p>
|
||||||
</>
|
</section>
|
||||||
)}
|
</>
|
||||||
<h1>
|
)}
|
||||||
<Text id="app.settings.permissions.edit_title" />
|
<h1>
|
||||||
</h1>
|
<Text id="app.settings.permissions.edit_title" />
|
||||||
<PermissionList
|
</h1>
|
||||||
value={currentRoleValue.permissions}
|
<PermissionList
|
||||||
onChange={(permissions) =>
|
value={currentRoleValue.permissions}
|
||||||
setValue({
|
onChange={(permissions) =>
|
||||||
...value,
|
setValue({
|
||||||
permissions,
|
...value,
|
||||||
} as RoleOrDefault)
|
permissions,
|
||||||
}
|
} as RoleOrDefault)
|
||||||
target={server}
|
}
|
||||||
/>
|
target={server}
|
||||||
{selected !== "default" && (
|
/>
|
||||||
<>
|
{selected !== "default" && (
|
||||||
<hr />
|
<>
|
||||||
<h1>
|
<hr />
|
||||||
<Text id="app.settings.categories.danger_zone" />
|
<h1>
|
||||||
</h1>
|
<Text id="app.settings.categories.danger_zone" />
|
||||||
<DeleteRoleButton
|
</h1>
|
||||||
palette="error"
|
<DeleteRoleButton
|
||||||
compact
|
palette="error"
|
||||||
onClick={deleteRole}>
|
compact
|
||||||
<Text id="app.settings.permissions.delete_role" />
|
onClick={deleteRole}>
|
||||||
</DeleteRoleButton>
|
<Text id="app.settings.permissions.delete_role" />
|
||||||
</>
|
</DeleteRoleButton>
|
||||||
)}
|
</>
|
||||||
</div>
|
)}
|
||||||
);
|
</div>
|
||||||
}}
|
);
|
||||||
/>
|
}}
|
||||||
</div>
|
/>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"jsx": "preserve",
|
"jsx": "preserve",
|
||||||
"jsxImportSource": "preact",
|
|
||||||
"jsxFactory": "h",
|
"jsxFactory": "h",
|
||||||
"jsxFragmentFactory": "Fragment",
|
"jsxFragmentFactory": "Fragment",
|
||||||
"types": ["vite-plugin-pwa/client"],
|
"types": ["vite-plugin-pwa/client"],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue