mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4745] memory leak fixes (#4931)
* fix app-layout component * fix card-view component * fix cloud-layout service * code fixes * code fixes * even more fixes * even more fixes * lint fixes * test fixes * fix code * remove useless pipes * fix code owners * enable spellcheck for cloud components * update test * update test
This commit is contained in:
committed by
Eugenio Romano
parent
e2311ab045
commit
1abb9bfc89
@@ -16,15 +16,17 @@
|
||||
*/
|
||||
|
||||
import moment from 'moment-es6';
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { Pipe, PipeTransform, OnDestroy } from '@angular/core';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { UserPreferenceValues, UserPreferencesService } from '../services/user-preferences.service';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Pipe({
|
||||
name: 'adfTimeAgo'
|
||||
})
|
||||
export class TimeAgoPipe implements PipeTransform {
|
||||
export class TimeAgoPipe implements PipeTransform, OnDestroy {
|
||||
|
||||
static DEFAULT_LOCALE = 'en-US';
|
||||
static DEFAULT_DATE_TIME_FORMAT = 'dd/MM/yyyy HH:mm';
|
||||
@@ -32,11 +34,16 @@ export class TimeAgoPipe implements PipeTransform {
|
||||
defaultLocale: string;
|
||||
defaultDateTimeFormat: string;
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(public userPreferenceService: UserPreferencesService,
|
||||
public appConfig: AppConfigService) {
|
||||
this.userPreferenceService.select(UserPreferenceValues.Locale).subscribe((locale) => {
|
||||
this.defaultLocale = locale || TimeAgoPipe.DEFAULT_LOCALE;
|
||||
});
|
||||
this.userPreferenceService
|
||||
.select(UserPreferenceValues.Locale)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(locale => {
|
||||
this.defaultLocale = locale || TimeAgoPipe.DEFAULT_LOCALE;
|
||||
});
|
||||
this.defaultDateTimeFormat = this.appConfig.get<string>('dateValues.defaultDateTimeFormat', TimeAgoPipe.DEFAULT_DATE_TIME_FORMAT);
|
||||
}
|
||||
|
||||
@@ -54,4 +61,9 @@ export class TimeAgoPipe implements PipeTransform {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user