Skip to content

Commit 27d2855

Browse files
MOBILE-4802 my: Load myoverview block when dynamic component is ready
1 parent d7851dd commit 27d2855

File tree

1 file changed

+11
-4
lines changed
  • src/core/features/courses/pages/my

1 file changed

+11
-4
lines changed

src/core/features/courses/pages/my/my.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
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';
1717
import { AsyncDirective } from '@classes/async-directive';
1818
import { PageLoadsManager } from '@classes/page-loads-manager';
1919
import { CorePromisedValue } from '@classes/promised-value';
@@ -58,7 +58,7 @@ import { CoreCoursesMyPageName } from '@features/courses/constants';
5858
})
5959
export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective {
6060

61-
@ViewChild(CoreBlockComponent) block!: CoreBlockComponent;
61+
block = viewChild(CoreBlockComponent);
6262

6363
downloadCoursesEnabled = false;
6464
userId: number;
@@ -87,6 +87,15 @@ export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirect
8787
this.loadContent();
8888
});
8989

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+
9099
this.logView = CoreTime.once(async () => {
91100
await CorePromiseUtils.ignoreErrors(CoreCourses.logView('my'));
92101

@@ -138,8 +147,6 @@ export default class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirect
138147

139148
await CoreWait.nextTicks(2);
140149

141-
this.myOverviewBlock = this.block?.dynamicComponent?.instance as AddonBlockMyOverviewComponent;
142-
143150
if (!this.loadedBlock && !supportsMyParam) {
144151
// In old sites, display the block even if not found in Dashboard.
145152
// This is because the "My courses" page doesn't exist in the site so it can't be configured.

0 commit comments

Comments
 (0)