From bc7704a1af576e7a1145d9e8f94599ead3a0e57e Mon Sep 17 00:00:00 2001 From: Alfonso Salces Date: Tue, 31 May 2022 15:08:12 +0200 Subject: [PATCH] MOBILE-4085 course-format: Improve performance with OnPush --- .../course/components/course-format/course-format.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/features/course/components/course-format/course-format.ts b/src/core/features/course/components/course-format/course-format.ts index 38047778b..cd69f025d 100644 --- a/src/core/features/course/components/course-format/course-format.ts +++ b/src/core/features/course/components/course-format/course-format.ts @@ -23,6 +23,8 @@ import { QueryList, Type, ElementRef, + ChangeDetectionStrategy, + ChangeDetectorRef, } from '@angular/core'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; @@ -64,6 +66,7 @@ import { CoreUserTourDirectiveOptions } from '@directives/user-tour'; selector: 'core-course-format', templateUrl: 'course-format.html', styleUrls: ['course-format.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { @@ -120,6 +123,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { constructor( protected content: IonContent, protected elementRef: ElementRef, + protected changeDetectorRef: ChangeDetectorRef, ) { // Pass this instance to all components so they can use its methods and properties. this.data.coreCourseFormatComponent = this; @@ -173,6 +177,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { } } } + this.changeDetectorRef.markForCheck(); }); } @@ -195,6 +200,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { if (changes.sections && this.sections) { this.treatSections(this.sections); } + this.changeDetectorRef.markForCheck(); } /** @@ -229,6 +235,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { this.loadSingleSectionComponent(), this.loadAllSectionsComponent(), ]); + this.changeDetectorRef.markForCheck(); } /** @@ -523,6 +530,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { CoreCourse.logView(this.course.id, newSection.section, undefined, this.course.fullname), ); } + this.changeDetectorRef.markForCheck(); } /**