2023-10-23 01:11:00 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { mastodon } from 'masto'
|
|
|
|
|
|
|
|
const { account, ...props } = defineProps<{
|
|
|
|
account: mastodon.v1.Account
|
|
|
|
relationship?: mastodon.v1.Relationship
|
|
|
|
}>()
|
2024-02-22 00:20:08 +09:00
|
|
|
const relationship = computed(() => props.relationship || useRelationship(account).value)
|
|
|
|
const { client } = useMasto()
|
2023-10-23 01:11:00 +09:00
|
|
|
|
|
|
|
async function authorizeFollowRequest() {
|
2024-02-22 00:20:08 +09:00
|
|
|
relationship.value!.requestedBy = false
|
|
|
|
relationship.value!.followedBy = true
|
2023-10-23 01:11:00 +09:00
|
|
|
try {
|
2024-02-22 00:20:08 +09:00
|
|
|
const newRel = await client.value.v1.followRequests.$select(account.id).authorize()
|
2023-10-23 01:11:00 +09:00
|
|
|
Object.assign(relationship!, newRel)
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(err)
|
2024-02-22 00:20:08 +09:00
|
|
|
relationship.value!.requestedBy = true
|
|
|
|
relationship.value!.followedBy = false
|
2023-10-23 01:11:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function rejectFollowRequest() {
|
2024-02-22 00:20:08 +09:00
|
|
|
relationship.value!.requestedBy = false
|
2023-10-23 01:11:00 +09:00
|
|
|
try {
|
2024-02-22 00:20:08 +09:00
|
|
|
const newRel = await client.value.v1.followRequests.$select(account.id).reject()
|
2023-10-23 01:11:00 +09:00
|
|
|
Object.assign(relationship!, newRel)
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(err)
|
2024-02-22 00:20:08 +09:00
|
|
|
relationship.value!.requestedBy = true
|
2023-10-23 01:11:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex gap-4>
|
|
|
|
<template v-if="relationship?.requestedBy">
|
2024-04-06 12:58:50 +09:00
|
|
|
<CommonTooltip :content="$t('account.authorize')">
|
2023-10-23 01:11:00 +09:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
rounded-full text-sm p2 border-1
|
|
|
|
hover:text-green transition-colors
|
|
|
|
@click="authorizeFollowRequest"
|
|
|
|
>
|
|
|
|
<span block text-current i-ri:check-fill />
|
|
|
|
</button>
|
|
|
|
</CommonTooltip>
|
2024-04-06 12:58:50 +09:00
|
|
|
<CommonTooltip :content="$t('account.reject')">
|
2023-10-23 01:11:00 +09:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
rounded-full text-sm p2 border-1
|
|
|
|
hover:text-red transition-colors
|
|
|
|
@click="rejectFollowRequest"
|
|
|
|
>
|
|
|
|
<span block text-current i-ri:close-fill />
|
|
|
|
</button>
|
|
|
|
</CommonTooltip>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<span text-secondary>
|
|
|
|
{{ relationship?.followedBy ? $t('account.authorized') : $t('account.rejected') }}
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|