|
13 | 13 | // limitations under the License. |
14 | 14 |
|
15 | 15 | import { AddonBlockMyOverviewComponent } from '@addons/block/myoverview/components/myoverview/myoverview'; |
16 | | -import { Component, OnDestroy, OnInit, ViewChild, inject } from '@angular/core'; |
| 16 | +import { Component, effect, OnDestroy, OnInit, viewChild, inject } from '@angular/core'; |
17 | 17 | import { AsyncDirective } from '@classes/async-directive'; |
18 | 18 | import { PageLoadsManager } from '@classes/page-loads-manager'; |
19 | 19 | import { CorePromisedValue } from '@classes/promised-value'; |
@@ -58,7 +58,7 @@ import { CoreCoursesMyPageName } from '@features/courses/constants'; |
58 | 58 | }) |
59 | 59 | export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { |
60 | 60 |
|
61 | | - @ViewChild(CoreBlockComponent) block!: CoreBlockComponent; |
| 61 | + block = viewChild(CoreBlockComponent); |
62 | 62 |
|
63 | 63 | downloadCoursesEnabled = false; |
64 | 64 | userId: number; |
@@ -87,6 +87,15 @@ export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirect |
87 | 87 | this.loadContent(); |
88 | 88 | }); |
89 | 89 |
|
| 90 | + effect(async () => { |
| 91 | + const dynamicComponent = this.block()?.dynamicComponent(); |
| 92 | + |
| 93 | + if (dynamicComponent) { |
| 94 | + await dynamicComponent.ready(); |
| 95 | + this.myOverviewBlock = dynamicComponent.instance; |
| 96 | + } |
| 97 | + }); |
| 98 | + |
90 | 99 | this.logView = CoreTime.once(async () => { |
91 | 100 | await CorePromiseUtils.ignoreErrors(CoreCourses.logView('my')); |
92 | 101 |
|
@@ -138,8 +147,6 @@ export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirect |
138 | 147 |
|
139 | 148 | await CoreWait.nextTicks(2); |
140 | 149 |
|
141 | | - this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent; |
142 | | - |
143 | 150 | if (!this.loadedBlock && !supportsMyParam) { |
144 | 151 | // In old sites, display the block even if not found in Dashboard. |
145 | 152 | // This is because the "My courses" page doesn't exist in the site so it can't be configured. |
|
0 commit comments