Skip to content

Commit

Permalink
Improve performance in new components for analogues and sources
Browse files Browse the repository at this point in the history
  • Loading branch information
davivcu committed Nov 30, 2023
1 parent 1854081 commit a01a90e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/app/components/analogues/analogues.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Input, OnInit } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { BehaviorSubject, distinctUntilChanged } from 'rxjs';
import { EditionLevelType } from 'src/app/app.config';
import { AnalogueClass } from 'src/app/models/evt-models';
import { EVTStatusService } from 'src/app/services/evt-status.service';
Expand All @@ -8,6 +8,7 @@ import { EVTStatusService } from 'src/app/services/evt-status.service';
selector: 'evt-analogues',
templateUrl: './analogues.component.html',
styleUrls: ['./analogues.component.scss','../sources/sources.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AnaloguesComponent implements OnInit {

Expand Down Expand Up @@ -40,7 +41,7 @@ export class AnaloguesComponent implements OnInit {
) {}

ngOnInit() {
this.analoguesInCurrentPage.subscribe({ next: (data) => { this.getEntries(data) } });
this.analoguesInCurrentPage.pipe(distinctUntilChanged()).subscribe({ next: (data) => { this.getEntries(data) } });
}

}
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/sources/sources.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { EVTStatusService } from 'src/app/services/evt-status.service';
import { SourceClass } from '../../models/evt-models';
import { BehaviorSubject } from 'rxjs';
import { BehaviorSubject, distinctUntilChanged } from 'rxjs';
import { EditionLevelType } from 'src/app/app.config';

@Component({
selector: 'evt-sources',
templateUrl: './sources.component.html',
styleUrls: ['./sources.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SourcesComponent implements OnInit {

Expand Down Expand Up @@ -40,7 +41,7 @@ export class SourcesComponent implements OnInit {
) {}

ngOnInit() {
this.quotesInCurrentPage.subscribe({ next: (data) => { this.getEntries(data) } });
this.quotesInCurrentPage.pipe(distinctUntilChanged()).subscribe({ next: (data) => { this.getEntries(data) } });
}

}
3 changes: 2 additions & 1 deletion src/app/utils/dom-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ export function deepSearch(obj, attrToMatch: string, valuesToMatch, counter: num
results = results.concat(deepSearch(value, attrToMatch, valuesToMatch, counter, ignoredProperties));
counter = counter - 1;
} else {
console.log('EVT WARN: element is too deep, not searching further in', obj);
console.log('EVT WARN: element is too deep, not searching further in', obj, value);
counter = 4000;
}
}
}
Expand Down

0 comments on commit a01a90e

Please sign in to comment.