Fix publish topic update

This commit is contained in:
Thomas Nordquist
2019-01-20 12:47:46 +01:00
parent fa9def4dd7
commit 4d794205d5
2 changed files with 16 additions and 14 deletions

View File

@@ -1,9 +1,18 @@
import { ActionTypes, CustomAction } from '../reducers'
import { ActionTypes, CustomAction, AppState } from '../reducers'
import * as q from '../../../backend/src/Model'
import { Dispatch } from 'redux'
import { setTopic } from './Publish'
export const selectTopic = (topic: q.TreeNode): CustomAction => {
return {
export const selectTopic = (topic: q.TreeNode) => (dispatch: Dispatch<any>, getState: () => AppState) => {
const { selectedTopic } = getState().tooBigReducer
// Update publish topic
if (selectedTopic && (selectedTopic.path() === getState().publish.topic || !getState().publish.topic)) {
dispatch(setTopic(topic.path()))
}
dispatch({
selectedTopic: topic,
type: ActionTypes.selectTopic,
}
})
}