feat: unify follow button (#25)
This commit is contained in:
parent
ac156034d1
commit
7beaab0baf
3 changed files with 36 additions and 33 deletions
|
@ -1,20 +1,10 @@
|
|||
<script setup lang="ts">
|
||||
import type { Account, MastoClient } from 'masto'
|
||||
import type { Account } from 'masto'
|
||||
|
||||
const { account } = defineProps<{
|
||||
account: Account
|
||||
}>()
|
||||
|
||||
const relationship = $(useRelationship(account))
|
||||
|
||||
let masto: MastoClient
|
||||
|
||||
async function toggleFollow() {
|
||||
relationship!.following = !relationship!.following
|
||||
masto ??= await useMasto()
|
||||
await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
|
||||
}
|
||||
|
||||
const createdAt = $computed(() => {
|
||||
const date = new Date(account.createdAt)
|
||||
return new Intl.DateTimeFormat('en-US', { month: 'long', day: 'numeric', year: 'numeric' }).format(date)
|
||||
|
@ -42,11 +32,7 @@ const createdAt = $computed(() => {
|
|||
</NuxtLink>
|
||||
</div>
|
||||
<div flex gap-2>
|
||||
<button v-if="relationship" flex gap-1 items-center w-full rounded op75 hover="op100 text-white b-purple" group @click="toggleFollow">
|
||||
<div rounded w-30 p2 group-hover="bg-rose/10">
|
||||
{{ relationship?.following ? 'Unfollow' : relationship?.followedBy ? 'Follow back' : 'Follow' }}
|
||||
</div>
|
||||
</button>
|
||||
<AccountFollowButton :account="account" />
|
||||
<!-- <button flex gap-1 items-center w-full rounded op75 hover="op100 text-purple" group>
|
||||
<div rounded p2 group-hover="bg-rose/10">
|
||||
<div i-ri:bell-line />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue