From 4bf054c8bd96a2f8787ef24f19d78e631cdcd1c9 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Wed, 16 Oct 2024 08:54:44 +0200 Subject: [PATCH] Potentially fix for loading collection for search inconsistently #479 #489 --- src/components/StacHeader.vue | 6 +++--- src/views/BrowseMixin.js | 6 ------ src/views/Search.vue | 8 ++++---- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/StacHeader.vue b/src/components/StacHeader.vue index af54a2dba..876f8f415 100644 --- a/src/components/StacHeader.vue +++ b/src/components/StacHeader.vue @@ -124,11 +124,11 @@ export default { if (!this.canSearch) { return null; } - let dataLink; + let searchLink; if (this.data instanceof STAC && !this.data.equals(this.root)) { - dataLink = this.data.getSearchLink(); + searchLink = this.data.getSearchLink(); } - if (dataLink) { + if (searchLink) { return `/search${this.data.getBrowserPath()}`; } else if (this.root && this.allowSelectCatalog) { diff --git a/src/views/BrowseMixin.js b/src/views/BrowseMixin.js index a9f9cc82a..f8f17bb43 100644 --- a/src/views/BrowseMixin.js +++ b/src/views/BrowseMixin.js @@ -30,12 +30,6 @@ export default { } return null; }, - created() { - // Load the root catalog data if not available (e.g. after page refresh or external access) - if (this.catalogUrl) { - this.$store.dispatch("load", { url: this.catalogUrl, loadApi: true }); - } - }, errorDescription() { if (this.error instanceof Error && this.error.isAxiosError && Utils.isObject(this.error.response)) { let res = this.error.response; diff --git a/src/views/Search.vue b/src/views/Search.vue index 91bf09f77..37bdbed2c 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -128,10 +128,10 @@ export default { return this.isCollectionSearch ? this.collectionSearch : this.itemSearch; }, collectionSearch() { - return this.canSearchCollections && this.parent instanceof STAC && this.parent.getApiCollectionsLink(); + return this.canSearchCollections && this.stac && this.stac.getApiCollectionsLink(); }, itemSearch() { - return this.canSearchItems && this.parent instanceof STAC && this.parent.getSearchLink(); + return this.canSearchItems && this.stac && this.stac.getSearchLink(); }, itemCollection() { if (this.isCollectionSearch) { @@ -191,7 +191,7 @@ export default { // so we check whether our current link has a next rel type which indicates // that it's a subsequent page. On the first pages the link rel type would be // "search" (or "prev" or "first"). This only works for forward navigation. - return this.link.rel === 'next'; + return this.link && this.link.rel === 'next'; } }, watch:{ @@ -217,7 +217,7 @@ export default { this.parent = this.root; } if (!this.parent) { - await this.$store.dispatch('load', { url }); + await this.$store.dispatch('load', { url, loadApi: true }); if (!this.root) { await this.$store.dispatch("config", { catalogUrl: url }); }