forked from abner/for-legacy-web
feat: switch to revolt.js@6.0.0 + new revolt-api
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { Channel, User } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { StateUpdater, useState } from "preact/hooks";
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Hash, VolumeFull } from "@styled-icons/boxicons-regular";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
|
||||
import { useContext } from "preact/hooks";
|
||||
|
||||
import { AppContext } from "../../context/revoltjs/RevoltClient";
|
||||
|
||||
import { ImageIconBase, IconBaseProps } from "./IconBase";
|
||||
import fallback from "./assets/group.png";
|
||||
|
||||
import { ImageIconBase, IconBaseProps } from "./IconBase";
|
||||
|
||||
interface Props extends IconBaseProps<Channel> {
|
||||
isServerChannel?: boolean;
|
||||
}
|
||||
@@ -32,7 +33,7 @@ export default observer(
|
||||
...imgProps
|
||||
} = props;
|
||||
const iconURL = client.generateFileURL(
|
||||
target?.icon ?? attachment,
|
||||
target?.icon ?? attachment ?? undefined,
|
||||
{ max_side: 256 },
|
||||
animate,
|
||||
);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Attachment } from "revolt-api/types/Autumn";
|
||||
import { API } from "revolt.js";
|
||||
import { Nullable } from "revolt.js/dist/util/null";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
export interface IconBaseProps<T> {
|
||||
target?: T;
|
||||
url?: string;
|
||||
attachment?: Attachment;
|
||||
attachment?: Nullable<API.File>;
|
||||
|
||||
size: number;
|
||||
hover?: boolean;
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Check } from "@styled-icons/boxicons-regular";
|
||||
import { Cog } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Permission } from "revolt.js/dist/api/permissions";
|
||||
import { Server } from "revolt.js/dist/maps/Servers";
|
||||
import { Server } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Server } from "revolt.js/dist/maps/Servers";
|
||||
import { Server } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { useContext } from "preact/hooks";
|
||||
@@ -39,7 +39,7 @@ export default observer(
|
||||
const { target, attachment, size, animate, server_name, ...imgProps } =
|
||||
props;
|
||||
const iconURL = client.generateFileURL(
|
||||
target?.icon ?? attachment,
|
||||
target?.icon ?? attachment ?? undefined,
|
||||
{ max_side: 256 },
|
||||
animate,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Message as MessageObject } from "revolt.js/dist/maps/Messages";
|
||||
import { Message as MessageObject } from "revolt.js";
|
||||
|
||||
import { attachContextMenu } from "preact-context-menu";
|
||||
import { memo } from "preact/compat";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Message } from "revolt.js";
|
||||
import styled, { css, keyframes } from "styled-components/macro";
|
||||
import { decodeTime } from "ulid";
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { Send, ShieldX, HappyBeaming, Box } from "@styled-icons/boxicons-solid";
|
||||
import { Send, ShieldX } from "@styled-icons/boxicons-solid";
|
||||
import Axios, { CancelTokenSource } from "axios";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Permission } from "revolt.js/dist/api/permissions";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel, Permission } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
import { ulid } from "ulid";
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ import {
|
||||
MessageSquareEdit,
|
||||
} from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { SystemMessage as SystemMessageI } from "revolt-api/types/Channels";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Message, API } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { attachContextMenu } from "preact-context-menu";
|
||||
@@ -75,7 +74,8 @@ export const SystemMessage = observer(
|
||||
({ attachContext, message, highlight, hideInfo }: Props) => {
|
||||
const data = message.asSystemMessage;
|
||||
const SystemMessageIcon =
|
||||
iconDictionary[data.type as SystemMessageI["type"]] ?? InfoCircle;
|
||||
iconDictionary[data.type as API.SystemMessage["type"]] ??
|
||||
InfoCircle;
|
||||
|
||||
let children;
|
||||
switch (data.type) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Attachment as AttachmentI } from "revolt-api/types/Autumn";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Attachment.module.scss";
|
||||
import classNames from "classnames";
|
||||
@@ -14,7 +14,7 @@ import Spoiler from "./Spoiler";
|
||||
import TextFile from "./TextFile";
|
||||
|
||||
interface Props {
|
||||
attachment: AttachmentI;
|
||||
attachment: API.File;
|
||||
hasContent?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
Download,
|
||||
} from "@styled-icons/boxicons-regular";
|
||||
import { File, Video } from "@styled-icons/boxicons-solid";
|
||||
import { Attachment } from "revolt-api/types/Autumn";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./AttachmentActions.module.scss";
|
||||
import classNames from "classnames";
|
||||
@@ -17,7 +17,7 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient";
|
||||
import IconButton from "../../../ui/IconButton";
|
||||
|
||||
interface Props {
|
||||
attachment: Attachment;
|
||||
attachment: API.File;
|
||||
}
|
||||
|
||||
export default function AttachmentActions({ attachment }: Props) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Attachment } from "revolt-api/types/Autumn";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Attachment.module.scss";
|
||||
import classNames from "classnames";
|
||||
@@ -10,12 +10,12 @@ import { AppContext } from "../../../../context/revoltjs/RevoltClient";
|
||||
enum ImageLoadingState {
|
||||
Loading,
|
||||
Loaded,
|
||||
Error
|
||||
Error,
|
||||
}
|
||||
|
||||
type Props = JSX.HTMLAttributes<HTMLImageElement> & {
|
||||
attachment: Attachment;
|
||||
}
|
||||
attachment: API.File;
|
||||
};
|
||||
|
||||
export default function ImageFile({ attachment, ...props }: Props) {
|
||||
const [loading, setLoading] = useState(ImageLoadingState.Loading);
|
||||
@@ -23,25 +23,19 @@ export default function ImageFile({ attachment, ...props }: Props) {
|
||||
const { openScreen } = useIntermediate();
|
||||
const url = client.generateFileURL(attachment)!;
|
||||
|
||||
return <img
|
||||
{...props}
|
||||
src={url}
|
||||
alt={attachment.filename}
|
||||
loading="lazy"
|
||||
className={classNames(styles.image, {
|
||||
[styles.loading]: loading !== ImageLoadingState.Loaded
|
||||
})}
|
||||
onClick={() =>
|
||||
openScreen({ id: "image_viewer", attachment })
|
||||
}
|
||||
onMouseDown={(ev) =>
|
||||
ev.button === 1 && window.open(url, "_blank")
|
||||
}
|
||||
onLoad={() =>
|
||||
setLoading(ImageLoadingState.Loaded)
|
||||
}
|
||||
onError={() =>
|
||||
setLoading(ImageLoadingState.Error)
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<img
|
||||
{...props}
|
||||
src={url}
|
||||
alt={attachment.filename}
|
||||
loading="lazy"
|
||||
className={classNames(styles.image, {
|
||||
[styles.loading]: loading !== ImageLoadingState.Loaded,
|
||||
})}
|
||||
onClick={() => openScreen({ id: "image_viewer", attachment })}
|
||||
onMouseDown={(ev) => ev.button === 1 && window.open(url, "_blank")}
|
||||
onLoad={() => setLoading(ImageLoadingState.Loaded)}
|
||||
onError={() => setLoading(ImageLoadingState.Error)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ import { Reply } from "@styled-icons/boxicons-regular";
|
||||
import { File } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Channel, Message, API } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
@@ -174,7 +172,7 @@ export const MessageReply = observer(
|
||||
<ReplyBase head={index === 0}>
|
||||
{/*<Reply size={16} />*/}
|
||||
|
||||
{message.author?.relationship === RelationshipStatus.Blocked ? (
|
||||
{message.author?.relationship === "Blocked" ? (
|
||||
<Text id="app.main.channel.misc.blocked_user" />
|
||||
) : (
|
||||
<>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import axios from "axios";
|
||||
import { Attachment } from "revolt-api/types/Autumn";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Attachment.module.scss";
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import Preloader from "../../../ui/Preloader";
|
||||
|
||||
interface Props {
|
||||
attachment: Attachment;
|
||||
attachment: API.File;
|
||||
}
|
||||
|
||||
const fileCache: { [key: string]: string } = {};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { DownArrowAlt } from "@styled-icons/boxicons-regular";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Permission } from "revolt.js";
|
||||
import { Message as MessageObject } from "revolt.js/dist/maps/Messages";
|
||||
import { Message as MessageObject } from "revolt.js";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { openContextMenu } from "preact-context-menu";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UpArrowAlt } from "@styled-icons/boxicons-regular";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import { decodeTime } from "ulid";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { At, Reply as ReplyIcon } from "@styled-icons/boxicons-regular";
|
||||
import { At } from "@styled-icons/boxicons-regular";
|
||||
import { File, XCircle } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Channel, Message } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
@@ -65,7 +64,7 @@ export default observer(({ channel }: Props) => {
|
||||
(x) =>
|
||||
typeof x !== "undefined" &&
|
||||
x._id !== x.client.user!._id &&
|
||||
x.relationship !== RelationshipStatus.Blocked,
|
||||
x.relationship !== "Blocked",
|
||||
);
|
||||
|
||||
if (users.length > 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Embed as EmbedI } from "revolt-api/types/Channels";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Embed.module.scss";
|
||||
import classNames from "classnames";
|
||||
@@ -13,7 +13,7 @@ import Attachment from "../attachments/Attachment";
|
||||
import EmbedMedia from "./EmbedMedia";
|
||||
|
||||
interface Props {
|
||||
embed: EmbedI;
|
||||
embed: API.Embed;
|
||||
}
|
||||
|
||||
const MAX_EMBED_WIDTH = 480;
|
||||
@@ -128,7 +128,7 @@ export default function Embed({ embed }: Props) {
|
||||
<a
|
||||
onMouseDown={(ev) =>
|
||||
(ev.button === 0 || ev.button === 1) &&
|
||||
openLink(embed.url)
|
||||
openLink(embed.url!)
|
||||
}
|
||||
className={styles.title}>
|
||||
{embed.title}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Group } from "@styled-icons/boxicons-solid";
|
||||
import { autorun, reaction } from "mobx";
|
||||
import { reaction } from "mobx";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { RetrievedInvite } from "revolt-api/types/Invites";
|
||||
import { Message } from "revolt.js/dist/maps/Messages";
|
||||
import { Message, API } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
import { defer } from "../../../../lib/defer";
|
||||
import { isTouchscreenDevice } from "../../../../lib/isTouchscreenDevice";
|
||||
|
||||
import {
|
||||
@@ -85,9 +83,9 @@ export function EmbedInvite({ code }: Props) {
|
||||
const [processing, setProcessing] = useState(false);
|
||||
const [error, setError] = useState<string | undefined>(undefined);
|
||||
const [joinError, setJoinError] = useState<string | undefined>(undefined);
|
||||
const [invite, setInvite] = useState<RetrievedInvite | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const [invite, setInvite] = useState<
|
||||
(API.InviteResponse & { type: "Server" }) | undefined
|
||||
>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
@@ -96,7 +94,9 @@ export function EmbedInvite({ code }: Props) {
|
||||
) {
|
||||
client
|
||||
.fetchInvite(code)
|
||||
.then((data) => setInvite(data))
|
||||
.then((data) =>
|
||||
setInvite(data as API.InviteResponse & { type: "Server" }),
|
||||
)
|
||||
.catch((err) => setError(takeError(err)));
|
||||
}
|
||||
}, [client, code, invite, status]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import { JanuaryEmbed } from "revolt-api/types/January";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Embed.module.scss";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useIntermediate } from "../../../../context/intermediate/Intermediate";
|
||||
import { useClient } from "../../../../context/revoltjs/RevoltClient";
|
||||
|
||||
interface Props {
|
||||
embed: JanuaryEmbed;
|
||||
embed: API.Embed;
|
||||
width?: number;
|
||||
height: number;
|
||||
}
|
||||
@@ -94,7 +94,7 @@ export default function EmbedMedia({ embed, width, height }: Props) {
|
||||
onClick={() =>
|
||||
openScreen({
|
||||
id: "image_viewer",
|
||||
embed: embed.image,
|
||||
embed: embed.image!,
|
||||
})
|
||||
}
|
||||
onMouseDown={(ev) =>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { LinkExternal } from "@styled-icons/boxicons-regular";
|
||||
import { EmbedImage } from "revolt-api/types/January";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import styles from "./Embed.module.scss";
|
||||
|
||||
import IconButton from "../../../ui/IconButton";
|
||||
|
||||
interface Props {
|
||||
embed: EmbedImage;
|
||||
embed: API.Image;
|
||||
}
|
||||
|
||||
export default function EmbedMediaActions({ embed }: Props) {
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
import { Shield } from "@styled-icons/boxicons-regular";
|
||||
import { Badges } from "revolt-api/types/Users";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Localizer, Text } from "preact-i18n";
|
||||
|
||||
import Tooltip from "../Tooltip";
|
||||
|
||||
enum Badges {
|
||||
Developer = 1,
|
||||
Translator = 2,
|
||||
Supporter = 4,
|
||||
ResponsibleDisclosure = 8,
|
||||
Founder = 16,
|
||||
PlatformModeration = 32,
|
||||
ActiveSupporter = 64,
|
||||
Paw = 128,
|
||||
EarlyAdopter = 256,
|
||||
ReservedRelevantJokeBadge1 = 512,
|
||||
}
|
||||
|
||||
const BadgesBase = styled.div`
|
||||
gap: 8px;
|
||||
display: flex;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User } from "revolt.js";
|
||||
|
||||
import Checkbox, { CheckboxProps } from "../../ui/Checkbox";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Cog } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Link } from "react-router-dom";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { openContextMenu } from "preact-context-menu";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Children } from "../../../types/Preact";
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { VolumeMute, MicrophoneOff } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Masquerade } from "revolt-api/types/Channels";
|
||||
import { Presence } from "revolt-api/types/Users";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User, API } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { useApplicationState } from "../../../mobx/State";
|
||||
@@ -18,17 +16,17 @@ type VoiceStatus = "muted" | "deaf";
|
||||
interface Props extends IconBaseProps<User> {
|
||||
status?: boolean;
|
||||
voice?: VoiceStatus;
|
||||
masquerade?: Masquerade;
|
||||
masquerade?: API.Masquerade;
|
||||
showServerIdentity?: boolean;
|
||||
}
|
||||
|
||||
export function useStatusColour(user?: User) {
|
||||
const theme = useApplicationState().settings.theme;
|
||||
|
||||
return user?.online && user?.status?.presence !== Presence.Invisible
|
||||
? user?.status?.presence === Presence.Idle
|
||||
return user?.online && user?.status?.presence !== "Invisible"
|
||||
? user?.status?.presence === "Idle"
|
||||
? theme.getVariable("status-away")
|
||||
: user?.status?.presence === Presence.Busy
|
||||
: user?.status?.presence === "Busy"
|
||||
? theme.getVariable("status-busy")
|
||||
: theme.getVariable("status-online")
|
||||
: theme.getVariable("status-invisible");
|
||||
@@ -94,7 +92,7 @@ export default observer(
|
||||
|
||||
url =
|
||||
client.generateFileURL(
|
||||
override ?? target?.avatar ?? attachment,
|
||||
override ?? target?.avatar ?? attachment ?? undefined,
|
||||
{ max_side: 256 },
|
||||
animate,
|
||||
) ?? (target ? target.defaultAvatarURL : fallback);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Masquerade } from "revolt-api/types/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { Nullable } from "revolt.js/dist/util/null";
|
||||
import { User, API } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
@@ -31,7 +29,7 @@ const BotBadge = styled.div`
|
||||
type UsernameProps = JSX.HTMLAttributes<HTMLElement> & {
|
||||
user?: User;
|
||||
prefixAt?: boolean;
|
||||
masquerade?: Masquerade;
|
||||
masquerade?: API.Masquerade;
|
||||
showServerIdentity?: boolean | "both";
|
||||
};
|
||||
|
||||
@@ -116,7 +114,7 @@ export default function UserShort({
|
||||
user?: User;
|
||||
size?: number;
|
||||
prefixAt?: boolean;
|
||||
masquerade?: Masquerade;
|
||||
masquerade?: API.Masquerade;
|
||||
showServerIdentity?: boolean;
|
||||
}) {
|
||||
const { openScreen } = useIntermediate();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Presence } from "revolt-api/types/Users";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User, API } from "revolt.js";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -25,15 +24,15 @@ export default observer(({ user, tooltip }: Props) => {
|
||||
return <>{user.status.text}</>;
|
||||
}
|
||||
|
||||
if (user.status?.presence === Presence.Busy) {
|
||||
if (user.status?.presence === "Busy") {
|
||||
return <Text id="app.status.busy" />;
|
||||
}
|
||||
|
||||
if (user.status?.presence === Presence.Idle) {
|
||||
if (user.status?.presence === "Idle") {
|
||||
return <Text id="app.status.idle" />;
|
||||
}
|
||||
|
||||
if (user.status?.presence === Presence.Invisible) {
|
||||
if (user.status?.presence === "Invisible") {
|
||||
return <Text id="app.status.offline" />;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Suspense, lazy } from "preact/compat";
|
||||
const Renderer = lazy(() => import("./Renderer"));
|
||||
|
||||
export interface MarkdownProps {
|
||||
content?: string;
|
||||
content?: string | null;
|
||||
disallowBigEmoji?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ export default function Renderer({ content, disallowBigEmoji }: MarkdownProps) {
|
||||
const { openLink } = useIntermediate();
|
||||
|
||||
if (typeof content === "undefined") return null;
|
||||
if (content.length === 0) return null;
|
||||
if (!content || content.length === 0) return null;
|
||||
|
||||
// We replace the message with the mention at the time of render.
|
||||
// We don't care if the mention changes.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import { X } from "@styled-icons/boxicons-regular";
|
||||
import { Crown } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Presence } from "revolt-api/types/Users";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { User, Channel } from "revolt.js";
|
||||
|
||||
import styles from "./Item.module.scss";
|
||||
import classNames from "classnames";
|
||||
@@ -64,7 +62,7 @@ export const UserButton = observer((props: UserProps) => {
|
||||
data-alert={typeof alert === "string"}
|
||||
data-online={
|
||||
typeof channel !== "undefined" ||
|
||||
(user.online && user.status?.presence !== Presence.Invisible)
|
||||
(user.online && user.status?.presence !== "Invisible")
|
||||
}
|
||||
onContextMenu={attachContextMenu("Menu", {
|
||||
user: user._id,
|
||||
|
||||
@@ -5,8 +5,7 @@ import {
|
||||
Notepad,
|
||||
} from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Link, Redirect, useLocation, useParams } from "react-router-dom";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import { Link, useLocation, useParams } from "react-router-dom";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
@@ -68,7 +67,7 @@ export default observer(() => {
|
||||
|
||||
// ! FIXME: must be a better way
|
||||
const incoming = [...client.users.values()].filter(
|
||||
(user) => user?.relationship === RelationshipStatus.Incoming,
|
||||
(user) => user?.relationship === "Incoming",
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,11 +2,9 @@ import { Plus } from "@styled-icons/boxicons-regular";
|
||||
import { Cog, Compass } from "@styled-icons/boxicons-solid";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Link, useHistory, useLocation, useParams } from "react-router-dom";
|
||||
import { RelationshipStatus } from "revolt-api/types/Users";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { attachContextMenu } from "preact-context-menu";
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
import ConditionalLink from "../../../lib/ConditionalLink";
|
||||
import PaintCounter from "../../../lib/PaintCounter";
|
||||
@@ -248,7 +246,7 @@ export default observer(() => {
|
||||
const { openScreen } = useIntermediate();
|
||||
|
||||
let alertCount = [...client.users.values()].filter(
|
||||
(x) => x.relationship === RelationshipStatus.Incoming,
|
||||
(x) => x.relationship === "Incoming",
|
||||
).length;
|
||||
|
||||
const homeActive =
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Redirect, useParams } from "react-router";
|
||||
import { Server } from "revolt.js/dist/maps/Servers";
|
||||
import { Server } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { attachContextMenu } from "preact-context-menu";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Channel } from "revolt.js";
|
||||
|
||||
import { getRenderer } from "../../../lib/renderer/Singleton";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { GroupedVirtuoso } from "react-virtuoso";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { Channel, User } from "revolt.js";
|
||||
import styled, { css } from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
import { autorun } from "mobx";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Role } from "revolt-api/types/Servers";
|
||||
import { Presence } from "revolt-api/types/Users";
|
||||
import { Channel } from "revolt.js/dist/maps/Channels";
|
||||
import { Server } from "revolt.js/dist/maps/Servers";
|
||||
import { User } from "revolt.js/dist/maps/Users";
|
||||
import { Channel, Server, User, API } from "revolt.js";
|
||||
|
||||
import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
@@ -62,7 +58,7 @@ function useEntries(
|
||||
.map((id) => {
|
||||
return [id, roles![id], roles![id].rank ?? 0] as [
|
||||
string,
|
||||
Role,
|
||||
API.Role,
|
||||
number,
|
||||
];
|
||||
})
|
||||
@@ -96,7 +92,7 @@ function useEntries(
|
||||
const sort = member?.nickname ?? u.username;
|
||||
const entry = [u, sort] as [User, string];
|
||||
|
||||
if (!u.online || u.status?.presence === Presence.Invisible) {
|
||||
if (!u.online || u.status?.presence === "Invisible") {
|
||||
categories.offline.push(entry);
|
||||
} else {
|
||||
if (isServer) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Link, useParams } from "react-router-dom";
|
||||
import { Message as MessageI } from "revolt.js/dist/maps/Messages";
|
||||
import { Message as MessageI } from "revolt.js";
|
||||
import styled from "styled-components/macro";
|
||||
|
||||
import { Text } from "preact-i18n";
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { OverrideField } from "revolt-api/types/_common";
|
||||
import { API } from "revolt.js";
|
||||
import { Permission } from "revolt.js";
|
||||
|
||||
import { PermissionSelect } from "./PermissionSelect";
|
||||
|
||||
interface Props {
|
||||
value: OverrideField | number;
|
||||
onChange: (v: OverrideField | number) => void;
|
||||
value: API.OverrideField | number;
|
||||
onChange: (v: API.OverrideField | number) => void;
|
||||
|
||||
filter?: (keyof typeof Permission)[];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Long from "long";
|
||||
import { OverrideField } from "revolt-api/types/_common";
|
||||
import { API } from "revolt.js";
|
||||
import { Permission } from "revolt.js";
|
||||
import styled from "styled-components";
|
||||
|
||||
@@ -13,8 +13,8 @@ import { OverrideSwitch } from "./OverrideSwitch";
|
||||
interface PermissionSelectProps {
|
||||
id: keyof typeof Permission;
|
||||
permission: number;
|
||||
value: OverrideField | number;
|
||||
onChange: (value: OverrideField | number) => void;
|
||||
value: API.OverrideField | number;
|
||||
onChange: (value: API.OverrideField | number) => void;
|
||||
}
|
||||
|
||||
type State = "Allow" | "Neutral" | "Deny";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Role } from "revolt-api/types/Servers";
|
||||
import { API } from "revolt.js";
|
||||
|
||||
import Checkbox from "../../ui/Checkbox";
|
||||
|
||||
export type RoleOrDefault = (
|
||||
| Role
|
||||
| API.Role
|
||||
| {
|
||||
name: string;
|
||||
permissions: number;
|
||||
|
||||
Reference in New Issue
Block a user