mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-10 01:03:36 -05:00
Prettier, Fix no role refresh
This commit is contained in:
parent
416cc0a991
commit
8ac7403522
1 changed files with 26 additions and 18 deletions
|
@ -6,9 +6,16 @@ import { Server } from "revolt.js/dist/maps/Servers";
|
||||||
|
|
||||||
import styles from "./Panes.module.scss";
|
import styles from "./Panes.module.scss";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import {useCallback, useContext, useEffect, useMemo, useState} from "preact/hooks";
|
import {
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from "preact/hooks";
|
||||||
|
|
||||||
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
import { useIntermediate } from "../../../context/intermediate/Intermediate";
|
||||||
|
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
||||||
|
|
||||||
import Button from "../../../components/ui/Button";
|
import Button from "../../../components/ui/Button";
|
||||||
import Checkbox from "../../../components/ui/Checkbox";
|
import Checkbox from "../../../components/ui/Checkbox";
|
||||||
|
@ -17,7 +24,6 @@ import InputBox from "../../../components/ui/InputBox";
|
||||||
import Overline from "../../../components/ui/Overline";
|
import Overline from "../../../components/ui/Overline";
|
||||||
|
|
||||||
import ButtonItem from "../../../components/navigation/items/ButtonItem";
|
import ButtonItem from "../../../components/navigation/items/ButtonItem";
|
||||||
import {AppContext} from "../../../context/revoltjs/RevoltClient";
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
server: Server;
|
server: Server;
|
||||||
|
@ -30,7 +36,7 @@ export const Roles = observer(({ server }: Props) => {
|
||||||
const client = useContext(AppContext);
|
const client = useContext(AppContext);
|
||||||
const [role, setRole] = useState("default");
|
const [role, setRole] = useState("default");
|
||||||
const { openScreen } = useIntermediate();
|
const { openScreen } = useIntermediate();
|
||||||
const roles = useMemo(() => server.roles ?? {}, [server]);
|
const roles = server.roles || {};
|
||||||
|
|
||||||
if (role !== "default" && typeof roles[role] === "undefined") {
|
if (role !== "default" && typeof roles[role] === "undefined") {
|
||||||
useEffect(() => setRole("default"), [role]);
|
useEffect(() => setRole("default"), [role]);
|
||||||
|
@ -123,26 +129,25 @@ export const Roles = observer(({ server }: Props) => {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{["default", ...Object.keys(roles)].map((id) => {
|
{["default", ...Object.keys(roles)].map((id) =>
|
||||||
if (id === "default") {
|
id === "default" ? (
|
||||||
return (
|
<ButtonItem
|
||||||
<ButtonItem
|
active={role === "default"}
|
||||||
active={role === "default"}
|
onClick={() => setRole("default")}>
|
||||||
onClick={() => setRole("default")}>
|
<Text id="app.settings.permissions.default_role" />
|
||||||
<Text id="app.settings.permissions.default_role" />
|
</ButtonItem>
|
||||||
</ButtonItem>
|
) : (
|
||||||
);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<ButtonItem
|
<ButtonItem
|
||||||
key={id}
|
key={id}
|
||||||
active={role === id}
|
active={role === id}
|
||||||
onClick={() => setRole(id)}
|
onClick={() => setRole(id)}
|
||||||
style={{ color: roles[id].colour }}>
|
style={{
|
||||||
|
color: roles[id].colour,
|
||||||
|
}}>
|
||||||
{roles[id].name}
|
{roles[id].name}
|
||||||
</ButtonItem>
|
</ButtonItem>
|
||||||
);
|
),
|
||||||
})}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.permissions}>
|
<div className={styles.permissions}>
|
||||||
<div className={styles.title}>
|
<div className={styles.title}>
|
||||||
|
@ -238,7 +243,10 @@ export const Roles = observer(({ server }: Props) => {
|
||||||
onChange={() =>
|
onChange={() =>
|
||||||
setPerm([perm[0], perm[1] ^ value])
|
setPerm([perm[0], perm[1] ^ value])
|
||||||
}
|
}
|
||||||
disabled={key === "View" || (!(clientPermissions & value))}
|
disabled={
|
||||||
|
key === "View" ||
|
||||||
|
!(clientPermissions & value)
|
||||||
|
}
|
||||||
description={
|
description={
|
||||||
<Text id={`permissions.channel.${key}.d`} />
|
<Text id={`permissions.channel.${key}.d`} />
|
||||||
}>
|
}>
|
||||||
|
|
Loading…
Reference in a new issue