From 19e077466a892a01663fc8f396ff077061642a37 Mon Sep 17 00:00:00 2001
From: Mar0xy
Date: Wed, 4 Oct 2023 02:24:00 +0200
Subject: [PATCH] upd: add refresh button to polls
Closes transfem-org/Sharkey#42
---
packages/frontend/src/components/MkPoll.vue | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/packages/frontend/src/components/MkPoll.vue b/packages/frontend/src/components/MkPoll.vue
index 9230104a3a..5289e6bb71 100644
--- a/packages/frontend/src/components/MkPoll.vue
+++ b/packages/frontend/src/components/MkPoll.vue
@@ -21,6 +21,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ showResult ? i18n.ts._poll.vote : i18n.ts._poll.showResult }}
{{ i18n.ts._poll.voted }}
{{ i18n.ts._poll.closed }}
+ · {{ i18n.ts.reload }}
· {{ timer }}
@@ -44,6 +45,7 @@ const remaining = ref(-1);
const total = computed(() => sum(props.note.poll.choices.map(x => x.votes)));
const closed = computed(() => remaining.value === 0);
+const isLocal = computed(() => !props.note.uri);
const isVoted = computed(() => !props.note.poll.multiple && props.note.poll.choices.some(c => c.isVoted));
const timer = computed(() => i18n.t(
remaining.value >= 86400 ? '_poll.remainingDays' :
@@ -89,6 +91,14 @@ const vote = async (id) => {
});
if (!showResult.value) showResult.value = !props.note.poll.multiple;
};
+
+async function refresh() {
+ if (!props.note.uri) return;
+ const obj = await os.apiWithDialog("ap/show", { uri: props.note.uri });
+ if (obj.type === "Note" && obj.object.poll) {
+ props.note.poll = obj.object.poll;
+ }
+};