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