Skip to content

Commit 3ac3b69

Browse files
committed
feat: make it fancier
1 parent cbe145e commit 3ac3b69

19 files changed

Lines changed: 1343 additions & 76 deletions

File tree

app/components/Package/Likes.vue

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,19 @@ const { user } = useAtproto()
3838
const authModal = useModal('auth-modal')
3939
const compactNumberFormatter = useCompactNumberFormatter()
4040
41-
const { data: likesData, status: likeStatus } = useFetch<PackageLikes>(
42-
() => `/api/social/likes/${props.packageName}`,
43-
{
44-
default: () => ({
45-
totalLikes: 0,
46-
userHasLiked: false,
47-
topLikedRank: null,
48-
}),
49-
server: false,
50-
},
51-
)
52-
53-
const isLoadingLikeData = computed(
54-
() => likeStatus.value === 'pending' || likeStatus.value === 'idle',
55-
)
41+
const { data: likesData } = useFetch<PackageLikes>(() => `/api/social/likes/${props.packageName}`, {
42+
default: () => ({
43+
totalLikes: 0,
44+
userHasLiked: false,
45+
topLikedRank: null,
46+
}),
47+
server: false,
48+
})
5649
const isPackageLiked = computed(() => likesData.value?.userHasLiked ?? false)
5750
const topLikedRank = computed(() => likesData.value?.topLikedRank ?? null)
5851
const likeButtonLabel = computed(() =>
5952
isPackageLiked.value ? $t('package.likes.unlike') : $t('package.likes.like'),
6053
)
61-
const likeTooltipText = computed(() =>
62-
isLoadingLikeData.value ? $t('common.loading') : likeButtonLabel.value,
63-
)
6454
const topLikedBadgeLabel = computed(() =>
6555
topLikedRank.value == null
6656
? ''
@@ -127,7 +117,7 @@ const likeAction = async () => {
127117

128118
<template>
129119
<div class="relative inline-flex items-center">
130-
<TooltipApp :text="likeTooltipText" position="bottom" class="items-center" strategy="fixed">
120+
<TooltipApp :text="likeButtonLabel" position="bottom" class="items-center" strategy="fixed">
131121
<div class="relative inline-flex">
132122
<span v-if="showLikeFloat" :key="likeFloatKey" aria-hidden="true" class="like-float"
133123
>+1</span
@@ -149,14 +139,7 @@ const likeAction = async () => {
149139
aria-hidden="true"
150140
class="inline-block w-4 h-4"
151141
/>
152-
<span
153-
v-if="isLoadingLikeData"
154-
class="i-svg-spinners:ring-resize w-3 h-3 my-0.5"
155-
aria-hidden="true"
156-
/>
157-
<span v-else>
158-
{{ compactNumberFormatter.format(likesData?.totalLikes ?? 0) }}
159-
</span>
142+
<span>{{ compactNumberFormatter.format(likesData?.totalLikes ?? 0) }}</span>
160143
</ButtonBase>
161144
</div>
162145
</TooltipApp>

0 commit comments

Comments
 (0)