2022-11-22 22:40:20 +00:00
|
|
|
<script setup lang="ts">
|
2022-11-22 23:08:36 +00:00
|
|
|
import type { Account } from 'masto'
|
2022-11-22 22:40:20 +00:00
|
|
|
|
|
|
|
const { account } = defineProps<{
|
|
|
|
account: Account
|
|
|
|
}>()
|
|
|
|
|
2022-11-23 13:59:13 +00:00
|
|
|
const isSelf = $computed(() => currentUser.value?.account?.id === account.id)
|
2022-11-22 22:40:20 +00:00
|
|
|
const relationship = $(useRelationship(account))
|
|
|
|
|
|
|
|
async function toggleFollow() {
|
|
|
|
relationship!.following = !relationship!.following
|
|
|
|
await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-23 13:59:13 +00:00
|
|
|
<button
|
|
|
|
v-if="!isSelf && relationship"
|
2022-11-23 14:39:48 +00:00
|
|
|
flex gap-1 items-center h-fit rounded hover="op100 text-white b-purple" group
|
2022-11-23 13:59:13 +00:00
|
|
|
@click="toggleFollow"
|
|
|
|
>
|
2022-11-22 22:40:20 +00:00
|
|
|
<div rounded w-28 p2 :group-hover="relationship?.following ? 'bg-red/30' : 'bg-purple/30'" :class="!relationship?.following ? 'bg-cyan/10' : ' bg-purple/10'">
|
|
|
|
<template v-if="relationship?.following">
|
|
|
|
<span group-hover="hidden">Following</span>
|
|
|
|
<span hidden group-hover="inline">Unfollow</span>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
{{ relationship?.followedBy ? 'Follow back' : 'Follow' }}
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
</template>
|