pull/1154/head
TeamAbron 2025-01-21 11:33:26 +03:30
parent e80bfc4daa
commit b0b8caebab
2 changed files with 10 additions and 6 deletions

View File

@ -37,6 +37,7 @@ export default function CreateInvite({
}: ModalProps<"create_invite">) {
const [processing, setProcessing] = useState(false);
const [code, setCode] = useState("abcdef");
const [url, setUrl] = useState("abcdef");
// Generate an invite code
useEffect(() => {
@ -44,7 +45,10 @@ export default function CreateInvite({
target
.createInvite()
.then(({ _id }) => setCode(_id))
.then((res) => {
setUrl(res.url || "default_url");
setCode(res._id || "default_code");
})
.catch((err) =>
modalController.push({ type: "error", error: takeError(err) }),
)
@ -65,7 +69,7 @@ export default function CreateInvite({
) : (
<Invite>
<Text id="app.special.modals.prompt.create_invite_created" />
<code style="font-size:14px">https://{window.location.host}/invite/{code}</code>
<code style="font-size:14px">{url}</code>
</Invite>
),
},
@ -79,11 +83,10 @@ export default function CreateInvite({
children: <Text id="app.context_menu.copy_link" />,
onClick: () =>
modalController.writeText(
`https://${window.location.host}/invite/${code}`
`${url}`
),
},
]}
/>
);
}

View File

@ -99,9 +99,10 @@ export const Channel = observer(
({ id, server_id }: { id: string; server_id: string }) => {
const client = useClient();
const state = useApplicationState();
if (!client.channels.get(id)) {
if (!client.channels.exists(id) && server_id) {
if (server_id) {
const server = client.servers.get(server_id);
const server = client.servers.get(server_id);
if (server && server.channel_ids.length > 0) {
let target_id = server.channel_ids[0];
const last_id = state.layout.getLastOpened(server_id);