diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php index e2aee15f01..dbc51b3e56 100644 --- a/lib/Db/Poll.php +++ b/lib/Db/Poll.php @@ -241,6 +241,8 @@ public function getStatusArray(): array { 'deletionDate' => $this->getDeletionDate(), 'archivedDate' => $this->getDeleted(), 'countParticipants' => $this->getIsAllowed(self::PERMISSION_POLL_RESULTS_VIEW) ? $this->getParticipantsCount() : 0, + 'maxVotes' => $this->getVoteLimit(), + 'maxOptionVotes' => $this->getOptionLimit(), ]; } public function getConfigurationArray(): array { diff --git a/src/components/SideBar/SideBarTabComments.vue b/src/components/SideBar/SideBarTabComments.vue index 965b20cd77..bc0a64c030 100644 --- a/src/components/SideBar/SideBarTabComments.vue +++ b/src/components/SideBar/SideBarTabComments.vue @@ -16,7 +16,6 @@ import CommentsIcon from 'vue-material-design-icons/CommentProcessing.vue' import { usePollStore } from '../../stores/poll' import { useCommentsStore } from '../../stores/comments' -import { Logger } from '../../helpers' const pollStore = usePollStore() const commentsStore = useCommentsStore() @@ -41,12 +40,8 @@ onBeforeRouteLeave(() => { }) watch( - [() => pollStore.permissions.comment, () => pollStore.configuration.anonymous], - ([commentNew, commentOld], [anonymousNew, anonymousOld]) => { - Logger.debug('Configuration affecting comments changed', { - comment: `${commentOld} → ${commentNew}`, - anonymous: `${anonymousOld} → ${anonymousNew}`, - }) + [() => pollStore.permissions.comment, () => pollStore.permissions.seeUsernames], + () => { commentsStore.load() }, ) diff --git a/src/stores/poll.ts b/src/stores/poll.ts index 8a8b5bdb0a..3bd49b6b71 100644 --- a/src/stores/poll.ts +++ b/src/stores/poll.ts @@ -84,6 +84,8 @@ export const usePollStore = defineStore('poll', { deletionDate: 0, archivedDate: 0, countParticipants: 0, + maxVotes: 0, + maxOptionVotes: 0, }, currentUserStatus: { groupInvitations: [], diff --git a/src/stores/poll.types.ts b/src/stores/poll.types.ts index 94a69258bf..520e6d57f9 100644 --- a/src/stores/poll.types.ts +++ b/src/stores/poll.types.ts @@ -54,6 +54,8 @@ export type PollStatus = { deletionDate: number archivedDate: number countParticipants: number + maxVotes: number + maxOptionVotes: number } export type PollPermissions = { diff --git a/src/views/Vote.vue b/src/views/Vote.vue index 8558e50483..09b56bf73e 100644 --- a/src/views/Vote.vue +++ b/src/views/Vote.vue @@ -40,7 +40,6 @@ import { useSubscriptionStore } from '../stores/subscription' import type { CollapsibleProps } from '../components/Base/modules/Collapsible.vue' import { Event } from '../Types' -import { Logger } from '../helpers' const pollStore = usePollStore() const optionsStore = useOptionsStore() @@ -176,39 +175,26 @@ onUnmounted(() => { watch( [ - () => pollStore.configuration.anonymous, - () => pollStore.configuration.maxVotesPerOption, - () => pollStore.configuration.maxVotesPerUser, - () => pollStore.configuration.hideBookedUp, + () => pollStore.permissions.seeUsernames, + () => pollStore.permissions.seeResults, ], - ( - [anonymousNew, maxVotesPerOptionNew, maxVotesPerUserNew, hideBookedUpNew], - [anonymousOld, maxVotesPerOptionOld, maxVotesPerUserOld, hideBookedUpOld], - ) => { - Logger.debug('Configuration affecting options changed', { - anonymous: `${anonymousNew} → ${anonymousOld}`, - maxVotesPerOptionNew: `${maxVotesPerOptionNew} → ${maxVotesPerOptionOld}`, - maxVotesPerUserNew: `${maxVotesPerUserNew} → ${maxVotesPerUserOld}`, - hideBookedUpNew: `${hideBookedUpNew} → ${hideBookedUpOld}`, - }) - optionsStore.load() + ([seeUsernamesNew, seeResultsNew], [seeUsernamesOld, seeResultsOld]) => { + if (seeResultsNew !== seeResultsOld || seeUsernamesNew !== seeUsernamesOld) { + optionsStore.load() + votesStore.load() + } }, ) watch( - [ - () => pollStore.configuration.anonymous, - () => pollStore.configuration.showResults, - ], - ([anonymousNew, showResultsNew], [anonymousOld, showResultsOld]) => { - Logger.debug('Configuration affecting votes changed', { - anonymous: `${anonymousOld} → ${anonymousNew}`, - showResults: `${showResultsOld} → ${showResultsNew}`, - }) - emit(Event.TransitionsOff, 500) - votesStore.load() + [() => pollStore.status.maxOptionVotes, () => pollStore.status.maxVotes], + ([maxOptionVotesNew, maxVotesNew], [maxOptionVotesOld, maxVotesOld]) => { + if (maxOptionVotesNew !== maxOptionVotesOld || maxVotesNew !== maxVotesOld) { + optionsStore.load() + } }, ) + const appClass = computed(() => [ pollStore.type, pollStore.viewMode,