Skip to content

Commit ffb342c

Browse files
committed
Reset apiCollections when encountering a link with rel type data #617
1 parent 94e18a3 commit ffb342c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/store/index.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ function getStore(config, router) {
604604
stac.setApiData(collections, nextLink);
605605
}
606606
},
607+
resetApiCollections(state) {
608+
state.apiCollections = [];
609+
state.apiItemsLoading = {};
610+
state.nextCollectionsLink = null;
611+
},
607612
resetApiItems(state, link) {
608613
state.apiItems = [];
609614
state.apiItemsLink = link;
@@ -911,16 +916,14 @@ function getStore(config, router) {
911916
async loadNextApiCollections(cx, args) {
912917
let { stac, show, noRetry } = args;
913918
let link;
914-
if (stac) {
915-
// First page
916-
if (cx.state.apiCollections.length > 0) {
917-
// If we have already loaded collections, skip loading the first page
918-
return;
919-
}
919+
if (stac) { // First page
920+
// If we load from new collections, reset list of collections.
921+
// Otherwise we may append to collections from a parent entity.
922+
// https://github.com/radiantearth/stac-browser/issues/617
923+
cx.commit('resetApiCollections');
920924
link = stac.getLinkWithRel('data');
921925
}
922-
else {
923-
// Second page and after
926+
else { // Second page and after
924927
stac = cx.state.data;
925928
link = cx.state.nextCollectionsLink;
926929
}

0 commit comments

Comments
 (0)