MOBILE-4034 core: Remove some listeners from app component
parent
6a12da2bf1
commit
55d5f9419b
|
@ -34,7 +34,6 @@ import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { CoreDom } from '@singletons/dom';
|
import { CoreDom } from '@singletons/dom';
|
||||||
import { CorePlatform } from '@services/platform';
|
import { CorePlatform } from '@services/platform';
|
||||||
import { CoreUserHelper } from '@features/user/services/user-helper';
|
|
||||||
|
|
||||||
const MOODLE_VERSION_PREFIX = 'version-';
|
const MOODLE_VERSION_PREFIX = 'version-';
|
||||||
const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
|
const MOODLEAPP_VERSION_PREFIX = 'moodleapp-';
|
||||||
|
@ -53,13 +52,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component being initialized.
|
* Component being initialized.
|
||||||
*
|
|
||||||
* @todo Review all old code to see if something is missing:
|
|
||||||
* - IAB events listening.
|
|
||||||
* - Platform pause/resume subscriptions.
|
|
||||||
* - handleOpenURL and openWindowSafely.
|
|
||||||
* - Back button registering to close modal first.
|
|
||||||
* - Note: HideKeyboardFormAccessoryBar has been moved to config.xml.
|
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
@ -101,24 +93,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
content.classList.toggle('core-footer-shadow', !CoreDom.scrollIsBottom(scrollElement));
|
content.classList.toggle('core-footer-shadow', !CoreDom.scrollIsBottom(scrollElement));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen for session expired events.
|
|
||||||
CoreEvents.on(CoreEvents.SESSION_EXPIRED, (data) => {
|
|
||||||
CoreLoginHelper.sessionExpired(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Listen for passwordchange and usernotfullysetup events to open InAppBrowser.
|
|
||||||
CoreEvents.on(CoreEvents.PASSWORD_CHANGE_FORCED, (data) => {
|
|
||||||
CoreLoginHelper.passwordChangeForced(data.siteId!);
|
|
||||||
});
|
|
||||||
CoreEvents.on(CoreEvents.USER_NOT_FULLY_SETUP, (data) => {
|
|
||||||
CoreUserHelper.openCompleteProfile(data.siteId!);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Listen for sitepolicynotagreed event to accept the site policy.
|
|
||||||
CoreEvents.on(CoreEvents.SITE_POLICY_NOT_AGREED, (data) => {
|
|
||||||
CoreLoginHelper.sitePolicyNotAgreed(data.siteId);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check URLs loaded in any InAppBrowser.
|
// Check URLs loaded in any InAppBrowser.
|
||||||
CoreEvents.on(CoreEvents.IAB_LOAD_START, (event) => {
|
CoreEvents.on(CoreEvents.IAB_LOAD_START, (event) => {
|
||||||
// URLs with a custom scheme can be prefixed with "http://" or "https://", we need to remove this.
|
// URLs with a custom scheme can be prefixed with "http://" or "https://", we need to remove this.
|
||||||
|
@ -280,6 +254,9 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
CoreApp.closeApp();
|
CoreApp.closeApp();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @todo: Pause Youtube videos in Android when app is put in background or screen is locked?
|
||||||
|
// See: https://github.com/moodlehq/moodleapp/blob/ionic3/src/app/app.component.ts#L312
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,10 +16,11 @@ import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
|
|
||||||
import { AppRoutingModule } from '@/app/app-routing.module';
|
import { AppRoutingModule } from '@/app/app-routing.module';
|
||||||
import { CoreLoginHelperProvider } from './services/login-helper';
|
import { CoreLoginHelper, CoreLoginHelperProvider } from './services/login-helper';
|
||||||
import { CoreRedirectGuard } from '@guards/redirect';
|
import { CoreRedirectGuard } from '@guards/redirect';
|
||||||
import { CoreLoginCronHandler } from './services/handlers/cron';
|
import { CoreLoginCronHandler } from './services/handlers/cron';
|
||||||
import { CoreCronDelegate } from '@services/cron';
|
import { CoreCronDelegate } from '@services/cron';
|
||||||
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
|
||||||
export const CORE_LOGIN_SERVICES = [
|
export const CORE_LOGIN_SERVICES = [
|
||||||
CoreLoginHelperProvider,
|
CoreLoginHelperProvider,
|
||||||
|
@ -44,6 +45,18 @@ const appRoutes: Routes = [
|
||||||
multi: true,
|
multi: true,
|
||||||
useValue: () => {
|
useValue: () => {
|
||||||
CoreCronDelegate.register(CoreLoginCronHandler.instance);
|
CoreCronDelegate.register(CoreLoginCronHandler.instance);
|
||||||
|
|
||||||
|
CoreEvents.on(CoreEvents.SESSION_EXPIRED, (data) => {
|
||||||
|
CoreLoginHelper.sessionExpired(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
CoreEvents.on(CoreEvents.PASSWORD_CHANGE_FORCED, (data) => {
|
||||||
|
CoreLoginHelper.passwordChangeForced(data.siteId);
|
||||||
|
});
|
||||||
|
|
||||||
|
CoreEvents.on(CoreEvents.SITE_POLICY_NOT_AGREED, (data) => {
|
||||||
|
CoreLoginHelper.sitePolicyNotAgreed(data.siteId);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -784,10 +784,12 @@ export class CoreLoginHelperProvider {
|
||||||
/**
|
/**
|
||||||
* Function that should be called when password change is forced. Reserved for core use.
|
* Function that should be called when password change is forced. Reserved for core use.
|
||||||
*
|
*
|
||||||
* @param siteId The site ID.
|
* @param siteId The site ID. Undefined for current site.
|
||||||
*/
|
*/
|
||||||
async passwordChangeForced(siteId: string): Promise<void> {
|
async passwordChangeForced(siteId?: string): Promise<void> {
|
||||||
const currentSite = CoreSites.getCurrentSite();
|
const currentSite = CoreSites.getCurrentSite();
|
||||||
|
siteId = siteId ?? currentSite?.getId();
|
||||||
|
|
||||||
if (!currentSite || siteId !== currentSite.getId()) {
|
if (!currentSite || siteId !== currentSite.getId()) {
|
||||||
return; // Site that triggered the event is not current site.
|
return; // Site that triggered the event is not current site.
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,10 +65,12 @@ export class CoreUserHelperProvider {
|
||||||
/**
|
/**
|
||||||
* Open a page with instructions on how to complete profile.
|
* Open a page with instructions on how to complete profile.
|
||||||
*
|
*
|
||||||
* @param siteId The site ID.
|
* @param siteId The site ID. Undefined for current site.
|
||||||
*/
|
*/
|
||||||
async openCompleteProfile(siteId: string): Promise<void> {
|
async openCompleteProfile(siteId?: string): Promise<void> {
|
||||||
const currentSite = CoreSites.getCurrentSite();
|
const currentSite = CoreSites.getCurrentSite();
|
||||||
|
siteId = siteId ?? currentSite?.getId();
|
||||||
|
|
||||||
if (!currentSite || siteId !== currentSite.getId()) {
|
if (!currentSite || siteId !== currentSite.getId()) {
|
||||||
return; // Site that triggered the event is not current site.
|
return; // Site that triggered the event is not current site.
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,14 @@ import { CoreCourseOptionsDelegate } from '@features/course/services/course-opti
|
||||||
import { CoreUserCourseOptionHandler } from './services/handlers/course-option';
|
import { CoreUserCourseOptionHandler } from './services/handlers/course-option';
|
||||||
import { CoreUserProfileFieldDelegateService } from './services/user-profile-field-delegate';
|
import { CoreUserProfileFieldDelegateService } from './services/user-profile-field-delegate';
|
||||||
import { CoreUserProvider } from './services/user';
|
import { CoreUserProvider } from './services/user';
|
||||||
import { CoreUserHelperProvider } from './services/user-helper';
|
import { CoreUserHelper, CoreUserHelperProvider } from './services/user-helper';
|
||||||
import { CoreUserOfflineProvider } from './services/user-offline';
|
import { CoreUserOfflineProvider } from './services/user-offline';
|
||||||
import { CoreUserSyncProvider } from './services/user-sync';
|
import { CoreUserSyncProvider } from './services/user-sync';
|
||||||
import { AppRoutingModule, conditionalRoutes } from '@/app/app-routing.module';
|
import { AppRoutingModule, conditionalRoutes } from '@/app/app-routing.module';
|
||||||
import { CoreScreen } from '@services/screen';
|
import { CoreScreen } from '@services/screen';
|
||||||
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
import { COURSE_PAGE_NAME } from '@features/course/course.module';
|
||||||
import { COURSE_INDEX_PATH } from '@features/course/course-lazy.module';
|
import { COURSE_INDEX_PATH } from '@features/course/course-lazy.module';
|
||||||
|
import { CoreEvents } from '@singletons/events';
|
||||||
|
|
||||||
export const CORE_USER_SERVICES: Type<unknown>[] = [
|
export const CORE_USER_SERVICES: Type<unknown>[] = [
|
||||||
CoreUserDelegateService,
|
CoreUserDelegateService,
|
||||||
|
@ -106,6 +107,10 @@ const courseIndexRoutes: Routes = [
|
||||||
CoreCronDelegate.register(CoreUserSyncCronHandler.instance);
|
CoreCronDelegate.register(CoreUserSyncCronHandler.instance);
|
||||||
CoreTagAreaDelegate.registerHandler(CoreUserTagAreaHandler.instance);
|
CoreTagAreaDelegate.registerHandler(CoreUserTagAreaHandler.instance);
|
||||||
CoreCourseOptionsDelegate.registerHandler(CoreUserCourseOptionHandler.instance);
|
CoreCourseOptionsDelegate.registerHandler(CoreUserCourseOptionHandler.instance);
|
||||||
|
|
||||||
|
CoreEvents.on(CoreEvents.USER_NOT_FULLY_SETUP, (data) => {
|
||||||
|
CoreUserHelper.openCompleteProfile(data.siteId);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue