From d687a61f7df4de92f046d293336a2f320b62a2a5 Mon Sep 17 00:00:00 2001
From: esikkala <esko.ikkala@aalto.fi>
Date: Wed, 24 Feb 2021 10:59:28 +0200
Subject: [PATCH] fetchResults: add optional clearTableData param

---
 src/client/actions/index.js            | 6 ++++--
 src/client/reducers/general/helpers.js | 7 ++++---
 src/client/reducers/general/results.js | 2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/client/actions/index.js b/src/client/actions/index.js
index 160d1727..e5f48b24 100644
--- a/src/client/actions/index.js
+++ b/src/client/actions/index.js
@@ -75,14 +75,16 @@ export const fetchResults = ({
   facetClass,
   uri = null,
   limit = null,
-  optimize = null
+  optimize = null,
+  clearTableData = false
 }) => ({
   type: FETCH_RESULTS,
   resultClass,
   facetClass,
   uri,
   limit,
-  optimize
+  optimize,
+  clearTableData
 })
 export const fetchInstanceAnalysis = ({
   resultClass,
diff --git a/src/client/reducers/general/helpers.js b/src/client/reducers/general/helpers.js
index 35b7b442..6a54b990 100644
--- a/src/client/reducers/general/helpers.js
+++ b/src/client/reducers/general/helpers.js
@@ -1,13 +1,14 @@
 import { has, isEmpty } from 'lodash'
 import { UPDATE_FACET_VALUES_CONSTRAIN_SELF } from '../../actions'
 
-export const fetchResults = state => {
+export const fetchResults = (state, action) => {
+  console.log(action)
   return {
     ...state,
     instance: null,
-    instanceTableData: null,
     instanceTableExternalData: null,
-    fetching: true
+    fetching: true,
+    ...(action.clearTableData && { instanceTableData: null })
   }
 }
 
diff --git a/src/client/reducers/general/results.js b/src/client/reducers/general/results.js
index 745bf20e..fa4668a1 100644
--- a/src/client/reducers/general/results.js
+++ b/src/client/reducers/general/results.js
@@ -41,7 +41,7 @@ export const handleDataFetchingAction = (state, action) => {
     case FETCH_RESULTS:
     case FETCH_PAGINATED_RESULTS:
     case FETCH_BY_URI:
-      return fetchResults(state)
+      return fetchResults(state, action)
     case FETCH_RESULT_COUNT:
       return fetchResultCount(state)
     case FETCH_INSTANCE_ANALYSIS:
-- 
GitLab