Fix publish topic update
This commit is contained in:
@@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ class Publish extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
this.props.actions.publish(this.props.connectionId)
|
||||
const topic = this.currentTopic() || ''
|
||||
const payload = this.props.payload
|
||||
|
||||
const topic = this.props.topic || ''
|
||||
const payload = this.props.payload
|
||||
if (this.props.connectionId && topic) {
|
||||
this.addMessageToHistory(topic, payload)
|
||||
}
|
||||
@@ -100,19 +100,12 @@ class Publish extends React.Component<Props, State> {
|
||||
)
|
||||
}
|
||||
|
||||
private currentTopic(): string | undefined {
|
||||
const { node, topic } = this.props
|
||||
const selectedNodePath = (node ? node.path() : undefined)
|
||||
|
||||
return (topic !== undefined) ? topic : selectedNodePath
|
||||
}
|
||||
|
||||
private clearTopic = () => {
|
||||
this.props.actions.setTopic('')
|
||||
}
|
||||
|
||||
private topic() {
|
||||
const topicStr = this.currentTopic() || ''
|
||||
const topicStr = this.props.topic || ''
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user