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:

user.component.ts
8 8
import {EnvProperties} from '../utils/properties/env-properties';
9 9
import {UserManagementService} from "../services/user-management.service";
10 10
import {properties} from "../../../environments/environment";
11
import {Subscriber} from "rxjs";
11 12
import {StringUtils} from "../utils/string-utils.class";
12 13

  
13 14
@Component({
......
21 22
  public server: boolean = true;
22 23
  public errorMessage: string = "";
23 24
  public password: string = "";
24
  private sub: any;
25
  private sublogin: any;
25
  private subscriptions = [];
26 26
  public errorCode: string = "";
27 27
  public redirectUrl: string = "";
28 28
  public routerHelper: RouterHelper = new RouterHelper();
......
41 41
  }
42 42

  
43 43
  ngOnInit() {
44
    this.route.data
44
    this.subscriptions.push(this.route.data
45 45
      .subscribe((data: { envSpecific: EnvProperties }) => {
46 46
        this.properties = data.envSpecific;
47 47
        this.loginUrl = this.properties.loginUrl;
48 48

  
49
      });
49
      }));
50 50
    if (typeof document !== 'undefined') {
51 51
      this.server = false;
52
      this.userManagementsService.getUserInfo().subscribe(user => {
52
      this.subscriptions.push(this.userManagementsService.getUserInfo().subscribe(user => {
53 53
        this.user = user;
54 54
        this.loggedIn = !!this.user;
55 55
        this.errorMessage = "";
56
        this.sub = this.route.queryParams.subscribe(params => {
56
        this.subscriptions.push(this.route.queryParams.subscribe(params => {
57 57
          this.errorCode = params["errorCode"];
58 58
          this.redirectUrl = params["redirectUrl"];
59 59
          this.errorMessage = "";
60 60
          if (this.loggedIn && this.errorCode == '1') {
61 61
            this.redirect();
62 62
          }
63
        });
64
      });
63
        }));
64
      }));
65 65
    }
66 66
  }
67 67

  
68 68

  
69 69
  ngOnDestroy() {
70
    if(this.sub) {
71
      this.sub.unsubscribe();
72
    }
73
    if (this.sublogin) {
74
      this.sublogin.unsubscribe();
75
    }
70
    this.subscriptions.forEach(subscription => {
71
      if (subscription instanceof Subscriber) {
72
        subscription.unsubscribe();
73
      }
74
    });
76 75
  }
77 76

  
78 77
  redirect() {

Also available in: Unified diff