Project

General

Profile

« Previous | Next » 

Revision 59816

[Library|Trunk]

code clean up:
-remove app.* files from library
-remove unused imports, code, files (Old search pages for results, dataproviders, map search page, etc)
-remove Freeguard from modules
-unsubscribe all subscriptions
-Services: configuration, isvocabularies, user management: unsubscribe from app component or the component that uses them (clearSubscriptions())
-Fetchers: unsubscribe from the component that uses them (clearSubscriptions())

View differences:

connectCommunityGuard.guard.ts
1

  
2
import {filter, map, mergeMap} from 'rxjs/operators';
3
import { Injectable } from '@angular/core';
1
import {take, tap} from 'rxjs/operators';
2
import {Injectable} from '@angular/core';
4 3
import {
5 4
  Router,
6 5
  CanActivate,
7 6
  ActivatedRouteSnapshot,
8 7
  RouterStateSnapshot,
9
  CanLoad,
10
  Route
8

  
11 9
} from '@angular/router';
12 10
import {Observable, Subscription} from 'rxjs';
13 11
import {CommunityService} from '../community/community.service';
14
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
15
import {ConnectHelper} from '../connectHelper';
16 12
import {properties} from "../../../../environments/environment";
17 13

  
18 14
@Injectable()
19
export class ConnectCommunityGuard implements  CanActivate {
15
export class ConnectCommunityGuard implements CanActivate {
20 16
  sub: Subscription = null;
21 17

  
22 18
  constructor(private router: Router,
......
24 20
  }
25 21

  
26 22
  check(community: string): Observable<boolean> | boolean {
27
    return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(map(isCommunity => {
28
      if(!isCommunity) {
23
    return this.communityService.isCommunityTypeByState(properties, properties['communityAPI'] + community).pipe(take(1), tap(isCommunity => {
24
      if (!isCommunity) {
29 25
        this.router.navigate(['errorcommunity']);
30 26
      }
31
      return isCommunity;
32 27
    }));
33 28
  }
34 29

  

Also available in: Unified diff