mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 1821: Refactor getCachedData method to be asynchronous and improve cache handling
Refactor getCachedData method to be asynchronous and improve cache handling
This commit is contained in:
committed by
Lorenz Hilpert
parent
9ba05253e9
commit
34e96f0751
@@ -166,6 +166,7 @@ export class ArticleSearchResultsComponent implements OnInit, OnDestroy, AfterVi
|
||||
if (!isEqual(cleanQueryParams, this.cleanupQueryParams(this.searchService.filter.getQueryParams()))) {
|
||||
await this.searchService.setDefaultFilter(queryParams);
|
||||
const data = await this.getCachedData(processId, queryParams, selectedBranch?.id);
|
||||
|
||||
if (data.items?.length > 0) {
|
||||
this.searchService.setItems(data.items);
|
||||
this.searchService.setHits(data.hits);
|
||||
@@ -392,15 +393,14 @@ export class ArticleSearchResultsComponent implements OnInit, OnDestroy, AfterVi
|
||||
});
|
||||
}
|
||||
|
||||
getCachedData(processId: number, params: Record<string, string> = {}, branchId: number) {
|
||||
async getCachedData(processId: number, params: Record<string, string> = {}, branchId: number) {
|
||||
const qparams = this.cleanupQueryParams({ ...params, processId: String(processId), branchId: String(branchId) });
|
||||
const cacheData = await this.cache.get<{
|
||||
items: ItemDTO[];
|
||||
hits: number;
|
||||
}>(qparams);
|
||||
|
||||
return (
|
||||
this.cache.get<{
|
||||
items: ItemDTO[];
|
||||
hits: number;
|
||||
}>(qparams) || { items: [], hits: 0 }
|
||||
);
|
||||
return cacheData ?? { items: [], hits: 0 };
|
||||
}
|
||||
|
||||
cleanupQueryParams(params: Record<string, string> = {}) {
|
||||
|
||||
Reference in New Issue
Block a user