From dd58a4aa92edcad34605173f7852cd34f9599238 Mon Sep 17 00:00:00 2001 From: Marie Date: Sun, 13 Oct 2024 03:44:07 +0200 Subject: upd: add ability to refresh poll --- packages/frontend/src/components/MkPoll.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/frontend') 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 @@ -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 ); +};