Skip to content

Commit

Permalink
fix(main.component): adapt code to consider that communitie$ is an ob…
Browse files Browse the repository at this point in the history
…servable
  • Loading branch information
NyaGarcia committed Jun 26, 2020
1 parent 32a3833 commit 65e0b60
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/app/pages/main/main.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ActivatedRoute, Router } from '@angular/router';
import { Community, Communities } from '@shared/interfaces';
import { Component, Input } from '@angular/core';
import { map } from 'rxjs/operators';
import { map, withLatestFrom } from 'rxjs/operators';
import { CommunityService } from '@shared/services';

@Component({
Expand All @@ -11,9 +11,11 @@ import { CommunityService } from '@shared/services';
})
export class MainComponent {
@Input()
/* communities: Communities; */
communitie$ = this.communityService.communities;
community$ = this.route.fragment.pipe(map(community => this.communitie$[community]));
community$ = this.route.fragment.pipe(
withLatestFrom(this.communitie$),
map(([community, communities]) => communities[community]),
);

constructor(
private router: Router,
Expand Down

0 comments on commit 65e0b60

Please sign in to comment.