flotilla/src/app/components/RoomMemberMenu.svelte

52 lines
1.4 KiB
Svelte
Raw Normal View History

2026-07-03 16:20:45 +00:00
<script lang="ts">
import {onMount} from "svelte"
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Confirm from "@lib/components/Confirm.svelte"
2026-07-28 16:16:26 +00:00
import {rooms} from "@app/core"
2026-07-03 16:20:45 +00:00
import {pushModal} from "@app/modal"
import {pushToast} from "@app/toast"
type Props = {
url: string
h: string
pubkey: string
onClick: () => void
}
const {url, h, pubkey, onClick}: Props = $props()
const removeMember = () =>
pushModal(Confirm, {
title: "Remove Member",
message: "Are you sure you want to remove this user from the room?",
confirm: async () => {
2026-07-28 16:16:26 +00:00
const command = await $rooms.removeMember(url, {h}, pubkey)
const error = await command.publish().waitForError()
2026-07-03 16:20:45 +00:00
if (error) {
pushToast({theme: "error", message: error})
} else {
pushToast({message: "Member has successfully been removed!"})
history.back()
}
},
})
let ul: Element
onMount(() => {
ul.addEventListener("click", onClick)
})
</script>
<ul class="menu whitespace-nowrap rounded-2xl bg-surface p-2" bind:this={ul}>
<li>
<Button class="text-error" onclick={removeMember}>
<Icon icon={MinusCircle} />
Remove Member
</Button>
</li>
</ul>