From 7463aa33ca508ab6731ffbaab4c53d4e6feedda6 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Thu, 14 Feb 2019 15:40:38 +0000 Subject: [PATCH] clear tags and categories when switching to narrative --- src/components/Layout.js | 6 +++++- src/reducers/app.js | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/Layout.js b/src/components/Layout.js index 6c1ce26..7d4db2e 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -76,7 +76,11 @@ class Dashboard extends React.Component { setNarrative (narrative) { // only handleSelect if narrative is not null - if (narrative) { this.handleSelect([ narrative.steps[0] ]) } + if (narrative) { + this.props.actions.clearFilter('tags') + this.props.actions.clearFilter('categories') + this.handleSelect([ narrative.steps[0] ]) + } this.props.actions.updateNarrative(narrative) } diff --git a/src/reducers/app.js b/src/reducers/app.js index 9fc7d0d..b47db77 100644 --- a/src/reducers/app.js +++ b/src/reducers/app.js @@ -144,6 +144,15 @@ function toggleFilter (appState, action) { } } +function clearFilter (appState, action) { + return { + ...appState, + filters: { + ...appState.filters, + [action.filter]: [] + } + } +} function updateTimeRange (appState, action) { // XXX return {