From 1af1e58416aae690320347acb30212e195651b29 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Thu, 27 Jun 2024 09:02:09 +0200 Subject: [PATCH] Fix vote components using wrong change detection strategy --- .../base-poll-vote.component.html | 2 +- .../base-poll-vote/base-poll-vote.component.ts | 17 +++++------------ .../assignment-poll-vote.component.ts | 5 +++-- .../motion-poll-vote.component.ts | 5 +++-- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.html b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.html index 02554c600f..20bcb802ef 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.html +++ b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.html @@ -63,7 +63,7 @@

}" >
- + {{ poll.option_ids.length }} {{ optionPluralLabel | translate }} e this._canVoteForSubjectMap[+key].next(this.canVote(this._delegationsMap[+key])); } - this.cd.markForCheck(); this._isReady = true; + this.cd.markForCheck(); } }), this.translate.onLangChange.subscribe(() => { @@ -423,19 +423,10 @@ export abstract class BasePollVoteComponent e } } - private createVotingDataObjects(): void { - this.voteRequestData[this.user.id] = { value: {} } as VotingData; - this.alreadyVoted[this.user.id] = this.poll.hasVoted; - this.deliveringVote[this.user.id] = false; - - if (this.delegations) { - this.setupDelegations(); - } - } - protected updatePoll(): void { this.setupHasVotedSubscription(); this.defineVoteOptions(); + this.cd.markForCheck(); } private setupHasVotedSubscription(): void { @@ -451,6 +442,8 @@ export abstract class BasePollVoteComponent e for (const key of Object.keys(this._canVoteForSubjectMap)) { this._canVoteForSubjectMap[+key].next(this.canVote(this._delegationsMap[+key])); } + + this.cd.markForCheck(); }) ); } @@ -486,7 +479,7 @@ export abstract class BasePollVoteComponent e }; for (const option of this.voteOptions) { - if (this.poll.pollmethod.includes(option.vote)) { + if (this.poll.pollmethod?.includes(option.vote)) { this.voteActions.push(option); } diff --git a/client/src/app/site/pages/meetings/pages/assignments/modules/assignment-poll/components/assignment-poll-vote/assignment-poll-vote.component.ts b/client/src/app/site/pages/meetings/pages/assignments/modules/assignment-poll/components/assignment-poll-vote/assignment-poll-vote.component.ts index 11f98d923b..8becc9fb54 100644 --- a/client/src/app/site/pages/meetings/pages/assignments/modules/assignment-poll/components/assignment-poll-vote/assignment-poll-vote.component.ts +++ b/client/src/app/site/pages/meetings/pages/assignments/modules/assignment-poll/components/assignment-poll-vote/assignment-poll-vote.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; import { PollMethod } from 'src/app/domain/models/poll/poll-constants'; import { VoteValue } from 'src/app/domain/models/poll/vote-constants'; @@ -17,7 +17,8 @@ import { UnknownUserLabel } from '../../services/assignment-poll.service'; @Component({ selector: `os-assignment-poll-vote`, templateUrl: `../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.html`, - styleUrls: [`../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.scss`] + styleUrls: [`../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush }) export class AssignmentPollVoteComponent extends BasePollVoteComponent { public unknownUserLabel = UnknownUserLabel; diff --git a/client/src/app/site/pages/meetings/pages/motions/modules/motion-poll/components/motion-poll-vote/motion-poll-vote.component.ts b/client/src/app/site/pages/meetings/pages/motions/modules/motion-poll/components/motion-poll-vote/motion-poll-vote.component.ts index 24ef8d59dc..2d074ac019 100644 --- a/client/src/app/site/pages/meetings/pages/motions/modules/motion-poll/components/motion-poll-vote/motion-poll-vote.component.ts +++ b/client/src/app/site/pages/meetings/pages/motions/modules/motion-poll/components/motion-poll-vote/motion-poll-vote.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; import { Id } from 'src/app/domain/definitions/key-types'; import { VoteValue } from 'src/app/domain/models/poll/vote-constants'; import { @@ -14,7 +14,8 @@ import { ViewOption } from '../../../../../polls'; @Component({ selector: `os-motion-poll-vote`, templateUrl: `../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.html`, - styleUrls: [`../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.scss`] + styleUrls: [`../../../../../../modules/poll/components/base-poll-vote/base-poll-vote.component.scss`], + changeDetection: ChangeDetectionStrategy.OnPush }) export class MotionPollVoteComponent extends BasePollVoteComponent { public override readonly settings = {