Merge pull request #4294 from FinnStutzenstein/fixOperatorService

fixed the operatorservice
This commit is contained in:
Emanuel Schütze 2019-02-10 21:10:30 +01:00 committed by GitHub
commit 050573b53c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 13 deletions

View File

@ -10,7 +10,6 @@ import { environment } from 'environments/environment';
import { DataStoreService } from './data-store.service'; import { DataStoreService } from './data-store.service';
import { OfflineService } from './offline.service'; import { OfflineService } from './offline.service';
import { ViewUser } from 'app/site/users/models/view-user'; import { ViewUser } from 'app/site/users/models/view-user';
import { CollectionStringMapperService } from './collectionStringMapper.service';
import { OnAfterAppsLoaded } from '../onAfterAppsLoaded'; import { OnAfterAppsLoaded } from '../onAfterAppsLoaded';
import { UserRepositoryService } from '../repositories/users/user-repository.service'; import { UserRepositoryService } from '../repositories/users/user-repository.service';
@ -101,9 +100,9 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL
private viewOperatorSubject: BehaviorSubject<ViewUser> = new BehaviorSubject<ViewUser>(null); private viewOperatorSubject: BehaviorSubject<ViewUser> = new BehaviorSubject<ViewUser>(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, * 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 http: HttpClient,
private DS: DataStoreService, private DS: DataStoreService,
private offlineService: OfflineService, private offlineService: OfflineService,
private collectionStringMapperService: CollectionStringMapperService private userRepository: UserRepositoryService
) { ) {
super(); super();
@ -141,9 +140,7 @@ export class OperatorService extends OpenSlidesComponent implements OnAfterAppsL
* Load the repo to get a view user. * Load the repo to get a view user.
*/ */
public onAfterAppsLoaded(): void { public onAfterAppsLoaded(): void {
this.userRepository = this.collectionStringMapperService.getRepositoryFromModelConstructor( this.userRepoLoaded = true;
User
) as UserRepositoryService;
if (this.user) { if (this.user) {
this._viewUser = this.userRepository.getViewModel(this.user.id); 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 { private updateUser(user: User | null): void {
this._user = user; this._user = user;
if (user && this.userRepository) { if (user && this.userRepoLoaded) {
this._viewUser = this.userRepository.getViewModel(user.id); this._viewUser = this.userRepository.getViewModel(user.id);
} else { } else {
this._viewUser = null; this._viewUser = null;

View File

@ -189,8 +189,8 @@ export abstract class BaseRepository<V extends BaseViewModel, M extends BaseMode
protected updateViewModelObservable(id: number): void { protected updateViewModelObservable(id: number): void {
if (this.viewModelSubjects[id]) { if (this.viewModelSubjects[id]) {
this.viewModelSubjects[id].next(this.viewModelStore[id]); this.viewModelSubjects[id].next(this.viewModelStore[id]);
this.generalViewModelSubject.next(this.viewModelStore[id]);
} }
this.generalViewModelSubject.next(this.viewModelStore[id]);
} }
/** /**

View File

@ -41,7 +41,6 @@
settings settings
</mat-icon> </mat-icon>
</mat-form-field> </mat-form-field>
</form> </form>
<br> <br>
@ -49,7 +48,6 @@
<span translate>Initial password</span>: {{ user.default_password }}<br> <span translate>Initial password</span>: {{ user.default_password }}<br>
<span translate>Username</span>: {{ user.username }} <span translate>Username</span>: {{ user.username }}
</div> </div>
</div> </div>
<div *ngIf="this.ownPage"> <div *ngIf="this.ownPage">
@ -88,6 +86,4 @@
</mat-form-field> </mat-form-field>
</form> </form>
</div> </div>
</mat-card> </mat-card>