MOBILE-3833 addons: Improve manager initialization
parent
848b5e79b5
commit
ec9ca06654
|
@ -43,29 +43,30 @@ export class AddonBadgesIssuedBadgePage implements OnInit {
|
||||||
user?: CoreUserProfile;
|
user?: CoreUserProfile;
|
||||||
course?: CoreEnrolledCourseData;
|
course?: CoreEnrolledCourseData;
|
||||||
badge?: AddonBadgesUserBadge;
|
badge?: AddonBadgesUserBadge;
|
||||||
badges?: CoreSwipeNavigationItemsManager;
|
badges: CoreSwipeNavigationItemsManager;
|
||||||
badgeLoaded = false;
|
badgeLoaded = false;
|
||||||
currentTime = 0;
|
currentTime = 0;
|
||||||
|
|
||||||
constructor(protected route: ActivatedRoute) { }
|
constructor(protected route: ActivatedRoute) {
|
||||||
|
|
||||||
/**
|
|
||||||
* View loaded.
|
|
||||||
*/
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.courseId = CoreNavigator.getRouteNumberParam('courseId') || this.courseId; // Use 0 for site badges.
|
this.courseId = CoreNavigator.getRouteNumberParam('courseId') || this.courseId; // Use 0 for site badges.
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getRequiredCurrentSite().getUserId();
|
this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getRequiredCurrentSite().getUserId();
|
||||||
this.badgeHash = CoreNavigator.getRouteParam('badgeHash') || '';
|
this.badgeHash = CoreNavigator.getRouteParam('badgeHash') || '';
|
||||||
|
|
||||||
this.fetchIssuedBadge().finally(() => {
|
|
||||||
this.badgeLoaded = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
||||||
AddonBadgesUserBadgesSource,
|
AddonBadgesUserBadgesSource,
|
||||||
[this.courseId, this.userId],
|
[this.courseId, this.userId],
|
||||||
);
|
);
|
||||||
|
|
||||||
this.badges = new CoreSwipeNavigationItemsManager(source);
|
this.badges = new CoreSwipeNavigationItemsManager(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View loaded.
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.fetchIssuedBadge().finally(() => {
|
||||||
|
this.badgeLoaded = true;
|
||||||
|
});
|
||||||
|
|
||||||
this.badges.start();
|
this.badges.start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,23 +38,19 @@ import { AddonModFeedbackFormItem, AddonModFeedbackHelper } from '../../services
|
||||||
})
|
})
|
||||||
export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
protected attemptId!: number;
|
cmId: number;
|
||||||
|
courseId: number;
|
||||||
cmId!: number;
|
|
||||||
courseId!: number;
|
|
||||||
feedback?: AddonModFeedbackWSFeedback;
|
feedback?: AddonModFeedbackWSFeedback;
|
||||||
attempt?: AddonModFeedbackWSAttempt;
|
attempt?: AddonModFeedbackWSAttempt;
|
||||||
attempts?: AddonModFeedbackAttemptsSwipeManager;
|
attempts: AddonModFeedbackAttemptsSwipeManager;
|
||||||
anonAttempt?: AddonModFeedbackWSAnonAttempt;
|
anonAttempt?: AddonModFeedbackWSAnonAttempt;
|
||||||
items: AddonModFeedbackAttemptItem[] = [];
|
items: AddonModFeedbackAttemptItem[] = [];
|
||||||
component = AddonModFeedbackProvider.COMPONENT;
|
component = AddonModFeedbackProvider.COMPONENT;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
|
||||||
/**
|
protected attemptId: number;
|
||||||
* @inheritdoc
|
|
||||||
*/
|
constructor() {
|
||||||
ngOnInit(): void {
|
|
||||||
try {
|
|
||||||
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId');
|
||||||
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId');
|
||||||
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId');
|
||||||
|
@ -65,7 +61,13 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.attempts = new AddonModFeedbackAttemptsSwipeManager(source);
|
this.attempts = new AddonModFeedbackAttemptsSwipeManager(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
try {
|
||||||
this.attempts.start();
|
this.attempts.start();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModal(error);
|
CoreDomUtils.showErrorModal(error);
|
||||||
|
@ -82,7 +84,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy {
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.attempts?.destroy();
|
this.attempts.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue