mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 01:15:28 +00:00
feat: port input modals to new system
This commit is contained in:
@@ -93,96 +93,6 @@ export function SpecialInputModal(props: SpecialProps) {
|
||||
|
||||
const { onClose } = props;
|
||||
switch (props.type) {
|
||||
case "create_group": {
|
||||
return (
|
||||
<InputModal
|
||||
onClose={onClose}
|
||||
question={<Text id="app.main.groups.create" />}
|
||||
field={<Text id="app.main.groups.name" />}
|
||||
callback={async (name) => {
|
||||
const group = await client.channels.createGroup({
|
||||
name,
|
||||
users: [],
|
||||
});
|
||||
|
||||
history.push(`/channel/${group._id}`);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case "create_server": {
|
||||
return (
|
||||
<InputModal
|
||||
onClose={onClose}
|
||||
question={<Text id="app.main.servers.create" />}
|
||||
field={<Text id="app.main.servers.name" />}
|
||||
description={
|
||||
<div>
|
||||
By creating this server, you agree to the{" "}
|
||||
<a
|
||||
href="https://revolt.chat/aup"
|
||||
target="_blank"
|
||||
rel="noreferrer">
|
||||
Acceptable Use Policy.
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
callback={async (name) => {
|
||||
const server = await client.servers.createServer({
|
||||
name,
|
||||
});
|
||||
|
||||
history.push(`/server/${server._id}`);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case "create_role": {
|
||||
return (
|
||||
<InputModal
|
||||
onClose={onClose}
|
||||
question={
|
||||
<Text id="app.settings.permissions.create_role" />
|
||||
}
|
||||
field={<Text id="app.settings.permissions.role_name" />}
|
||||
callback={async (name) => {
|
||||
const role = await props.server.createRole(name);
|
||||
props.callback(role.id);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case "set_custom_status": {
|
||||
return (
|
||||
<InputModal
|
||||
onClose={onClose}
|
||||
question={<Text id="app.context_menu.set_custom_status" />}
|
||||
field={<Text id="app.context_menu.custom_status" />}
|
||||
defaultValue={client.user?.status?.text ?? undefined}
|
||||
callback={(text) =>
|
||||
client.users.edit({
|
||||
status: {
|
||||
...client.user?.status,
|
||||
text: text.trim().length > 0 ? text : undefined,
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
case "add_friend": {
|
||||
return (
|
||||
<InputModal
|
||||
onClose={onClose}
|
||||
question={"Add Friend"}
|
||||
callback={(username) =>
|
||||
client.api
|
||||
.post(`/users/friend`, { username })
|
||||
.then(undefined)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ export function takeError(error: any): string {
|
||||
return "UnknownError";
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function mapError(error: any): never {
|
||||
throw takeError(error);
|
||||
}
|
||||
|
||||
export function getChannelName(
|
||||
channel: Channel,
|
||||
prefixType?: boolean,
|
||||
|
||||
Reference in New Issue
Block a user