Skip to content
Merged
Prev Previous commit
Next Next commit
refactor: TT-106 Delete exponentialGrowth variable in the TimeClock, …
…ProjectListHover and EntryFields components
  • Loading branch information
VanessaIniguezG authored and scastillo-jp committed Feb 17, 2021
commit 6146572725ce62f9ae954f864f8a28e5faeaae7a
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
loadActivitiesSubscription: Subscription;
loadActiveEntrySubscription: Subscription;
actionSetDateSubscription: Subscription;
exponentialGrowth;

constructor(
private featureManagerService: FeatureManagerService,
Expand Down Expand Up @@ -177,9 +176,8 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {
}


async ngOnDestroy():Promise<void> {
this.exponentialGrowth = await this.isFeatureToggleActivated();
if (this.exponentialGrowth) {
ngOnDestroy(): void {
if (this.isFeatureToggleActivated()) {
this.loadActivitiesSubscription.unsubscribe();
this.loadActiveEntrySubscription.unsubscribe();
this.actionSetDateSubscription.unsubscribe();
Expand All @@ -188,9 +186,6 @@ export class EntryFieldsComponent implements OnInit, OnDestroy {

isFeatureToggleActivated() {
return this.featureManagerService.isToggleEnabledForUser('exponential-growth').pipe(
map((enabled) => {
return enabled === true ? true : false;
})
).toPromise();
map((enabled) => enabled));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
isLoading$: Observable<boolean>;
projectsSubscription: Subscription;
activeEntrySubscription: Subscription;
exponentialGrowth;

constructor(private featureManagerService: FeatureManagerService,
private formBuilder: FormBuilder, private store: Store<ProjectState>,
Expand Down Expand Up @@ -110,9 +109,8 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
}
}

async ngOnDestroy(): Promise<void> {
this.exponentialGrowth = await this.isFeatureToggleActivated();
if(this.exponentialGrowth){
ngOnDestroy(): void {
if(this.isFeatureToggleActivated()){
this.projectsSubscription.unsubscribe();
this.activeEntrySubscription.unsubscribe();
}
Expand All @@ -121,9 +119,6 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {

isFeatureToggleActivated() {
return this.featureManagerService.isToggleEnabledForUser('exponential-growth').pipe(
map((enabled) => {
return enabled === true ? true : false;
})
).toPromise();
map((enabled) => enabled));
}
}
11 changes: 3 additions & 8 deletions src/app/modules/time-clock/pages/time-clock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class TimeClockComponent implements OnInit, OnDestroy {
activeTimeEntry: Entry;
clockOutSubscription: Subscription;
storeSubscription: Subscription;
exponentialGrowth;

constructor(
private featureManagerService: FeatureManagerService,
Expand Down Expand Up @@ -73,19 +72,15 @@ export class TimeClockComponent implements OnInit, OnDestroy {
}
}

async ngOnDestroy(): Promise<void> {
this.exponentialGrowth = await this.isFeatureToggleActivated();
this.exponentialGrowth && this.storeSubscription.unsubscribe();
ngOnDestroy(): void {
this.isFeatureToggleActivated() && this.storeSubscription.unsubscribe();
this.clockOutSubscription.unsubscribe();
this.storeSubscription.unsubscribe();
}

isFeatureToggleActivated() {
return this.featureManagerService.isToggleEnabledForUser('exponential-growth').pipe(
map((enabled) => {
return enabled === true ? true : false;
})
).toPromise();
map((enabled) => enabled));
}
}

Expand Down