From 2874bd40d901980e61c1c4dd77d693052385d54e Mon Sep 17 00:00:00 2001 From: "David J. Yu" <87633683+ddjnw1yu@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:43:17 +1200 Subject: [PATCH] Replace global variable with markRaw --- src/components/SearchFilters.vue | 5 +++-- src/components/SidebarContent.vue | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/SearchFilters.vue b/src/components/SearchFilters.vue index d1778c44..58c8ea6e 100644 --- a/src/components/SearchFilters.vue +++ b/src/components/SearchFilters.vue @@ -156,6 +156,7 @@ export default { }, data: function () { return { + algoliaClient: undefined, cascaderIsReady: false, previousShowAllChecked: { species: false, @@ -776,11 +777,11 @@ export default { }, }, mounted: function () { - this.algoliaClient = new AlgoliaClient( + this.algoliaClient = markRaw(new AlgoliaClient( this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION - ) + )) this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX) this.populateCascader().then(() => { this.cascaderIsReady = true diff --git a/src/components/SidebarContent.vue b/src/components/SidebarContent.vue index 3352cb91..b30472cb 100644 --- a/src/components/SidebarContent.vue +++ b/src/components/SidebarContent.vue @@ -78,6 +78,7 @@ import EventBus from './EventBus.js' import { AlgoliaClient } from '../algolia/algolia.js' import { getFilters, facetPropPathMapping } from '../algolia/utils.js' +import { markRaw } from 'vue' // handleErrors: A custom fetch error handler to recieve messages from the server // even when an error is found @@ -142,6 +143,7 @@ export default { data: function () { return { ...this.entry, + algoliaClient: undefined, bodyStyle: { flex: '1 1 auto', 'flex-flow': 'column', @@ -442,11 +444,11 @@ export default { }, mounted: function () { // initialise algolia - this.algoliaClient = new AlgoliaClient( + this.algoliaClient = markRaw(new AlgoliaClient( this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION - ) + )) this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX) this.openSearch(this.filter, this.searchInput) },