feat: add "View results" button to poll post

This commit is contained in:
TAKAHASHI Shuuji 2025-08-13 15:03:02 +09:00
parent 78fd25ac10
commit 9349b5391d
2 changed files with 12 additions and 7 deletions

View file

@ -14,7 +14,7 @@ const timeAgoOptions = useTimeAgoOptions()
const expiredTimeAgo = useTimeAgo(poll.expiresAt!, timeAgoOptions)
const expiredTimeFormatted = useFormattedDateTime(poll.expiresAt!)
const { formatPercentage } = useHumanReadableNumber()
const loading = ref(false)
const isLoading = ref(false)
const { client } = useMasto()
@ -41,11 +41,11 @@ async function vote(e: Event) {
}
async function refresh() {
if (loading.value) {
if (isLoading.value) {
return
}
loading.value = true
isLoading.value = true
try {
const newPoll = await client.value.v1.polls.$select(poll.id).fetch()
Object.assign(poll, newPoll)
@ -55,7 +55,7 @@ async function refresh() {
console.error(e)
}
finally {
loading.value = false
isLoading.value = false
}
}
@ -106,9 +106,13 @@ const votersCount = computed(() => poll.votersCount ?? poll.votesCount ?? 0)
</CommonTooltip>
</div>
</div>
<div v-if="!poll.expired">
<div v-if="!poll.expired" flex gap-x-2>
<button v-if="!poll.voted" whitespace-nowrap flex gap-1 items-center hover:text-primary @click="refresh">
<div text-xs i-ri:information-line />
{{ $t('status.poll.view_results') }}
</button>
<button whitespace-nowrap flex gap-1 items-center hover:text-primary @click="refresh">
<div text-xs :class="loading ? 'animate-spin' : ''" i-ri:loop-right-line />
<div text-xs :class="isLoading ? 'animate-spin' : ''" i-ri:loop-right-line />
{{ $t('status.poll.update') }}
</button>
</div>

View file

@ -643,7 +643,8 @@
"count": "{0} votes|{0} vote|{0} votes",
"ends": "ends {0}",
"finished": "finished {0}",
"update": "Update poll"
"update": "Update poll",
"view_results": "View results"
},
"replying_to": "Replying to {0}",
"show_full_thread": "Show Full thread",