1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-20 07:49:57 +00:00
elk/components/account/AccountMoreButton.vue

140 lines
4.6 KiB
Vue
Raw Normal View History

2022-11-25 11:39:21 +00:00
<script setup lang="ts">
import type { Account } from 'masto'
const { account } = defineProps<{
account: Account
command?: boolean
2022-11-25 11:39:21 +00:00
}>()
let relationship = $(useRelationship(account))
2022-11-25 18:24:46 +00:00
const isSelf = $computed(() => currentUser.value?.account.id === account.id)
const masto = useMasto()
2022-11-26 12:58:10 +00:00
const toggleMute = async () => {
2022-11-25 11:39:21 +00:00
// TODO: Add confirmation
2022-11-26 12:58:10 +00:00
relationship!.muting = !relationship!.muting
relationship = relationship!.muting
? await masto.accounts.mute(account.id, {
2022-11-26 12:58:10 +00:00
// TODO support more options
})
: await masto.accounts.unmute(account.id)
2022-11-25 11:39:21 +00:00
}
2022-11-26 12:58:10 +00:00
const toggleBlockUser = async () => {
2022-11-25 11:39:21 +00:00
// TODO: Add confirmation
2022-11-26 12:58:10 +00:00
relationship!.blocking = !relationship!.blocking
relationship = await masto.accounts[relationship!.blocking ? 'block' : 'unblock'](account.id)
2022-11-25 11:39:21 +00:00
}
2022-11-26 12:58:10 +00:00
const toggleBlockDomain = async () => {
2022-11-25 11:39:21 +00:00
// TODO: Add confirmation
2022-11-26 12:58:10 +00:00
relationship!.domainBlocking = !relationship!.domainBlocking
await masto.domainBlocks[relationship!.domainBlocking ? 'block' : 'unblock'](getServerName(account))
2022-11-25 11:39:21 +00:00
}
</script>
<template>
<CommonDropdown :eager-mount="command">
2022-11-29 21:24:26 +00:00
<button flex gap-1 items-center w-full rounded op75 hover="op100 text-purple" group aria-label="More actions">
2022-11-25 11:39:21 +00:00
<div rounded-5 p2 group-hover="bg-purple/10">
<div i-ri:more-2-fill />
</div>
</button>
<template #popper>
<NuxtLink :to="account.url" external target="_blank">
<CommonDropdownItem
:text="$t('menu.open_in_original_site')"
icon="i-ri:arrow-right-up-line"
:command="command"
/>
2022-11-25 11:39:21 +00:00
</NuxtLink>
<template v-if="currentUser">
<template v-if="!isSelf">
<CommonDropdownItem
:text="$t('menu.mention_account', [`@${account.acct}`])"
icon="i-ri:at-line"
:command="command"
@click="mentionUser(account)"
/>
<CommonDropdownItem
:text="$t('menu.direct_message_account', [`@${account.acct}`])"
icon="i-ri:message-3-line"
:command="command"
@click="directMessageUser(account)"
/>
2022-11-26 12:58:10 +00:00
<CommonDropdownItem
v-if="!relationship?.muting"
:text="$t('menu.mute_account', [`@${account.acct}`])"
icon="i-ri:volume-up-fill"
:command="command"
@click="toggleMute"
/>
<CommonDropdownItem
v-else
:text="$t('menu.unmute_account', [`@${account.acct}`])"
icon="i-ri:volume-mute-line"
:command="command"
@click="toggleMute"
/>
<CommonDropdownItem
v-if="!relationship?.blocking"
:text="$t('menu.block_account', [`@${account.acct}`])"
icon="i-ri:forbid-2-line"
:command="command"
@click="toggleBlockUser"
/>
<CommonDropdownItem
v-else
:text="$t('menu.unblock_account', [`@${account.acct}`])"
icon="i-ri:checkbox-circle-line"
:command="command"
@click="toggleBlockUser"
/>
2022-11-29 01:21:03 +00:00
<template v-if="getServerName(account) !== currentServer">
<CommonDropdownItem
v-if="!relationship?.domainBlocking"
:text="$t('menu.block_domain', [getServerName(account)])"
2022-11-29 01:21:03 +00:00
icon="i-ri:shut-down-line"
:command="command"
2022-11-29 01:21:03 +00:00
@click="toggleBlockDomain"
/>
<CommonDropdownItem
v-else
:text="$t('menu.unblock_domain', [getServerName(account)])"
icon="i-ri:restart-line"
:command="command"
@click="toggleBlockDomain"
/>
2022-11-29 01:21:03 +00:00
</template>
</template>
<template v-else>
<NuxtLink to="/pinned">
<CommonDropdownItem :text="$t('account.pinned')" icon="i-ri:pushpin-line" :command="command" />
</NuxtLink>
<NuxtLink to="/favourites">
<CommonDropdownItem :text="$t('account.favourites')" icon="i-ri:heart-3-line" :command="command" />
</NuxtLink>
<NuxtLink to="/mutes">
<CommonDropdownItem :text="$t('account.muted_users')" icon="i-ri:volume-mute-line" :command="command" />
</NuxtLink>
<NuxtLink to="/blocks">
<CommonDropdownItem :text="$t('account.blocked_users')" icon="i-ri:forbid-2-line" :command="command" />
</NuxtLink>
<NuxtLink to="/domain_blocks">
2022-11-29 11:26:24 +00:00
<CommonDropdownItem :text="$t('account.blocked_domains')" icon="i-ri:shut-down-line" :command="command" />
</NuxtLink>
</template>
2022-11-25 18:24:46 +00:00
</template>
2022-11-25 11:39:21 +00:00
</template>
</CommonDropdown>
</template>