mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
Use tabWidth 4 without actual tabs.
This commit is contained in:
@@ -7,9 +7,9 @@ import { useContext, useEffect, useState } from "preact/hooks";
|
||||
|
||||
import RequiresOnline from "../../context/revoltjs/RequiresOnline";
|
||||
import {
|
||||
AppContext,
|
||||
ClientStatus,
|
||||
StatusContext,
|
||||
AppContext,
|
||||
ClientStatus,
|
||||
StatusContext,
|
||||
} from "../../context/revoltjs/RevoltClient";
|
||||
import { takeError } from "../../context/revoltjs/util";
|
||||
|
||||
@@ -20,109 +20,109 @@ import Overline from "../../components/ui/Overline";
|
||||
import Preloader from "../../components/ui/Preloader";
|
||||
|
||||
export default function Invite() {
|
||||
const history = useHistory();
|
||||
const client = useContext(AppContext);
|
||||
const status = useContext(StatusContext);
|
||||
const { code } = useParams<{ code: string }>();
|
||||
const [processing, setProcessing] = useState(false);
|
||||
const [error, setError] = useState<string | undefined>(undefined);
|
||||
const [invite, setInvite] = useState<Invites.RetrievedInvite | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const history = useHistory();
|
||||
const client = useContext(AppContext);
|
||||
const status = useContext(StatusContext);
|
||||
const { code } = useParams<{ code: string }>();
|
||||
const [processing, setProcessing] = useState(false);
|
||||
const [error, setError] = useState<string | undefined>(undefined);
|
||||
const [invite, setInvite] = useState<Invites.RetrievedInvite | undefined>(
|
||||
undefined,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (
|
||||
typeof invite === "undefined" &&
|
||||
(status === ClientStatus.ONLINE || status === ClientStatus.READY)
|
||||
) {
|
||||
client
|
||||
.fetchInvite(code)
|
||||
.then((data) => setInvite(data))
|
||||
.catch((err) => setError(takeError(err)));
|
||||
}
|
||||
}, [status]);
|
||||
useEffect(() => {
|
||||
if (
|
||||
typeof invite === "undefined" &&
|
||||
(status === ClientStatus.ONLINE || status === ClientStatus.READY)
|
||||
) {
|
||||
client
|
||||
.fetchInvite(code)
|
||||
.then((data) => setInvite(data))
|
||||
.catch((err) => setError(takeError(err)));
|
||||
}
|
||||
}, [status]);
|
||||
|
||||
if (typeof invite === "undefined") {
|
||||
return (
|
||||
<div className={styles.preloader}>
|
||||
<RequiresOnline>
|
||||
{error ? (
|
||||
<Overline type="error" error={error} />
|
||||
) : (
|
||||
<Preloader type="spinner" />
|
||||
)}
|
||||
</RequiresOnline>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (typeof invite === "undefined") {
|
||||
return (
|
||||
<div className={styles.preloader}>
|
||||
<RequiresOnline>
|
||||
{error ? (
|
||||
<Overline type="error" error={error} />
|
||||
) : (
|
||||
<Preloader type="spinner" />
|
||||
)}
|
||||
</RequiresOnline>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ! FIXME: add i18n translations
|
||||
return (
|
||||
<div
|
||||
className={styles.invite}
|
||||
style={{
|
||||
backgroundImage: invite.server_banner
|
||||
? `url('${client.generateFileURL(invite.server_banner)}')`
|
||||
: undefined,
|
||||
}}>
|
||||
<div className={styles.leave}>
|
||||
<ArrowBack size={32} onClick={() => history.push("/")} />
|
||||
</div>
|
||||
// ! FIXME: add i18n translations
|
||||
return (
|
||||
<div
|
||||
className={styles.invite}
|
||||
style={{
|
||||
backgroundImage: invite.server_banner
|
||||
? `url('${client.generateFileURL(invite.server_banner)}')`
|
||||
: undefined,
|
||||
}}>
|
||||
<div className={styles.leave}>
|
||||
<ArrowBack size={32} onClick={() => history.push("/")} />
|
||||
</div>
|
||||
|
||||
{!processing && (
|
||||
<div className={styles.icon}>
|
||||
<ServerIcon
|
||||
attachment={invite.server_icon}
|
||||
server_name={invite.server_name}
|
||||
size={64}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{!processing && (
|
||||
<div className={styles.icon}>
|
||||
<ServerIcon
|
||||
attachment={invite.server_icon}
|
||||
server_name={invite.server_name}
|
||||
size={64}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.details}>
|
||||
{processing ? (
|
||||
<Preloader type="ring" />
|
||||
) : (
|
||||
<>
|
||||
<h1>{invite.server_name}</h1>
|
||||
<h2>#{invite.channel_name}</h2>
|
||||
<h3>
|
||||
Invited by{" "}
|
||||
<UserIcon
|
||||
size={24}
|
||||
attachment={invite.user_avatar}
|
||||
/>{" "}
|
||||
{invite.user_name}
|
||||
</h3>
|
||||
<Overline type="error" error={error} />
|
||||
<Button
|
||||
contrast
|
||||
onClick={async () => {
|
||||
if (status === ClientStatus.READY) {
|
||||
return history.push("/");
|
||||
}
|
||||
<div className={styles.details}>
|
||||
{processing ? (
|
||||
<Preloader type="ring" />
|
||||
) : (
|
||||
<>
|
||||
<h1>{invite.server_name}</h1>
|
||||
<h2>#{invite.channel_name}</h2>
|
||||
<h3>
|
||||
Invited by{" "}
|
||||
<UserIcon
|
||||
size={24}
|
||||
attachment={invite.user_avatar}
|
||||
/>{" "}
|
||||
{invite.user_name}
|
||||
</h3>
|
||||
<Overline type="error" error={error} />
|
||||
<Button
|
||||
contrast
|
||||
onClick={async () => {
|
||||
if (status === ClientStatus.READY) {
|
||||
return history.push("/");
|
||||
}
|
||||
|
||||
try {
|
||||
setProcessing(true);
|
||||
try {
|
||||
setProcessing(true);
|
||||
|
||||
let result = await client.joinInvite(code);
|
||||
if (result.type === "Server") {
|
||||
history.push(
|
||||
`/server/${result.server._id}/channel/${result.channel._id}`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(takeError(err));
|
||||
setProcessing(false);
|
||||
}
|
||||
}}>
|
||||
{status === ClientStatus.READY
|
||||
? "Login to REVOLT"
|
||||
: "Accept Invite"}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
let result = await client.joinInvite(code);
|
||||
if (result.type === "Server") {
|
||||
history.push(
|
||||
`/server/${result.server._id}/channel/${result.channel._id}`,
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(takeError(err));
|
||||
setProcessing(false);
|
||||
}
|
||||
}}>
|
||||
{status === ClientStatus.READY
|
||||
? "Login to REVOLT"
|
||||
: "Accept Invite"}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user