SES-135 resolved conflicts

This commit is contained in:
Natalia Gawron 2021-01-10 15:52:36 +01:00
commit dccbdb8f4a
3 changed files with 15 additions and 18 deletions

View File

@ -1,6 +1,9 @@
import {Component, OnInit} from '@angular/core';
import {AbilitiesComponent} from "../abilities/abilities.component";
import { Component, OnInit } from '@angular/core';
import { PlayerSignalRService } from "../../shared/signalR-service/player-signalR.service";
import { first } from "rxjs/operators";
import { Store } from '@ngrx/store';
import { AppState } from 'src/app/store/models/app-state.model';
import { AbilitiesComponent } from '../abilities/abilities.component';
@Component({
selector: 'app-player-dashboard',
@ -12,7 +15,12 @@ export class PlayerDashboardComponent implements OnInit {
isExpanded = false;
selected = false;
constructor(private signalRService: PlayerSignalRService, private store: Store<AppState>) {}
ngOnInit() {
this.store.select(s => s.playerStore.characterId).pipe(first()).subscribe((id) => {
this.signalRService.Login(id);
});
this.SwitchMiddleComponent('AbilitiesComponent');
}
@ -26,5 +34,4 @@ export class PlayerDashboardComponent implements OnInit {
this.middleComponent = AbilitiesComponent;
}
}
}

View File

@ -3,10 +3,9 @@ import { FormGroup, Validators, FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import {UserService} from '../../../services/user.service';
import {ErrorResponse} from '../../../types/ErrorResponse';
import {Observable, Subscription} from 'rxjs';
import {Subscription} from 'rxjs';
import {HttpErrorResponse} from '@angular/common/http';
import {AppStoreModel} from '../../store/models/app-store.model';
import {select, Store} from '@ngrx/store';
import {Store} from '@ngrx/store';
import {AddUserId} from '../../store/actions/app.actions';
import {AppState} from 'src/app/store/models/app-state.model';
import {first} from "rxjs/operators";
@ -18,9 +17,6 @@ import {first} from "rxjs/operators";
})
export class SignInComponent implements OnDestroy, OnInit {
allSubscriptions = new Subscription();
role$: Observable<AppStoreModel>;
isExpanded = false;
apiError = false;
apiErrorMessage = '';
@ -39,7 +35,6 @@ export class SignInComponent implements OnDestroy, OnInit {
});
ngOnInit() {
this.role$ = this.store.select(s => s.appStore);
}
onLoginButtonClick() {
@ -77,10 +72,6 @@ export class SignInComponent implements OnDestroy, OnInit {
this.router.navigate(['']);
}
collapse() {
this.isExpanded = false;
}
toggle() {
this.isExpanded = !this.isExpanded;
}

View File

@ -8,15 +8,14 @@ export class PlayerSignalRService {
constructor(@Inject('BASE_URL') baseUrl: string) {
this.signalR = new SignalRService(baseUrl);
this.registerOnServerEvents();
this.signalR.startConnection();
}
public Login() {
public Login(characterId: number) {
this.signalR.startConnection();
this.signalR.connectionEstablished$.subscribe(() => {
if (this.signalR.connectionEstablished$.getValue() === true) {
this.signalR.hubConnection.send('GameMasterLogin');
this.signalR.hubConnection.send('PlayerCharacterLogin', characterId);
}
});
}