feat: blocking feedback on follow button

This commit is contained in:
patak 2022-12-19 15:01:41 +01:00
parent 79fb8c5d92
commit e72d45a208
6 changed files with 34 additions and 2 deletions

View file

@ -23,6 +23,18 @@ async function toggleFollow() {
}
}
async function unblock() {
relationship!.blocking = false
try {
const newRel = await useMasto().accounts.unblock(account.id)
Object.assign(relationship!, newRel)
}
catch {
// TODO error handling
relationship!.blocking = true
}
}
const { t } = useI18n()
useCommand({
@ -39,6 +51,9 @@ const buttonStyle = $computed(() => {
if (!relationship)
return 'text-inverted'
if (relationship.blocking)
return 'text-inverted bg-red border-red'
// If following, use a label style with a strong border for Mutuals
if (relationship.following)
return `text-base ${relationship.followedBy ? 'border-strong' : 'border-base'}`
@ -54,9 +69,16 @@ const buttonStyle = $computed(() => {
gap-1 items-center group
:disabled="relationship?.requested"
border-1
rounded-full flex="~ gap2 center" font-500 w-30 h-fit py1 :class="buttonStyle" :hover="relationship?.following ? 'border-red text-red' : 'bg-base border-primary text-primary'" @click="toggleFollow"
rounded-full flex="~ gap2 center" font-500 w-30 h-fit py1
:class="buttonStyle"
:hover="!relationship?.blocking && relationship?.following ? 'border-red text-red' : 'bg-base border-primary text-primary'"
@click="relationship?.blocking ? unblock() : toggleFollow()"
>
<template v-if="relationship?.following">
<template v-if="relationship?.blocking">
<span group-hover="hidden">{{ $t('account.blocking') }}</span>
<span hidden group-hover="inline">{{ $t('account.unblock') }}</span>
</template>
<template v-else-if="relationship?.following">
<span group-hover="hidden">{{ relationship?.followedBy ? $t('account.mutuals') : $t('account.following') }}</span>
<span hidden group-hover="inline">{{ $t('account.unfollow') }}</span>
</template>