Skip to content

Commit 8b6ac7b

Browse files
authored
Merge pull request #4040 from nextcloud/fix/misc
Some minor fixes and tidy
2 parents d3c2776 + 4bd1af7 commit 8b6ac7b

3 files changed

Lines changed: 17 additions & 20 deletions

File tree

lib/Controller/PollController.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public function getFull(int $pollId): JSONResponse {
9898
#[FrontpageRoute(verb: 'POST', url: '/poll/add')]
9999
public function add(string $type, string $title, string $votingVariant = Poll::VARIANT_SIMPLE): JSONResponse {
100100
return $this->response(
101-
fn () => $this->pollService->add($type, $title, $votingVariant),
101+
fn () => [
102+
'poll' => $this->pollService->add($type, $title, $votingVariant)
103+
],
102104
Http::STATUS_CREATED
103105
);
104106
}
@@ -147,7 +149,9 @@ public function sendConfirmation(int $pollId): JSONResponse {
147149
#[NoAdminRequired]
148150
#[FrontpageRoute(verb: 'PUT', url: '/poll/{pollId}/toggleArchive')]
149151
public function toggleArchive(int $pollId): JSONResponse {
150-
return $this->response(fn () => $this->pollService->toggleArchive($pollId));
152+
return $this->response(fn () => [
153+
'poll' => $this->pollService->toggleArchive($pollId)
154+
]);
151155
}
152156

153157
/**
@@ -157,7 +161,9 @@ public function toggleArchive(int $pollId): JSONResponse {
157161
#[NoAdminRequired]
158162
#[FrontpageRoute(verb: 'DELETE', url: '/poll/{pollId}')]
159163
public function delete(int $pollId): JSONResponse {
160-
return $this->response(fn () => ['poll' => $this->pollService->delete($pollId)]);
164+
return $this->response(fn () => [
165+
'poll' => $this->pollService->delete($pollId)
166+
]);
161167
}
162168

163169
/**
@@ -191,7 +197,9 @@ public function reopen(int $pollId): JSONResponse {
191197
#[NoAdminRequired]
192198
#[FrontpageRoute(verb: 'POST', url: '/poll/{pollId}/clone')]
193199
public function clone(int $pollId): JSONResponse {
194-
return $this->response(fn () => ['poll' => $this->clonePoll($pollId)]);
200+
return $this->response(fn () => [
201+
'poll' => $this->clonePoll($pollId)
202+
]);
195203
}
196204

197205
private function clonePoll(int $pollId): Poll {

src/stores/poll.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,10 @@ export const usePollStore = defineStore('poll', {
572572
const pollsStore = usePollsStore()
573573

574574
try {
575-
await PollsAPI.toggleArchive(payload.pollId)
575+
const response = await PollsAPI.toggleArchive(payload.pollId)
576+
if (this.id === payload.pollId) {
577+
this.$patch(response.data.poll)
578+
}
576579
} catch (error) {
577580
if ((error as AxiosError)?.code === 'ERR_CANCELED') {
578581
return

src/views/Reference.vue

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ interface Props {
3232
}
3333
3434
const { richObject } = defineProps<Props>()
35-
// const expiryClass2 = (() => {
36-
// if (!richObject?.poll?.expiry) {
37-
// return ''
38-
// }
39-
// if (DateTime.fromMillis(richObject.poll.expiry * 1000).diffNow('hours').hours < 36) {
40-
// return StatusResults.Warning
41-
// }
42-
// return StatusResults.Success
43-
// })
35+
4436
const expiryClass = richObject?.poll?.expiry
4537
? DateTime.fromMillis(richObject.poll.expiry * 1000).diffNow('hours').hours < 36
4638
? StatusResults.Warning
@@ -80,12 +72,6 @@ const expiryClass = richObject?.poll?.expiry
8072
<NcUserBubble
8173
:user="richObject.poll.ownerId"
8274
:display-name="richObject.poll.ownerDisplayName" />
83-
<span
84-
v-if="richObject.poll.expiry > 0 && !richObject.poll.expired"
85-
class="expiration">
86-
{{ t('polls', 'Ends in') }}
87-
{{ DateTime.fromMillis(richObject.poll.expiry * 1000).toRelative() }}
88-
</span>
8975
</div>
9076
</div>
9177
</template>

0 commit comments

Comments
 (0)