Avoids extra request for repository level filters. #824.

This commit is contained in:
mateuswetah 2023-11-13 16:36:11 -03:00
parent ef654c3000
commit 3b6243b00c
1 changed files with 19 additions and 25 deletions

View File

@ -410,7 +410,7 @@
this.isLoadingFilters = true; this.isLoadingFilters = true;
// Normal filter loading, only collection ones // Normal filter loading, only collection ones
if ( !this.taxonomy ) { if ( !this.taxonomy && !this.isRepositoryLevel ) {
this.fetchFilters({ this.fetchFilters({
collectionId: this.collectionId, collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel, isRepositoryLevel: this.isRepositoryLevel,
@ -419,29 +419,7 @@
}) })
.then((resp) => { .then((resp) => {
resp.request resp.request
.then(() => { .then(() => this.isLoadingFilters = false)
if ( !this.isRepositoryLevel )
this.isLoadingFilters = false;
// On repository level we also fetch collection filters
else {
// Cancels previous Request
if (this.repositoryFiltersSearchCancel != undefined)
this.repositoryFiltersSearchCancel.cancel('Repository Collection Filters search Canceled.');
this.fetchRepositoryCollectionFilters()
.then((anotherResp) => {
anotherResp.request
.then(() => this.isLoadingFilters = false)
.catch(() => this.isLoadingFilters = false);
this.repositoryFiltersSearchCancel = anotherResp.source;
})
.catch(() => this.isLoadingFilters = false);
}
})
.catch(() => this.isLoadingFilters = false); .catch(() => this.isLoadingFilters = false);
// Search Request Token for cancelling // Search Request Token for cancelling
@ -450,7 +428,7 @@
.catch(() => this.isLoadingFilters = false); .catch(() => this.isLoadingFilters = false);
// Custom filter loading, get's from collections that have items with that taxonomy // Custom filter loading, get's from collections that have items with that taxonomy
} else { } else if ( this.taxonomy ) {
let collectionsIds = []; let collectionsIds = [];
@ -467,6 +445,22 @@
this.fetchTaxonomyFilters({ taxonomyId: taxonomyId[taxonomyId.length - 1], collectionsIds: collectionsIds }) this.fetchTaxonomyFilters({ taxonomyId: taxonomyId[taxonomyId.length - 1], collectionsIds: collectionsIds })
.catch(() => this.isLoadingFilters = false); .catch(() => this.isLoadingFilters = false);
} else if ( this.isRepositoryLevel && !this.taxonomy ) {
// Cancels previous Request
if (this.repositoryFiltersSearchCancel != undefined)
this.repositoryFiltersSearchCancel.cancel('Repository Collection Filters search Canceled.');
this.fetchRepositoryCollectionFilters()
.then((anotherResp) => {
anotherResp.request
.then(() => this.isLoadingFilters = false)
.catch(() => this.isLoadingFilters = false);
this.repositoryFiltersSearchCancel = anotherResp.source;
})
.catch(() => this.isLoadingFilters = false);
} }
}, },