From 89995e01db2db42a3aaea06e5956f677be846c2c Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Sun, 10 Feb 2019 20:18:15 +0100 Subject: [PATCH] fixed the operatorservice Do not use the injector, because only in the operator needed members from the user repository were tree-shaked away by the --aot production build. Import it right away (not nice, but prevents tree shaking) --- .../src/app/core/core-services/operator.service.ts | 13 +++++-------- client/src/app/core/repositories/base-repository.ts | 2 +- .../components/password/password.component.html | 4 ---- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/client/src/app/core/core-services/operator.service.ts b/client/src/app/core/core-services/operator.service.ts index 132a852fc..a0ad0c293 100644 --- a/client/src/app/core/core-services/operator.service.ts +++ b/client/src/app/core/core-services/operator.service.ts @@ -10,7 +10,6 @@ import { environment } from 'environments/environment'; import { DataStoreService } from './data-store.service'; import { OfflineService } from './offline.service'; import { ViewUser } from 'app/site/users/models/view-user'; -import { CollectionStringMapperService } from './collectionStringMapper.service'; import { OnAfterAppsLoaded } from '../onAfterAppsLoaded'; import { UserRepositoryService } from '../repositories/users/user-repository.service'; @@ -101,9 +100,9 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL private viewOperatorSubject: BehaviorSubject = new BehaviorSubject(null); /** - * The user repository. Will be filled by the `onAfterAppsLoaded`. + * Do not access the repo before it wasn't loaded. Will be true after `onAfterAppsLoaded`. */ - private userRepository: UserRepositoryService; + private userRepoLoaded = false; /** * Sets up an observer for watching changes in the DS. If the operator user or groups are changed, @@ -117,7 +116,7 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL private http: HttpClient, private DS: DataStoreService, private offlineService: OfflineService, - private collectionStringMapperService: CollectionStringMapperService + private userRepository: UserRepositoryService ) { super(); @@ -141,9 +140,7 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL * Load the repo to get a view user. */ public onAfterAppsLoaded(): void { - this.userRepository = this.collectionStringMapperService.getRepositoryFromModelConstructor( - User - ) as UserRepositoryService; + this.userRepoLoaded = true; if (this.user) { this._viewUser = this.userRepository.getViewModel(this.user.id); } @@ -156,7 +153,7 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL */ private updateUser(user: User | null): void { this._user = user; - if (user && this.userRepository) { + if (user && this.userRepoLoaded) { this._viewUser = this.userRepository.getViewModel(user.id); } else { this._viewUser = null; diff --git a/client/src/app/core/repositories/base-repository.ts b/client/src/app/core/repositories/base-repository.ts index fe5279bf2..c3c64dc9f 100644 --- a/client/src/app/core/repositories/base-repository.ts +++ b/client/src/app/core/repositories/base-repository.ts @@ -189,8 +189,8 @@ export abstract class BaseRepository -
@@ -49,7 +48,6 @@ Initial password: {{ user.default_password }}
Username: {{ user.username }} -
@@ -88,6 +86,4 @@
- -