Skip to content

Commit

Permalink
feat(SearchBar): add a way to invalidate the cache on setting change
Browse files Browse the repository at this point in the history
  • Loading branch information
alecarn committed May 24, 2023
1 parent 870afc7 commit 1814dd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"angular.enable-strict-mode-prompt": false
}
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"cache": {
"enabled": false,
"environment": "all"
}
},
"analytics": false
}
}
13 changes: 12 additions & 1 deletion packages/geo/src/lib/search/search-bar/search-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SEARCH_TYPES } from '../shared/search.enums';
import { SearchResult, Research } from '../shared/search.interfaces';
import { SearchService } from '../shared/search.service';
import { SearchSourceService } from '../shared/search-source.service';
import { globalCacheBusterNotifier } from 'ts-cacheable';

/**
* Searchbar that triggers a research in all search sources enabled.
Expand Down Expand Up @@ -144,6 +145,11 @@ export class SearchBarComponent implements OnInit, OnDestroy {
@Input() pointerSummaryEnabled: boolean = false;
@Input() searchResultsGeometryEnabled: boolean = false;

/**
* Workaround, to invalidate the cache due to mishandling of cache settings
*/
@Input() bustCacheOnSettingChange: boolean = false;

/**
* When reverse coordinates status change
*/
Expand Down Expand Up @@ -333,8 +339,13 @@ export class SearchBarComponent implements OnInit, OnDestroy {
}

onSearchSettingsChange() {
this.doSearch(this.term);
this.searchSettingsChange.emit();

if (this.bustCacheOnSettingChange) {
globalCacheBusterNotifier.next();
}

this.doSearch(this.term);
this.handlePlaceholder();
}

Expand Down

0 comments on commit 1814dd5

Please sign in to comment.