Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Show } from "solid-js";
import { Show, createResource } from "solid-js";

import { useNavigate } from "@solidjs/router";
import { ServerMember, User } from "stoat.js";
import { ServerMember, User, PublicBot } from "stoat.js";
import { styled } from "styled-system/jsx";

import { useClient } from "@revolt/client";
import { UserContextMenu } from "@revolt/app";
import { useModals } from "@revolt/modal";

Expand All @@ -24,8 +25,18 @@ export function ProfileActions(props: {
member?: ServerMember;
}) {
const navigate = useNavigate();
const client = useClient();
const { openModal } = useModals();

const [publicBot] = createResource(
() => props.user.bot && props.user.id,
(id) =>
client()
.bots.fetchPublic(id)
.then((b) => (b instanceof PublicBot ? b : new PublicBot(client(), b)))
.catch(() => {}),
);

/**
* Open direct message channel
*/
Expand Down Expand Up @@ -65,6 +76,18 @@ export function ProfileActions(props: {
<Show when={props.user.relationship === "Friend"}>
<Button onPress={openDm}>Message</Button>
</Show>
<Show when={publicBot()}>
<Button
onPress={() =>
openModal({
type: "add_bot",
invite: publicBot()!,
})
}
>
Add Bot
</Button>
</Show>

<Show
when={
Expand Down