From 568b736731d7518d1457dafc365032bc39598f6a Mon Sep 17 00:00:00 2001 From: Adam Kariv Date: Thu, 19 Oct 2023 19:28:39 +0300 Subject: [PATCH] kolzchut/srm#551 --- .../search-results.component.ts | 13 ++++++++-- projects/srm/src/app/consts.ts | 2 +- projects/srm/src/app/page/page.component.less | 26 ++++++++++--------- projects/srm/src/app/page/page.component.ts | 3 +++ .../results-drawer.component.less | 1 + 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/projects/srm/src/app/autocomplete-results/search-results.component.ts b/projects/srm/src/app/autocomplete-results/search-results.component.ts index 52313135..43204f7a 100644 --- a/projects/srm/src/app/autocomplete-results/search-results.component.ts +++ b/projects/srm/src/app/autocomplete-results/search-results.component.ts @@ -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; @@ -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 { @@ -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; @@ -104,7 +113,7 @@ export class SearchResultsComponent implements OnInit, OnChanges, AfterViewInit this.resultsSubscription = null; } this.fetchQueue = new ReplaySubject(1); - this.resultsSubscription = timer(2000).pipe( + this.resultsSubscription = timer(1).pipe( switchMap(() => this.fetchQueue), filter((params) => { return params.offset > this.fetchedOffset; diff --git a/projects/srm/src/app/consts.ts b/projects/srm/src/app/consts.ts index 7679d335..4090d7ae 100644 --- a/projects/srm/src/app/consts.ts +++ b/projects/srm/src/app/consts.ts @@ -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 { diff --git a/projects/srm/src/app/page/page.component.less b/projects/srm/src/app/page/page.component.less index e8b14bde..99c4d383 100644 --- a/projects/srm/src/app/page/page.component.less +++ b/projects/srm/src/app/page/page.component.less @@ -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; diff --git a/projects/srm/src/app/page/page.component.ts b/projects/srm/src/app/page/page.component.ts index 96da5b2b..c5f56824 100644 --- a/projects/srm/src/app/page/page.component.ts +++ b/projects/srm/src/app/page/page.component.ts @@ -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) => { diff --git a/projects/srm/src/app/results-drawer/results-drawer.component.less b/projects/srm/src/app/results-drawer/results-drawer.component.less index eb09a68b..4d786cd0 100644 --- a/projects/srm/src/app/results-drawer/results-drawer.component.less +++ b/projects/srm/src/app/results-drawer/results-drawer.component.less @@ -225,6 +225,7 @@ overscroll-behavior-y: none; .no-scrollbars; flex: 1 1 auto; + z-index: 0; } .mobile({