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:

depositFirstPage.component.ts
8 8
import {SEOService} from "../sharedComponents/SEO/SEO.service";
9 9
import {Meta, Title} from "@angular/platform-browser";
10 10
import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component";
11
import {properties} from "../../../environments/environment";
12
import {Subscriber} from "rxjs";
11 13

  
12 14
@Component({
13 15
  selector: 'deposit-first-page',
......
212 214

  
213 215
  @Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
214 216
  @Input() piwikSiteId = null;
215
  piwiksub:any;
216 217

  
217 218
  @Input() communityId = null;
218 219

  
......
226 227
  public routerHelper:RouterHelper = new RouterHelper();
227 228
  @Input() showBreadcrumb:boolean = false;
228 229
  breadcrumbs:Breadcrumb[] = [];
230
  subscriptions = [];
229 231
  constructor (private  route: ActivatedRoute, private _piwikService:PiwikService,
230 232
               private helper: HelperService,
231 233
               private _router: Router,
......
235 237

  
236 238

  
237 239
  ngOnInit() {
238
    this.route.data
239
      .subscribe((data: { envSpecific: EnvProperties }) => {
240
        this.properties = data.envSpecific;
240
        this.properties = properties;
241 241
        this.url = this.properties.domain+this.properties.baseLink + this._router.url;
242 242
        this.seoService.createLinkForCanonicalURL(this.url, false);
243 243

  
......
260 260
        }
261 261

  
262 262
        if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
263
          this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe();
263
          this.subscriptions.push(this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe());
264 264
        }
265 265
        this.breadcrumbs.push({name: 'home', route: '/'}, {name: "Deposit", route: null});
266
      });
267 266
  }
268 267

  
269 268
  public getPageContents() {
270
    this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
269
    this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
271 270
      this.pageContents = contents;
272
    })
271
    }));
273 272
  }
274 273

  
275 274
  public getDivContents() {
276
    this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
275
    this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
277 276
      this.divContents = contents;
278
    })
277
    }));
279 278
  }
280 279

  
281 280
  ngOnDestroy() {
282
    if(this.piwiksub){
283
      this.piwiksub.unsubscribe();
284
    }
281
    this.subscriptions.forEach(subscription => {
282
      if (subscription instanceof Subscriber) {
283
        subscription.unsubscribe();
284
      }
285
    });
285 286
  }
286 287

  
287 288
  private updateDescription(description:string) {

Also available in: Unified diff