MOBILE-3592 user: Make delegate and handlers singleton
parent
fd19dd8c62
commit
46cec40cfe
|
@ -39,11 +39,9 @@ import { CoreComponentsModule } from '@components/components.module';
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserProfileFieldDelegate, AddonUserProfileFieldCheckboxHandler],
|
||||
useFactory: (
|
||||
userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
handler: AddonUserProfileFieldCheckboxHandler,
|
||||
) => () => userProfileFieldDelegate.registerHandler(handler),
|
||||
deps: [],
|
||||
useFactory: () => () =>
|
||||
CoreUserProfileFieldDelegate.instance.registerHandler(AddonUserProfileFieldCheckboxHandler.instance),
|
||||
},
|
||||
],
|
||||
exports: [
|
||||
|
|
|
@ -17,13 +17,14 @@ import { Injectable, Type } from '@angular/core';
|
|||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonUserProfileFieldCheckboxComponent } from '../../component/checkbox';
|
||||
|
||||
/**
|
||||
* Checkbox user profile field handlers.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonUserProfileFieldCheckboxHandler implements CoreUserProfileFieldHandler {
|
||||
export class AddonUserProfileFieldCheckboxHandlerService implements CoreUserProfileFieldHandler {
|
||||
|
||||
name = 'AddonUserProfileFieldCheckbox';
|
||||
type = 'checkbox';
|
||||
|
@ -74,3 +75,5 @@ export class AddonUserProfileFieldCheckboxHandler implements CoreUserProfileFiel
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class AddonUserProfileFieldCheckboxHandler extends makeSingleton(AddonUserProfileFieldCheckboxHandlerService) {}
|
||||
|
|
|
@ -41,11 +41,9 @@ import { CorePipesModule } from '@pipes/pipes.module';
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserProfileFieldDelegate, AddonUserProfileFieldDatetimeHandler],
|
||||
useFactory: (
|
||||
userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
handler: AddonUserProfileFieldDatetimeHandler,
|
||||
) => () => userProfileFieldDelegate.registerHandler(handler),
|
||||
deps: [],
|
||||
useFactory: () => () =>
|
||||
CoreUserProfileFieldDelegate.instance.registerHandler(AddonUserProfileFieldDatetimeHandler.instance),
|
||||
},
|
||||
],
|
||||
exports: [
|
||||
|
|
|
@ -18,13 +18,14 @@ import { AuthEmailSignupProfileField } from '@features/login/services/login-help
|
|||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonUserProfileFieldDatetimeComponent } from '../../component/datetime';
|
||||
|
||||
/**
|
||||
* Datetime user profile field handlers.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFieldHandler {
|
||||
export class AddonUserProfileFieldDatetimeHandlerService implements CoreUserProfileFieldHandler {
|
||||
|
||||
name = 'AddonUserProfileFieldDatetime';
|
||||
type = 'datetime';
|
||||
|
@ -76,3 +77,5 @@ export class AddonUserProfileFieldDatetimeHandler implements CoreUserProfileFiel
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class AddonUserProfileFieldDatetimeHandler extends makeSingleton(AddonUserProfileFieldDatetimeHandlerService) {}
|
||||
|
|
|
@ -41,11 +41,9 @@ import { CoreDirectivesModule } from '@directives/directives.module';
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserProfileFieldDelegate, AddonUserProfileFieldMenuHandler],
|
||||
useFactory: (
|
||||
userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
handler: AddonUserProfileFieldMenuHandler,
|
||||
) => () => userProfileFieldDelegate.registerHandler(handler),
|
||||
deps: [],
|
||||
useFactory: () => () =>
|
||||
CoreUserProfileFieldDelegate.instance.registerHandler(AddonUserProfileFieldMenuHandler.instance),
|
||||
},
|
||||
],
|
||||
exports: [
|
||||
|
|
|
@ -17,13 +17,14 @@ import { Injectable, Type } from '@angular/core';
|
|||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { CoreUserProfileFieldHandler, CoreUserProfileFieldHandlerData } from '@features/user/services/user-profile-field-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonUserProfileFieldMenuComponent } from '../../component/menu';
|
||||
|
||||
/**
|
||||
* Menu user profile field handlers.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonUserProfileFieldMenuHandler implements CoreUserProfileFieldHandler {
|
||||
export class AddonUserProfileFieldMenuHandlerService implements CoreUserProfileFieldHandler {
|
||||
|
||||
name = 'AddonUserProfileFieldMenu';
|
||||
type = 'menu';
|
||||
|
@ -74,3 +75,5 @@ export class AddonUserProfileFieldMenuHandler implements CoreUserProfileFieldHan
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class AddonUserProfileFieldMenuHandler extends makeSingleton(AddonUserProfileFieldMenuHandlerService) {}
|
||||
|
|
|
@ -19,12 +19,13 @@ import { AddonUserProfileFieldTextComponent } from '../../component/text';
|
|||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
/**
|
||||
* Text user profile field handlers.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonUserProfileFieldTextHandler implements CoreUserProfileFieldHandler {
|
||||
export class AddonUserProfileFieldTextHandlerService implements CoreUserProfileFieldHandler {
|
||||
|
||||
name = 'AddonUserProfileFieldText';
|
||||
type = 'text';
|
||||
|
@ -73,3 +74,5 @@ export class AddonUserProfileFieldTextHandler implements CoreUserProfileFieldHan
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class AddonUserProfileFieldTextHandler extends makeSingleton(AddonUserProfileFieldTextHandlerService) {}
|
||||
|
|
|
@ -41,11 +41,9 @@ import { CoreDirectivesModule } from '@directives/directives.module';
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserProfileFieldDelegate, AddonUserProfileFieldTextHandler],
|
||||
useFactory: (
|
||||
userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
handler: AddonUserProfileFieldTextHandler,
|
||||
) => () => userProfileFieldDelegate.registerHandler(handler),
|
||||
deps: [],
|
||||
useFactory: () => () =>
|
||||
CoreUserProfileFieldDelegate.instance.registerHandler(AddonUserProfileFieldTextHandler.instance),
|
||||
},
|
||||
],
|
||||
exports: [
|
||||
|
|
|
@ -19,12 +19,13 @@ import { AddonUserProfileFieldTextareaComponent } from '../../component/textarea
|
|||
import { CoreTextUtils } from '@services/utils/text';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { CoreUserProfileField } from '@features/user/services/user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
/**
|
||||
* Textarea user profile field handlers.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonUserProfileFieldTextareaHandler implements CoreUserProfileFieldHandler {
|
||||
export class AddonUserProfileFieldTextareaHandlerService implements CoreUserProfileFieldHandler {
|
||||
|
||||
name = 'AddonUserProfileFieldTextarea';
|
||||
type = 'textarea';
|
||||
|
@ -83,3 +84,5 @@ export class AddonUserProfileFieldTextareaHandler implements CoreUserProfileFiel
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class AddonUserProfileFieldTextareaHandler extends makeSingleton(AddonUserProfileFieldTextareaHandlerService) {}
|
||||
|
|
|
@ -43,11 +43,9 @@ import { CoreEditorComponentsModule } from '@features/editor/components/componen
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserProfileFieldDelegate, AddonUserProfileFieldTextareaHandler],
|
||||
useFactory: (
|
||||
userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
handler: AddonUserProfileFieldTextareaHandler,
|
||||
) => () => userProfileFieldDelegate.registerHandler(handler),
|
||||
deps: [],
|
||||
useFactory: () => () =>
|
||||
CoreUserProfileFieldDelegate.instance.registerHandler(AddonUserProfileFieldTextareaHandler.instance),
|
||||
},
|
||||
],
|
||||
exports: [
|
||||
|
|
|
@ -83,7 +83,6 @@ export class CoreLoginEmailSignupPage implements OnInit {
|
|||
protected navCtrl: NavController,
|
||||
protected fb: FormBuilder,
|
||||
protected route: ActivatedRoute,
|
||||
protected userProfileFieldDelegate: CoreUserProfileFieldDelegate,
|
||||
) {
|
||||
// Create the ageVerificationForm.
|
||||
this.ageVerificationForm = this.fb.group({
|
||||
|
@ -191,7 +190,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
|
|||
{ siteUrl: this.siteUrl },
|
||||
);
|
||||
|
||||
if (this.userProfileFieldDelegate.hasRequiredUnsupportedField(this.settings.profilefields)) {
|
||||
if (CoreUserProfileFieldDelegate.instance.hasRequiredUnsupportedField(this.settings.profilefields)) {
|
||||
this.allRequiredSupported = false;
|
||||
|
||||
throw new Error(Translate.instance.instant('core.login.signuprequiredfieldnotsupported'));
|
||||
|
@ -302,7 +301,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
|
|||
|
||||
try {
|
||||
// Get the data for the custom profile fields.
|
||||
params.customprofilefields = await this.userProfileFieldDelegate.getDataForFields(
|
||||
params.customprofilefields = await CoreUserProfileFieldDelegate.instance.getDataForFields(
|
||||
this.settings?.profilefields,
|
||||
true,
|
||||
'email',
|
||||
|
|
|
@ -40,10 +40,6 @@ export class CoreUserProfileFieldComponent implements OnInit {
|
|||
componentClass?: Type<unknown>; // The class of the component to render.
|
||||
data: CoreUserProfileFieldComponentData = {}; // Data to pass to the component.
|
||||
|
||||
constructor(
|
||||
protected userProfileFieldsDelegate: CoreUserProfileFieldDelegate,
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
*/
|
||||
|
@ -52,7 +48,7 @@ export class CoreUserProfileFieldComponent implements OnInit {
|
|||
return;
|
||||
}
|
||||
|
||||
this.componentClass = await this.userProfileFieldsDelegate.getComponent(this.field, this.signup);
|
||||
this.componentClass = await CoreUserProfileFieldDelegate.instance.getComponent(this.field, this.signup);
|
||||
|
||||
this.data.field = this.field;
|
||||
this.data.edit = CoreUtils.instance.isTrueOrOne(this.edit);
|
||||
|
|
|
@ -31,7 +31,7 @@ import {
|
|||
CoreUserProvider,
|
||||
} from '@features/user/services/user';
|
||||
import { CoreUserHelper } from '@features/user/services/user-helper';
|
||||
import { CoreUserDelegate, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
|
||||
import { CoreUserDelegate, CoreUserDelegateService, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
|
||||
import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper';
|
||||
import { CoreIonLoadingElement } from '@classes/ion-loading';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
|
@ -64,7 +64,6 @@ export class CoreUserProfilePage implements OnInit, OnDestroy {
|
|||
constructor(
|
||||
protected route: ActivatedRoute,
|
||||
protected navCtrl: NavController,
|
||||
protected userDelegate: CoreUserDelegate,
|
||||
) {
|
||||
|
||||
this.obsProfileRefreshed = CoreEvents.on<CoreUserProfileRefreshedData>(CoreUserProvider.PROFILE_REFRESHED, (data) => {
|
||||
|
@ -127,26 +126,26 @@ export class CoreUserProfilePage implements OnInit, OnDestroy {
|
|||
// If there's already a subscription, unsubscribe because we'll get a new one.
|
||||
this.subscription?.unsubscribe();
|
||||
|
||||
this.subscription = this.userDelegate.getProfileHandlersFor(user, this.courseId).subscribe((handlers) => {
|
||||
this.subscription = CoreUserDelegate.instance.getProfileHandlersFor(user, this.courseId).subscribe((handlers) => {
|
||||
this.actionHandlers = [];
|
||||
this.newPageHandlers = [];
|
||||
this.communicationHandlers = [];
|
||||
handlers.forEach((handler) => {
|
||||
switch (handler.type) {
|
||||
case CoreUserDelegate.TYPE_COMMUNICATION:
|
||||
case CoreUserDelegateService.TYPE_COMMUNICATION:
|
||||
this.communicationHandlers.push(handler.data);
|
||||
break;
|
||||
case CoreUserDelegate.TYPE_ACTION:
|
||||
case CoreUserDelegateService.TYPE_ACTION:
|
||||
this.actionHandlers.push(handler.data);
|
||||
break;
|
||||
case CoreUserDelegate.TYPE_NEW_PAGE:
|
||||
case CoreUserDelegateService.TYPE_NEW_PAGE:
|
||||
default:
|
||||
this.newPageHandlers.push(handler.data);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
this.isLoadingHandlers = !this.userDelegate.areHandlersLoaded(user.id);
|
||||
this.isLoadingHandlers = !CoreUserDelegate.instance.areHandlersLoaded(user.id);
|
||||
});
|
||||
|
||||
await this.checkUserImageUpdated();
|
||||
|
|
|
@ -18,12 +18,13 @@ import { Params } from '@angular/router';
|
|||
import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler';
|
||||
import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
/**
|
||||
* Handler to treat links to user profiles.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserProfileLinkHandler extends CoreContentLinksHandlerBase {
|
||||
export class CoreUserProfileLinkHandlerService extends CoreContentLinksHandlerBase {
|
||||
|
||||
name = 'CoreUserProfileLinkHandler';
|
||||
// Match user/view.php and user/profile.php but NOT grade/report/user/.
|
||||
|
@ -74,3 +75,5 @@ export class CoreUserProfileLinkHandler extends CoreContentLinksHandlerBase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class CoreUserProfileLinkHandler extends makeSingleton(CoreUserProfileLinkHandlerService) {}
|
||||
|
|
|
@ -14,20 +14,21 @@
|
|||
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreUserDelegate, CoreUserProfileHandler, CoreUserProfileHandlerData } from '../user-delegate';
|
||||
import { CoreUserDelegateService, CoreUserProfileHandler, CoreUserProfileHandlerData } from '../user-delegate';
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreUserProfile } from '../user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
/**
|
||||
* Handler to send a email to a user.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserProfileMailHandler implements CoreUserProfileHandler {
|
||||
export class CoreUserProfileMailHandlerService implements CoreUserProfileHandler {
|
||||
|
||||
name = 'CoreUserProfileMail';
|
||||
priority = 700;
|
||||
type = CoreUserDelegate.TYPE_COMMUNICATION;
|
||||
type = CoreUserDelegateService.TYPE_COMMUNICATION;
|
||||
|
||||
/**
|
||||
* Check if handler is enabled.
|
||||
|
@ -73,3 +74,5 @@ export class CoreUserProfileMailHandler implements CoreUserProfileHandler {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class CoreUserProfileMailHandler extends makeSingleton(CoreUserProfileMailHandlerService) {}
|
||||
|
|
|
@ -15,13 +15,14 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { CoreCronHandler } from '@services/cron';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreUserSync } from '../user-sync';
|
||||
|
||||
/**
|
||||
* Synchronization cron handler.
|
||||
*/
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserSyncCronHandler implements CoreCronHandler {
|
||||
export class CoreUserSyncCronHandlerService implements CoreCronHandler {
|
||||
|
||||
name = 'CoreUserSyncCronHandler';
|
||||
|
||||
|
@ -48,3 +49,5 @@ export class CoreUserSyncCronHandler implements CoreCronHandler {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class CoreUserSyncCronHandler extends makeSingleton(CoreUserSyncCronHandlerService) {}
|
||||
|
|
|
@ -19,6 +19,7 @@ import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
|||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreUserProfile } from './user';
|
||||
import { makeSingleton } from '@singletons';
|
||||
|
||||
/**
|
||||
* Interface that all user profile handlers must implement.
|
||||
|
@ -127,10 +128,8 @@ export interface CoreUserProfileHandlerToDisplay {
|
|||
* Service to interact with plugins to be shown in user profile. Provides functions to register a plugin
|
||||
* and notify an update in the data.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CoreUserDelegate extends CoreDelegate<CoreUserProfileHandler> {
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserDelegateService extends CoreDelegate<CoreUserProfileHandler> {
|
||||
|
||||
/**
|
||||
* User profile handler type for communication.
|
||||
|
@ -164,7 +163,7 @@ export class CoreUserDelegate extends CoreDelegate<CoreUserProfileHandler> {
|
|||
constructor() {
|
||||
super('CoreUserDelegate', true);
|
||||
|
||||
CoreEvents.on<CoreUserUpdateHandlerData>(CoreUserDelegate.UPDATE_HANDLER_EVENT, (data) => {
|
||||
CoreEvents.on<CoreUserUpdateHandlerData>(CoreUserDelegateService.UPDATE_HANDLER_EVENT, (data) => {
|
||||
if (!data || !data.handler || !this.userHandlers[data.userId]) {
|
||||
return;
|
||||
}
|
||||
|
@ -255,7 +254,7 @@ export class CoreUserDelegate extends CoreDelegate<CoreUserProfileHandler> {
|
|||
name: name,
|
||||
data: handler.getDisplayData(user, courseId),
|
||||
priority: handler.priority || 0,
|
||||
type: handler.type || CoreUserDelegate.TYPE_NEW_PAGE,
|
||||
type: handler.type || CoreUserDelegateService.TYPE_NEW_PAGE,
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
|
@ -271,6 +270,8 @@ export class CoreUserDelegate extends CoreDelegate<CoreUserProfileHandler> {
|
|||
|
||||
}
|
||||
|
||||
export class CoreUserDelegate extends makeSingleton(CoreUserDelegateService) {}
|
||||
|
||||
/**
|
||||
* Data passed to UPDATE_HANDLER_EVENT event.
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,7 @@ import { CoreUserRole } from './user';
|
|||
/**
|
||||
* Service that provides some features regarding users information.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserHelperProvider {
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,14 +16,12 @@ import { Injectable } from '@angular/core';
|
|||
|
||||
import { CoreSites } from '@services/sites';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { PREFERENCES_TABLE_NAME, CoreUserPreferenceDBRecord } from './db/user';
|
||||
import { PREFERENCES_TABLE_NAME, CoreUserPreferenceDBRecord } from './database/user';
|
||||
|
||||
/**
|
||||
* Service to handle offline user preferences.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserOfflineProvider {
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
|||
import { CoreDelegate, CoreDelegateHandler } from '@classes/delegate';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { AuthEmailSignupProfileField } from '@features/login/services/login-helper';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { CoreUserProfileField } from './user';
|
||||
|
||||
/**
|
||||
|
@ -73,10 +74,8 @@ export interface CoreUserProfileFieldHandlerData {
|
|||
/**
|
||||
* Service to interact with user profile fields.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CoreUserProfileFieldDelegate extends CoreDelegate<CoreUserProfileFieldHandler> {
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserProfileFieldDelegateService extends CoreDelegate<CoreUserProfileFieldHandler> {
|
||||
|
||||
protected handlerNameProperty = 'type';
|
||||
|
||||
|
@ -206,3 +205,5 @@ export class CoreUserProfileFieldDelegate extends CoreDelegate<CoreUserProfileFi
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
export class CoreUserProfileFieldDelegate extends makeSingleton(CoreUserProfileFieldDelegateService) {}
|
||||
|
|
|
@ -25,16 +25,14 @@ import { makeSingleton } from '@singletons';
|
|||
import { CoreEvents, CoreEventUserDeletedData } from '@singletons/events';
|
||||
import { CoreStatusWithWarningsWSResponse, CoreWSExternalWarning } from '@services/ws';
|
||||
import { CoreError } from '@classes/errors/error';
|
||||
import { USERS_TABLE_NAME, CoreUserDBRecord } from './db/user';
|
||||
import { USERS_TABLE_NAME, CoreUserDBRecord } from './database/user';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmUser:';
|
||||
|
||||
/**
|
||||
* Service to provide user functionalities.
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CoreUserProvider {
|
||||
|
||||
static readonly PARTICIPANTS_LIST_LIMIT = 50; // Max of participants to retrieve in each WS call.
|
||||
|
|
|
@ -17,12 +17,14 @@ import { Routes } from '@angular/router';
|
|||
|
||||
import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module';
|
||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/db/user';
|
||||
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/database/user';
|
||||
import { CoreUserComponentsModule } from './components/components.module';
|
||||
import { CoreUserDelegate } from './services/user-delegate';
|
||||
import { CoreUserProfileMailHandler } from './services/handlers/profile-mail';
|
||||
import { CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate';
|
||||
import { CoreUserProfileLinkHandler } from './services/handlers/profile-link';
|
||||
import { CoreCronDelegate } from '@services/cron';
|
||||
import { CoreUserSyncCronHandler } from './services/handlers/sync-cron';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
|
@ -48,17 +50,11 @@ const routes: Routes = [
|
|||
{
|
||||
provide: APP_INITIALIZER,
|
||||
multi: true,
|
||||
deps: [CoreUserDelegate, CoreUserProfileMailHandler, CoreContentLinksDelegate, CoreUserProfileLinkHandler],
|
||||
useFactory: (
|
||||
userDelegate: CoreUserDelegate,
|
||||
mailHandler: CoreUserProfileMailHandler,
|
||||
linksDelegate: CoreContentLinksDelegate,
|
||||
profileLinkHandler: CoreUserProfileLinkHandler,
|
||||
|
||||
) => () => {
|
||||
// @todo: Register sync handler when init process has been fixed.
|
||||
userDelegate.registerHandler(mailHandler);
|
||||
linksDelegate.registerHandler(profileLinkHandler);
|
||||
deps: [],
|
||||
useFactory: () => () => {
|
||||
CoreUserDelegate.instance.registerHandler(CoreUserProfileMailHandler.instance);
|
||||
CoreContentLinksDelegate.instance.registerHandler(CoreUserProfileLinkHandler.instance);
|
||||
CoreCronDelegate.instance.register(CoreUserSyncCronHandler.instance);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue