From 3d09eb4543c5120dd1361b9c2f8520e9fdbaee5a Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Wed, 5 Dec 2018 11:17:19 +0000 Subject: [PATCH] clean handler semantics in Dashboard.jsx, add markNotificationsRead --- src/actions/index.js | 7 +++++ src/components/CardStack.jsx | 2 +- src/components/Dashboard.jsx | 47 ++++++++++++++++---------------- src/components/Notification.jsx | 2 +- src/components/Toolbar.jsx | 4 +-- src/reducers/domain.js | 19 +++++++++++-- src/reducers/utils/validators.js | 2 +- 7 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 865612e..bbbccf9 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -256,6 +256,13 @@ export function toggleNotifications() { } } +export const MARK_NOTIFICATIONS_READ = 'MARK_NOTIFICATIONS_READ' +export function markNotificationsRead() { + return { + type: MARK_NOTIFICATIONS_READ + } +} + // ERRORS export const FETCH_SOURCE_ERROR = 'FETCH_SOURCE_ERROR' diff --git a/src/components/CardStack.jsx b/src/components/CardStack.jsx index 8c5071e..05fbddf 100644 --- a/src/components/CardStack.jsx +++ b/src/components/CardStack.jsx @@ -54,7 +54,7 @@ class CardStack extends React.Component {
this.props.onToggle('TOGGLE_CARDSTACK')} + onClick={() => this.props.onToggleCardstack()} >

diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index a0ebc67..a92bcb8 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -19,7 +19,7 @@ class Dashboard extends React.Component { this.handleHighlight = this.handleHighlight.bind(this); this.handleSelect = this.handleSelect.bind(this); - this.handleToggle = this.handleToggle.bind(this); + // this.handleToggle = this.handleToggle.bind(this); this.handleTagFilter = this.handleTagFilter.bind(this); this.updateTimerange = this.updateTimerange.bind(this); @@ -62,22 +62,22 @@ class Dashboard extends React.Component { this.props.actions.updateTimeRange(timeRange); } - handleToggle( key ) { - switch( key ) { - case 'TOGGLE_CARDSTACK': { - this.props.actions.updateSelected([]); - break; - } - case 'TOGGLE_INFOPOPUP': { - this.props.actions.toggleInfoPopup(); - break; - } - case 'TOGGLE_NOTIFICATIONS': { - this.props.actions.toggleNotifications(); - break; - } - } - } + // handleToggle( key ) { + // switch( key ) { + // case 'TOGGLE_CARDSTACK': { + // this.props.actions.updateSelected([]); + // break; + // } + // case 'TOGGLE_INFOPOPUP': { + // this.props.actions.toggleInfoPopup(); + // break; + // } + // case 'TOGGLE_NOTIFICATIONS': { + // this.props.actions.toggleNotifications(); + // break; + // } + // } + // } getCategoryColor(category='other') { return this.props.ui.style.categories[category] || this.props.style.categories['other'] @@ -100,33 +100,32 @@ class Dashboard extends React.Component { }} /> this.handleToggle(key) } + onFilter={this.handleTagFilter} actions={this.props.actions} /> this.props.actions.updateSelected([])} getNarrativeLinks={event => this.getNarrativeLinks(event)} getCategoryColor={category => this.getCategoryColor(category)} /> this.handleToggle('TOGGLE_CARDSTACK')} getCategoryColor={category => this.getCategoryColor(category)} /> this.handleToggle('TOGGLE_INFOPOPUP')} + toggle={() => this.props.actions.toggleInfoPopup()} /> this.handleToggle('TOGGLE_NOTIFICATIONS')} + onToggle={() => { + this.props.actions.toggleNotifications(); + }} /> this.toggleDetails() }>