Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vote components using wrong change detection strategy #3796

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h4 *ngIf="delegation" class="poll-delegation-title">
}"
>
<div *ngIf="showAvailableVotes" class="grid-name-area"></div>
<b *ngIf="!showAvailableVotes" class="grid-name-area">
<b *ngIf="!showAvailableVotes && poll.option_ids" class="grid-name-area">
{{ poll.option_ids.length }} {{ optionPluralLabel | translate }}
</b>
<b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export abstract class BasePollVoteComponent<C extends PollContentObject = any> e
this._canVoteForSubjectMap[+key].next(this.canVote(this._delegationsMap[+key]));
}

this.cd.markForCheck();
this._isReady = true;
this.cd.markForCheck();
}
}),
this.translate.onLangChange.subscribe(() => {
Expand Down Expand Up @@ -423,19 +423,10 @@ export abstract class BasePollVoteComponent<C extends PollContentObject = any> 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 {
Expand All @@ -451,6 +442,8 @@ export abstract class BasePollVoteComponent<C extends PollContentObject = any> e
for (const key of Object.keys(this._canVoteForSubjectMap)) {
this._canVoteForSubjectMap[+key].next(this.canVote(this._delegationsMap[+key]));
}

this.cd.markForCheck();
})
);
}
Expand Down Expand Up @@ -486,7 +479,7 @@ export abstract class BasePollVoteComponent<C extends PollContentObject = any> 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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<ViewAssignment> {
public unknownUserLabel = UnknownUserLabel;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 = {
Expand Down
Loading