From bc6bff07857a3031cad3e9e93f65caa8302beae3 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sat, 24 May 2025 10:25:40 +0200 Subject: [PATCH 1/3] fix controller responses Signed-off-by: dartcafe --- lib/Controller/PollController.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index ab99af8fab..766bb0eab9 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -98,7 +98,9 @@ public function getFull(int $pollId): JSONResponse { #[FrontpageRoute(verb: 'POST', url: '/poll/add')] public function add(string $type, string $title, string $votingVariant = Poll::VARIANT_SIMPLE): JSONResponse { return $this->response( - fn () => $this->pollService->add($type, $title, $votingVariant), + fn () => [ + 'poll' => $this->pollService->add($type, $title, $votingVariant) + ], Http::STATUS_CREATED ); } @@ -147,7 +149,9 @@ public function sendConfirmation(int $pollId): JSONResponse { #[NoAdminRequired] #[FrontpageRoute(verb: 'PUT', url: '/poll/{pollId}/toggleArchive')] public function toggleArchive(int $pollId): JSONResponse { - return $this->response(fn () => $this->pollService->toggleArchive($pollId)); + return $this->response(fn () => [ + 'poll' => $this->pollService->toggleArchive($pollId) + ]); } /** @@ -157,7 +161,9 @@ public function toggleArchive(int $pollId): JSONResponse { #[NoAdminRequired] #[FrontpageRoute(verb: 'DELETE', url: '/poll/{pollId}')] public function delete(int $pollId): JSONResponse { - return $this->response(fn () => ['poll' => $this->pollService->delete($pollId)]); + return $this->response(fn () => [ + 'poll' => $this->pollService->delete($pollId) + ]); } /** @@ -191,7 +197,9 @@ public function reopen(int $pollId): JSONResponse { #[NoAdminRequired] #[FrontpageRoute(verb: 'POST', url: '/poll/{pollId}/clone')] public function clone(int $pollId): JSONResponse { - return $this->response(fn () => ['poll' => $this->clonePoll($pollId)]); + return $this->response(fn () => [ + 'poll' => $this->clonePoll($pollId) + ]); } private function clonePoll(int $pollId): Poll { From 4a6e9f5e2d65a73307814e2f0d3e70798c10464e Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sat, 24 May 2025 10:25:58 +0200 Subject: [PATCH 2/3] fix archived state Signed-off-by: dartcafe --- src/stores/poll.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/stores/poll.ts b/src/stores/poll.ts index 4137f6b926..fe93c601cc 100644 --- a/src/stores/poll.ts +++ b/src/stores/poll.ts @@ -572,7 +572,10 @@ export const usePollStore = defineStore('poll', { const pollsStore = usePollsStore() try { - await PollsAPI.toggleArchive(payload.pollId) + const response = await PollsAPI.toggleArchive(payload.pollId) + if (this.id === payload.pollId) { + this.$patch(response.data.poll) + } } catch (error) { if ((error as AxiosError)?.code === 'ERR_CANCELED') { return From 4bd1af7a33d0a890f57c2587ca0908038dfb91d7 Mon Sep 17 00:00:00 2001 From: dartcafe Date: Sat, 24 May 2025 10:29:20 +0200 Subject: [PATCH 3/3] tidy Reference Signed-off-by: dartcafe --- src/views/Reference.vue | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/views/Reference.vue b/src/views/Reference.vue index 78ee130fc4..887dc155a3 100644 --- a/src/views/Reference.vue +++ b/src/views/Reference.vue @@ -32,15 +32,7 @@ interface Props { } const { richObject } = defineProps() -// const expiryClass2 = (() => { -// if (!richObject?.poll?.expiry) { -// return '' -// } -// if (DateTime.fromMillis(richObject.poll.expiry * 1000).diffNow('hours').hours < 36) { -// return StatusResults.Warning -// } -// return StatusResults.Success -// }) + const expiryClass = richObject?.poll?.expiry ? DateTime.fromMillis(richObject.poll.expiry * 1000).diffNow('hours').hours < 36 ? StatusResults.Warning @@ -80,12 +72,6 @@ const expiryClass = richObject?.poll?.expiry - - {{ t('polls', 'Ends in') }} - {{ DateTime.fromMillis(richObject.poll.expiry * 1000).toRelative() }} -