Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Oct 19, 2023
1 parent 8f8110b commit 568b736
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
// done = false;
triggerVisible = false;
searchHash: string | null = null;
geoHash: string | null = null;

results: (Card | null)[] = [];
obs: IntersectionObserver;
Expand All @@ -71,7 +72,16 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
this.paramsQueue.pipe(
filter((params) => !!params),
delay(1),
debounceTime(this.platform.browser() ? 2000 : 0),
switchMap((params) => {
if (params.searchHash === this.searchHash && params.geoHash === this.geoHash) {
return from([]);
} else {
return from([params]);
}
}),
switchMap((params) => {
this.geoHash = params.geoHash;
if (params.searchHash === this.searchHash) {
return from([params]);
} else {
Expand All @@ -93,7 +103,6 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
);
}
}),
debounceTime(this.platform.browser() ? 500 : 0),
).subscribe((params) => {
this.offset = 0;
this.fetchedOffset = -1;
Expand All @@ -104,7 +113,7 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit
this.resultsSubscription = null;
}
this.fetchQueue = new ReplaySubject<SearchParamsOffset>(1);
this.resultsSubscription = timer(2000).pipe(
this.resultsSubscription = timer(1).pipe(
switchMap(() => this.fetchQueue),
filter((params) => {
return params.offset > this.fetchedOffset;
Expand Down
2 changes: 1 addition & 1 deletion projects/srm/src/app/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class SearchParams {
}

get geoHash(): string {
return this.bounds?.map((x) => x.join(',')).join('|') || '';
return this.bounds?.map((x) => x.map((xx) => xx.toFixed(4)).join(',')).join('|') || '';
}

get hasFilters(): boolean {
Expand Down
26 changes: 14 additions & 12 deletions projects/srm/src/app/page/page.component.less
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,21 @@
box-shadow: 0px 0px 12px 0px rgba(171, 199, 255, 0.50);
});
}

app-search-results {
transform: translateY(0%);
animation: 0.2s ease-in-out 1 forwards;
animation-fill-mode: forwards;
transition: transform 0.2s ease-in-out;
&.shown {
animation-name: show-results;
}
&.hidden {
animation-name: hide-results;

.mobile({
app-search-results {
transform: translateY(0%);
animation: 0.2s ease-in-out 1 forwards;
animation-fill-mode: forwards;
transition: transform 0.2s ease-in-out;
&.shown {
animation-name: show-results;
}
&.hidden {
animation-name: hide-results;
}
}
}
});

app-disclaimer-footer {
margin-top: auto;
Expand Down
3 changes: 3 additions & 0 deletions projects/srm/src/app/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export class PageComponent implements OnInit {

this.searchParamsCalc.pipe(
untilDestroyed(this),
filter((spc) => {
return this.stage === 'search-results';
}),
debounceTime(platform.browser() ? 100 : 0),
delay(1),
map((spc) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
overscroll-behavior-y: none;
.no-scrollbars;
flex: 1 1 auto;
z-index: 0;
}

.mobile({
Expand Down

0 comments on commit 568b736

Please sign in to comment.