Skip to content

Commit

Permalink
Made motion title update (#2301)
Browse files Browse the repository at this point in the history
  • Loading branch information
luisa-beerboom authored May 22, 2023
1 parent 5bc6b29 commit 78cf482
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewEncapsulation } from '@angular/core';
import { distinctUntilChanged, map } from 'rxjs';
import { ProjectorControllerService } from 'src/app/site/pages/meetings/pages/projectors/services/projector-controller.service';
import { BaseProjectableViewModel } from 'src/app/site/pages/meetings/view-models';
Expand All @@ -25,7 +25,7 @@ export class ProjectableTitleComponent {
map(_ => this.isBeingProjected())
);

constructor(private projectorService: ProjectorControllerService) {}
constructor(private projectorService: ProjectorControllerService, private cd: ChangeDetectorRef) {}

public isBeingProjected(): boolean {
if (!this.model) {
Expand All @@ -34,4 +34,8 @@ export class ProjectableTitleComponent {

return this.projectorService.isProjected(this.model);
}

public update(): void {
this.cd.markForCheck();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Subscription } from 'rxjs';
import { distinctUntilChanged, Subscription } from 'rxjs';
import { ChangeRecoMode } from 'src/app/domain/models/motions/motions.constants';
import { PersonalNote } from 'src/app/domain/models/motions/personal-note';
import { ProjectableTitleComponent } from 'src/app/site/pages/meetings/modules/meetings-component-collector/detail-view/components/projectable-title/projectable-title.component';
import { ViewMotion, ViewMotionChangeRecommendation } from 'src/app/site/pages/meetings/pages/motions';
import { MeetingComponentServiceCollectorService } from 'src/app/site/pages/meetings/services/meeting-component-service-collector.service';

Expand All @@ -17,6 +18,9 @@ import { MotionDetailServiceCollectorService } from '../../services/motion-detai
styleUrls: [`./motion-manage-title.component.scss`]
})
export class MotionManageTitleComponent extends BaseMotionDetailChildComponent {
@ViewChild(ProjectableTitleComponent)
protected readonly titleComponent: ProjectableTitleComponent | undefined;

public titleChangeRecommendation: ViewMotionChangeRecommendation | null = null;

public override get parent(): ViewMotion | null {
Expand Down Expand Up @@ -80,7 +84,12 @@ export class MotionManageTitleComponent extends BaseMotionDetailChildComponent {
return [
this.changeRecoRepo
.getTitleChangeRecoOfMotionObservable(this.motion?.id)
?.subscribe(changeReco => (this.titleChangeRecommendation = changeReco))
?.subscribe(changeReco => (this.titleChangeRecommendation = changeReco)),
this.viewService.changeRecommendationModeSubject.pipe(distinctUntilChanged()).subscribe(reco => {
if (this.titleComponent) {
this.titleComponent.update();
}
})
];
}
}

0 comments on commit 78cf482

Please sign in to comment.