Commit 6eac125b authored by Lukas Burgey's avatar Lukas Burgey

Simplify some code

parent 79097f6f
......@@ -38,7 +38,7 @@ export class UserService {
private deployments$ = new BehaviorSubject<Deployment[]>([]);
public voSelector = (user: User) => user ? user.vos : [];
public serviceSelector = (user: User) => user ? user.services ? user.services : [] : [];
public serviceSelector = (user: User) => user ? user.services : [];
constructor(
private cookieService: CookieService,
......@@ -386,23 +386,24 @@ export class UserService {
}
public subscribeVOs(): Observable<VO[]> {
const voSelector = (user: User) => user ? user.vos : [];
const vos$ = this.subscribeSpecific<VO[]>(voSelector);
return this.prefs.connect().pipe(
combineLatest(
vos$,
this.subscribeServices(),
(prefs: Prefs, vos: VO[], svc: Service[]) => {
this.user$.asObservable(),
(prefs: Prefs, user: User) => {
const vos = this.voSelector(user);
const services = this.serviceSelector(user);
if (prefs.showEmptyVOs) {
// filter VOs that have no services
// filter out VOs that have no services
return vos.filter(
(vo: VO) => svc.some(
(vo: VO) => services.some(
(s: Service) => s.vos.some(
svo => svo.id === vo.id,
),
),
);
}
return vos;
}
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment