mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-22 07:00:58 -05:00
Fix elements not observing permissions.
This commit is contained in:
parent
463aa79356
commit
29cc221a34
6 changed files with 301 additions and 282 deletions
|
@ -97,7 +97,7 @@
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scroll": "^1.8.2",
|
"react-scroll": "^1.8.2",
|
||||||
"redux": "^4.1.0",
|
"redux": "^4.1.0",
|
||||||
"revolt.js": "5.0.0-alpha.12",
|
"revolt.js": "5.0.0-alpha.14",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sass": "^1.35.1",
|
"sass": "^1.35.1",
|
||||||
"shade-blend-color": "^1.0.0",
|
"shade-blend-color": "^1.0.0",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Send, ShieldX } from "@styled-icons/boxicons-solid";
|
import { Send, ShieldX } from "@styled-icons/boxicons-solid";
|
||||||
import Axios, { CancelTokenSource } from "axios";
|
import Axios, { CancelTokenSource } from "axios";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import { ChannelPermission } from "revolt.js/dist/api/permissions";
|
import { ChannelPermission } from "revolt.js/dist/api/permissions";
|
||||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
@ -108,7 +109,7 @@ const Action = styled.div`
|
||||||
// ! FIXME: add to app config and load from app config
|
// ! FIXME: add to app config and load from app config
|
||||||
export const CAN_UPLOAD_AT_ONCE = 4;
|
export const CAN_UPLOAD_AT_ONCE = 4;
|
||||||
|
|
||||||
export default function MessageBox({ channel }: Props) {
|
export default observer(({ channel }: Props) => {
|
||||||
const [draft, setDraft] = useState(getState().drafts[channel._id] ?? "");
|
const [draft, setDraft] = useState(getState().drafts[channel._id] ?? "");
|
||||||
|
|
||||||
const [uploadState, setUploadState] = useState<UploadState>({
|
const [uploadState, setUploadState] = useState<UploadState>({
|
||||||
|
@ -506,4 +507,4 @@ export default function MessageBox({ channel }: Props) {
|
||||||
</Base>
|
</Base>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Money } from "@styled-icons/boxicons-regular";
|
import { Money } from "@styled-icons/boxicons-regular";
|
||||||
import { Envelope, Edit, UserPlus, Shield } from "@styled-icons/boxicons-solid";
|
import { Envelope, Edit, UserPlus, Shield } from "@styled-icons/boxicons-solid";
|
||||||
|
import { observer } from "mobx-react-lite";
|
||||||
import { Link, useHistory } from "react-router-dom";
|
import { Link, useHistory } from "react-router-dom";
|
||||||
import { Profile, RelationshipStatus } from "revolt-api/types/Users";
|
import { Profile, RelationshipStatus } from "revolt-api/types/Users";
|
||||||
import { UserPermission } from "revolt.js/dist/api/permissions";
|
import { UserPermission } from "revolt.js/dist/api/permissions";
|
||||||
|
@ -41,7 +42,8 @@ enum Badges {
|
||||||
EarlyAdopter = 256,
|
EarlyAdopter = 256,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
export const UserProfile = observer(
|
||||||
|
({ user_id, onClose, dummy, dummyProfile }: Props) => {
|
||||||
const { openScreen, writeClipboard } = useIntermediate();
|
const { openScreen, writeClipboard } = useIntermediate();
|
||||||
|
|
||||||
const [profile, setProfile] = useState<undefined | null | Profile>(
|
const [profile, setProfile] = useState<undefined | null | Profile>(
|
||||||
|
@ -84,7 +86,10 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dummy) return;
|
if (dummy) return;
|
||||||
if (status === ClientStatus.ONLINE && typeof mutual === "undefined") {
|
if (
|
||||||
|
status === ClientStatus.ONLINE &&
|
||||||
|
typeof mutual === "undefined"
|
||||||
|
) {
|
||||||
setMutual(null);
|
setMutual(null);
|
||||||
user.fetchMutual().then(setMutual);
|
user.fetchMutual().then(setMutual);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +97,10 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dummy) return;
|
if (dummy) return;
|
||||||
if (status === ClientStatus.ONLINE && typeof profile === "undefined") {
|
if (
|
||||||
|
status === ClientStatus.ONLINE &&
|
||||||
|
typeof profile === "undefined"
|
||||||
|
) {
|
||||||
setProfile(null);
|
setProfile(null);
|
||||||
|
|
||||||
if (user.permission & UserPermission.ViewProfile) {
|
if (user.permission & UserPermission.ViewProfile) {
|
||||||
|
@ -129,7 +137,9 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
||||||
<Localizer>
|
<Localizer>
|
||||||
<span
|
<span
|
||||||
className={styles.username}
|
className={styles.username}
|
||||||
onClick={() => writeClipboard(user.username)}>
|
onClick={() =>
|
||||||
|
writeClipboard(user.username)
|
||||||
|
}>
|
||||||
@{user.username}
|
@{user.username}
|
||||||
</span>
|
</span>
|
||||||
</Localizer>
|
</Localizer>
|
||||||
|
@ -245,17 +255,24 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
||||||
content={
|
content={
|
||||||
<Text id="app.special.popovers.user_profile.badges.supporter" />
|
<Text id="app.special.popovers.user_profile.badges.supporter" />
|
||||||
}>
|
}>
|
||||||
<Money size={32} color="#efab44" />
|
<Money
|
||||||
|
size={32}
|
||||||
|
color="#efab44"
|
||||||
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
{badges & Badges.ResponsibleDisclosure ? (
|
{badges &
|
||||||
|
Badges.ResponsibleDisclosure ? (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={
|
content={
|
||||||
<Text id="app.special.popovers.user_profile.badges.responsible_disclosure" />
|
<Text id="app.special.popovers.user_profile.badges.responsible_disclosure" />
|
||||||
}>
|
}>
|
||||||
<Shield size={32} color="gray" />
|
<Shield
|
||||||
|
size={32}
|
||||||
|
color="gray"
|
||||||
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
|
@ -334,4 +351,5 @@ export function UserProfile({ user_id, onClose, dummy, dummyProfile }: Props) {
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
);
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default function ChannelSettings() {
|
||||||
switch (channel?.channel_type) {
|
switch (channel?.channel_type) {
|
||||||
case "TextChannel":
|
case "TextChannel":
|
||||||
case "VoiceChannel":
|
case "VoiceChannel":
|
||||||
base_url = `/server/${channel.server}/channel/${cid}/settings`;
|
base_url = `/server/${channel.server_id}/channel/${cid}/settings`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
base_url = `/channel/${cid}/settings`;
|
base_url = `/channel/${cid}/settings`;
|
||||||
|
|
|
@ -27,8 +27,6 @@ export const Members = observer(({ server }: Props) => {
|
||||||
{ members: Member[]; users: User[] } | undefined
|
{ members: Member[]; users: User[] } | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
|
||||||
const client = useClient();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
server.fetchMembers().then(setData);
|
server.fetchMembers().then(setData);
|
||||||
}, []);
|
}, []);
|
||||||
|
@ -50,10 +48,12 @@ export const Members = observer(({ server }: Props) => {
|
||||||
{data &&
|
{data &&
|
||||||
data.members.length > 0 &&
|
data.members.length > 0 &&
|
||||||
data.members
|
data.members
|
||||||
.map((member, index) => {
|
.map((member) => {
|
||||||
return {
|
return {
|
||||||
member,
|
member,
|
||||||
user: data.users[index],
|
user: data.users.find(
|
||||||
|
(x) => x._id === member._id.user,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.map(({ member, user }) => (
|
.map(({ member, user }) => (
|
||||||
|
|
|
@ -3570,10 +3570,10 @@ revolt-api@0.5.1-alpha.10-patch.0:
|
||||||
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.1-alpha.10-patch.0.tgz#97d31bec7dfa4573567097443acb059c4feaac20"
|
resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.1-alpha.10-patch.0.tgz#97d31bec7dfa4573567097443acb059c4feaac20"
|
||||||
integrity sha512-UyM890HkGlYNQOxpHuEpUsJHLt8Ujnjg9/zPEDGpbvS4iy0jmHX23Hh8tOCfb/ewxbNrtT3G1HpSWKOneW/vYg==
|
integrity sha512-UyM890HkGlYNQOxpHuEpUsJHLt8Ujnjg9/zPEDGpbvS4iy0jmHX23Hh8tOCfb/ewxbNrtT3G1HpSWKOneW/vYg==
|
||||||
|
|
||||||
revolt.js@5.0.0-alpha.12:
|
revolt.js@5.0.0-alpha.14:
|
||||||
version "5.0.0-alpha.12"
|
version "5.0.0-alpha.14"
|
||||||
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.12.tgz#06777f74f6a79161b18e02938a8d60d465395066"
|
resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.0-alpha.14.tgz#13b1d350a89467eb2ad6905a290ee1fada4150c1"
|
||||||
integrity sha512-QqgawsSjrFTKhMA5JBKii6MgOJ4VO2u1GBmjTiKzPR2krnoWHdPSbD7VvD2scMGMPXIaIxU3zA++tyN8mfzIFg==
|
integrity sha512-kZBIx9PX8Y8Esu51Y6OgeFwlpajtaRv/ap3YKlWEELlAcDAEDoSZj+iL4ilkxIxvh4RDJMlVlAforwSvXvy9DQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
axios "^0.19.2"
|
axios "^0.19.2"
|
||||||
eventemitter3 "^4.0.7"
|
eventemitter3 "^4.0.7"
|
||||||
|
|
Loading…
Reference in a new issue