diff --git a/components/status/StatusPoll.vue b/components/status/StatusPoll.vue index d8bcbbf7..b39b5351 100644 --- a/components/status/StatusPoll.vue +++ b/components/status/StatusPoll.vue @@ -14,6 +14,7 @@ const timeAgoOptions = useTimeAgoOptions() const expiredTimeAgo = useTimeAgo(poll.expiresAt!, timeAgoOptions) const expiredTimeFormatted = useFormattedDateTime(poll.expiresAt!) const { formatPercentage } = useHumanReadableNumber() +const loading = ref(false) const { client } = useMasto() @@ -39,6 +40,25 @@ async function vote(e: Event) { await client.value.v1.polls.$select(poll.id).votes.create({ choices }) } +async function refresh() { + if (loading.value) { + return + } + + loading.value = true + try { + const newPoll = await client.value.v1.polls.$select(poll.id).fetch() + Object.assign(poll, newPoll) + cacheStatus({ ...status, poll: newPoll }, undefined, true) + } + catch (e) { + console.error(e) + } + finally { + loading.value = false + } +} + const votersCount = computed(() => poll.votersCount ?? poll.votesCount ?? 0) @@ -71,15 +91,27 @@ const votersCount = computed(() => poll.votersCount ?? poll.votesCount ?? 0) -
- - · - - - +
+
+
+ +
+ · +
+ + + +
+
+
+ +
diff --git a/locales/en.json b/locales/en.json index eb1a3443..b7ac956e 100644 --- a/locales/en.json +++ b/locales/en.json @@ -639,7 +639,8 @@ "poll": { "count": "{0} votes|{0} vote|{0} votes", "ends": "ends {0}", - "finished": "finished {0}" + "finished": "finished {0}", + "update": "Update poll" }, "replying_to": "Replying to {0}", "show_full_thread": "Show Full thread", diff --git a/locales/fr-FR.json b/locales/fr-FR.json index d1d974f2..d54598ba 100644 --- a/locales/fr-FR.json +++ b/locales/fr-FR.json @@ -585,7 +585,8 @@ "poll": { "count": "{0} votes", "ends": "se clôt {0}", - "finished": "clos {0}" + "finished": "clos {0}", + "update": "Mettre à jour les résultats" }, "replying_to": "Répondre à {0}", "show_full_thread": "Voir le fil de discussion complet",