2023-01-27 15:15:46 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { mastodon } from 'masto'
|
|
|
|
|
|
|
|
const { account, list } = defineProps<{
|
|
|
|
account: mastodon.v1.Account
|
|
|
|
hoverCard?: boolean
|
|
|
|
list: string
|
|
|
|
}>()
|
|
|
|
|
|
|
|
cacheAccount(account)
|
|
|
|
|
|
|
|
const client = useMastoClient()
|
|
|
|
|
|
|
|
const isRemoved = ref(false)
|
|
|
|
|
|
|
|
async function edit() {
|
|
|
|
try {
|
2024-08-16 15:52:08 +01:00
|
|
|
if (isRemoved.value)
|
|
|
|
await client.v1.lists.$select(list).accounts.create({ accountIds: [account.id] })
|
|
|
|
else
|
|
|
|
await client.v1.lists.$select(list).accounts.remove({ accountIds: [account.id] })
|
2023-01-27 15:15:46 +00:00
|
|
|
isRemoved.value = !isRemoved.value
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex justify-between hover:bg-active transition-100 items-center>
|
|
|
|
<AccountInfo
|
|
|
|
:account="account" hover p1 as="router-link"
|
|
|
|
:hover-card="hoverCard"
|
|
|
|
shrink
|
|
|
|
overflow-hidden
|
|
|
|
:to="getAccountRoute(account)"
|
|
|
|
/>
|
|
|
|
<div>
|
2023-02-03 10:48:27 +00:00
|
|
|
<CommonTooltip
|
|
|
|
:content="isRemoved ? $t('list.add_account') : $t('list.remove_account')"
|
|
|
|
:hover="isRemoved ? 'text-green' : 'text-red'"
|
|
|
|
>
|
2023-02-02 23:09:12 +00:00
|
|
|
<button
|
|
|
|
text-sm p2 border-1 transition-colors
|
|
|
|
border-dark
|
|
|
|
btn-action-icon
|
|
|
|
@click="edit"
|
|
|
|
>
|
|
|
|
<span :class="isRemoved ? 'i-ri:user-add-line' : 'i-ri:user-unfollow-line'" />
|
|
|
|
</button>
|
2023-01-27 15:15:46 +00:00
|
|
|
</CommonTooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|