Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions app/components/status/StatusPoll.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
Expand All @@ -55,7 +55,7 @@ async function refresh() {
console.error(e)
}
finally {
loading.value = false
isLoading.value = false
}
}

Expand Down Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down