Avoids extra request for repository level filters. #824.
This commit is contained in:
parent
ef654c3000
commit
3b6243b00c
|
@ -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,38 +419,16 @@
|
||||||
})
|
})
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
resp.request
|
resp.request
|
||||||
.then(() => {
|
|
||||||
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)
|
.then(() => this.isLoadingFilters = false)
|
||||||
.catch(() => this.isLoadingFilters = false);
|
.catch(() => this.isLoadingFilters = false);
|
||||||
|
|
||||||
this.repositoryFiltersSearchCancel = anotherResp.source;
|
|
||||||
})
|
|
||||||
.catch(() => this.isLoadingFilters = false);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(() => this.isLoadingFilters = false);
|
|
||||||
|
|
||||||
// Search Request Token for cancelling
|
// Search Request Token for cancelling
|
||||||
this.filtersSearchCancel = resp.source;
|
this.filtersSearchCancel = resp.source;
|
||||||
})
|
})
|
||||||
.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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue