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:

newSearchPage.component.ts
22 22
import {HelperFunctions} from "../../utils/HelperFunctions.class";
23 23
import {properties} from "../../../../environments/environment";
24 24
import {AlertModal} from "../../utils/modal/alert";
25
import {Subscriber} from "rxjs";
25 26

  
26 27
declare var UIkit: any;
27 28

  
......
89 90
  @Input() lastIndex: boolean = true;
90 91
  public dashboard: boolean = properties.isDashboard;
91 92

  
92
  piwiksub: any;
93
  subscriptions = [];
93 94
  public parameterNames: string[] = [];
94 95
  public parameterValues: string[] = [];
95 96

  
......
145 146
      this.updateUrl(this.properties.domain + this.properties.baseLink + this.router.url);
146 147
      this.url = this.properties.domain + this.properties.baseLink + this.router.url;
147 148
      if (typeof document !== 'undefined' && this.isPiwikEnabled && !this.includeOnlyResultsAndFilter) {
148
        this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
149
        this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe());
149 150
      }
150 151
    this.route.queryParams.subscribe(params => {
151 152
      if (params['page'] && params['page'] != 1) {
......
183 184

  
184 185
  private getPageContents() {
185 186
    if((this.customFilter && this.customFilter.queryFieldName == "communityId") && this.properties.adminToolsCommunity !== "monitor") {
186
      this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => {
187
      this.subscriptions.push(this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => {
187 188
        this.pageContents = contents;
188
      });
189
      }));
189 190
    }
190 191
  }
191 192

  
192 193
  private getDivContents() {
193 194
    if((this.customFilter && this.customFilter.queryFieldName == "communityId") && this.properties.adminToolsCommunity !== "monitor") {
194
      this.helper.getDivHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => {
195
      this.subscriptions.push(this.helper.getDivHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : this.properties.adminToolsCommunity, this.router.url).subscribe(contents => {
195 196
        this.divContents = contents;
196
      });
197
      }));
197 198
    }
198 199
  }
199 200

  
200 201
  ngOnDestroy() {
201
    if (this.piwiksub) {
202
      this.piwiksub.unsubscribe();
203
    }
202
    this.subscriptions.forEach(subscription => {
203
      if (subscription instanceof Subscriber) {
204
        subscription.unsubscribe();
205
      }
206
    });
204 207
  }
205 208

  
206 209
  updateDescription() {
......
301 304
      localStorage.setItem('previousRoute', this.router.url);
302 305
    }
303 306
    if (this.isPiwikEnabled && (typeof document !== 'undefined')) {
304
      this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe();
307
      this.subscriptions.push(this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe());
305 308
    }
306 309
    /* End Piwik Code */
307 310
  }

Also available in: Unified diff