simplify user component (#447)

* simplify user component

* language picker selector
This commit is contained in:
Denys Vuika
2018-06-22 04:59:53 +01:00
committed by Cilibiu Bogdan
parent 045c4ee9a2
commit bc554bb8d3
9 changed files with 79 additions and 34 deletions

View File

@@ -23,13 +23,11 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
import { Subscription } from 'rxjs/Rx';
import { Component, ViewEncapsulation } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
import { selectUser } from '../../store/selectors/app.selectors';
import { ProfileState } from '../../store/states/profile.state';
import { Observable } from 'rxjs/Rx';
import { selectUser, appLanguagePicker } from '../../store/selectors/app.selectors';
import { AppStore, ProfileState } from '../../store/states';
@Component({
selector: 'aca-current-user',
@@ -37,20 +35,12 @@ import { ProfileState } from '../../store/states/profile.state';
encapsulation: ViewEncapsulation.None,
host: { class: 'aca-current-user' }
})
export class CurrentUserComponent implements OnInit, OnDestroy {
private subscriptions: Subscription[] = [];
export class CurrentUserComponent {
profile$: Observable<ProfileState>;
languagePicker$: Observable<boolean>;
user: ProfileState;
constructor(private store: Store<AppStore>) {}
ngOnInit() {
this.subscriptions = this.subscriptions.concat([
this.store.select(selectUser).subscribe((user) => this.user = user)
]);
}
ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
constructor(store: Store<AppStore>) {
this.profile$ = store.select(selectUser);
this.languagePicker$ = store.select(appLanguagePicker);
}
}