summaryrefslogtreecommitdiff
path: root/packages/frontend
diff options
context:
space:
mode:
authorMarie <github@yuugi.dev>2024-10-13 03:44:07 +0200
committerHazelnoot <acomputerdog@gmail.com>2024-10-15 18:21:08 -0400
commitdd58a4aa92edcad34605173f7852cd34f9599238 (patch)
tree7b128f4b2e6addb25d471f35b18118317047faad /packages/frontend
parentmerge: Refresh locales after any change, not just a version update (resolves ... (diff)
downloadsharkey-dd58a4aa92edcad34605173f7852cd34f9599238.tar.gz
sharkey-dd58a4aa92edcad34605173f7852cd34f9599238.tar.bz2
sharkey-dd58a4aa92edcad34605173f7852cd34f9599238.zip
upd: add ability to refresh poll
Diffstat (limited to 'packages/frontend')
-rw-r--r--packages/frontend/src/components/MkPoll.vue15
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/frontend/src/components/MkPoll.vue b/packages/frontend/src/components/MkPoll.vue
index 393ac4efba..d594348bfa 100644
--- a/packages/frontend/src/components/MkPoll.vue
+++ b/packages/frontend/src/components/MkPoll.vue
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div :class="{ [$style.done]: closed || isVoted }">
<ul :class="$style.choices">
- <li v-for="(choice, i) in poll.choices" :key="i" :class="$style.choice" @click="vote(i)">
+ <li v-for="(choice, i) in props.poll.choices" :key="i" :class="$style.choice" @click="vote(i)">
<div :class="$style.bg" :style="{ 'width': `${showResult ? (choice.votes / total * 100) : 0}%` }"></div>
<span :class="$style.fg">
<template v-if="choice.isVoted"><i class="ti ti-check" style="margin-right: 4px; color: var(--accent);"></i></template>
@@ -24,6 +24,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<span v-if="isVoted">{{ i18n.ts._poll.voted }}</span>
<span v-else-if="closed">{{ i18n.ts._poll.closed }}</span>
<span v-if="remaining > 0"> · {{ timer }}</span>
+ <span v-if="!closed"> · </span>
+ <a v-if="!closed" style="color: inherit;" @click="refreshVotes()">Refresh</a>
</p>
</div>
</template>
@@ -108,6 +110,17 @@ const vote = async (id) => {
});
if (!showResult.value) showResult.value = !props.poll.multiple;
};
+
+const refreshVotes = async () => {
+ pleaseLogin(undefined, pleaseLoginContext.value);
+
+ if (props.readOnly || closed.value) return;
+ await misskeyApi('notes/polls/refresh', {
+ noteId: props.noteId,
+ // Sadly due to being in the same component and the poll being a prop we require to break Vue's recommendation of not mutating the prop to update it.
+ // eslint-disable-next-line vue/no-mutating-props
+ }).then((res: any) => res.poll ? props.poll.choices = res.poll.choices : null );
+};
</script>
<style lang="scss" module>