package bugfix
This commit is contained in:
1
package-lock.json
generated
1
package-lock.json
generated
@@ -22130,6 +22130,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
|
||||||
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
|
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
"darwin"
|
"darwin"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
import {ChangeDetectionStrategy, Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {SongService} from '../services/song.service';
|
import {SongService} from '../services/song.service';
|
||||||
import {Song} from '../services/song';
|
import {Song} from '../services/song';
|
||||||
import {debounceTime, map} from 'rxjs/operators';
|
import {debounceTime, map} from 'rxjs/operators';
|
||||||
@@ -13,6 +13,7 @@ import {ScrollService} from '../../../services/scroll.service';
|
|||||||
selector: 'app-songs',
|
selector: 'app-songs',
|
||||||
templateUrl: './song-list.component.html',
|
templateUrl: './song-list.component.html',
|
||||||
styleUrls: ['./song-list.component.less'],
|
styleUrls: ['./song-list.component.less'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
animations: [fade],
|
animations: [fade],
|
||||||
})
|
})
|
||||||
export class SongListComponent implements OnInit, OnDestroy {
|
export class SongListComponent implements OnInit, OnDestroy {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
.detail {
|
.detail {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
grid-gap: 10px;
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import {Directive, ElementRef, Input, OnInit, TemplateRef, ViewContainerRef} from '@angular/core';
|
import {ChangeDetectorRef, Directive, ElementRef, Input, OnInit, TemplateRef, ViewContainerRef} from '@angular/core';
|
||||||
import {roles} from './roles';
|
import {roles} from './roles';
|
||||||
import {UserService} from './user.service';
|
import {UserService} from './user.service';
|
||||||
import {User} from './user';
|
import {User} from './user';
|
||||||
|
import {combineLatest} from 'rxjs';
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[appRole]',
|
selector: '[appRole]',
|
||||||
@@ -15,25 +16,26 @@ export class RoleDirective implements OnInit {
|
|||||||
private element: ElementRef,
|
private element: ElementRef,
|
||||||
private templateRef: TemplateRef<unknown>,
|
private templateRef: TemplateRef<unknown>,
|
||||||
private viewContainer: ViewContainerRef,
|
private viewContainer: ViewContainerRef,
|
||||||
private userService: UserService
|
private userService: UserService,
|
||||||
|
private changeDetection: ChangeDetectorRef
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.userService.user$.subscribe(user => {
|
combineLatest([this.userService.user$, this.userService.loggedIn$()]).subscribe(_ => {
|
||||||
this.currentUser = user;
|
this.currentUser = _[0];
|
||||||
|
this.loggedIn = _[1];
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
this.userService.loggedIn$().subscribe(_ => {
|
|
||||||
this.loggedIn = !!_;
|
|
||||||
this.updateView();
|
|
||||||
});
|
|
||||||
this.updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private currentViewState = false;
|
||||||
private updateView() {
|
private updateView() {
|
||||||
this.viewContainer.clear();
|
const viewState = this.loggedIn && this.checkPermission();
|
||||||
if (this.loggedIn && this.checkPermission()) {
|
if (this.currentViewState !== viewState) {
|
||||||
this.viewContainer.createEmbeddedView(this.templateRef);
|
if (!viewState) this.viewContainer.clear();
|
||||||
|
if (viewState) this.viewContainer.createEmbeddedView(this.templateRef);
|
||||||
|
this.changeDetection.markForCheck();
|
||||||
|
this.currentViewState = viewState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export class UserService {
|
|||||||
return aUser.user.uid;
|
return aUser.user.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public loggedIn$: () => Observable<firebase.User | null> = () => this.afAuth.authState;
|
public loggedIn$: () => Observable<boolean> = () => this.afAuth.authState.pipe(map(_ => !!_));
|
||||||
|
|
||||||
public list$: () => Observable<User[]> = (): Observable<User[]> => this.db.col$('users');
|
public list$: () => Observable<User[]> = (): Observable<User[]> => this.db.col$('users');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user