Deselect message history message when topic selection changes

Fixes #93
This commit is contained in:
Thomas Nordquist
2019-04-15 16:45:58 +02:00
parent d24dc41024
commit 38819b0e0a
5 changed files with 70 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import * as q from '../../../backend/src/Model'
import { Dispatch } from 'redux'
import { ActionTypes } from '../reducers/Sidebar'
import { AppState } from '../reducers'
import { Dispatch } from 'redux'
import { makePublishEvent, rendererEvents } from '../../../events'
export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () => AppState) => {
@@ -12,6 +13,13 @@ export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () =
dispatch(clearTopic(selectedTopic, false))
}
export const setCompareMessage = (message?: q.Message) => (dispatch: Dispatch<any>) => {
dispatch({
message,
type: ActionTypes.SIDEBAR_SET_COMPARE_MESSAGE,
})
}
export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicClearLimit = 50) => (dispatch: Dispatch<any>, getState: () => AppState) => {
const { connectionId } = getState().connection
if (!connectionId) {
@@ -25,7 +33,6 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicC
retain: true,
qos: 0 as 0,
}
console.log('deleting', topic.path())
rendererEvents.emit(publishEvent, mqttMessage)
if (recursive) {

View File

@@ -1,5 +1,6 @@
import * as q from '../../../backend/src/Model'
import { ActionTypes } from '../reducers/Tree'
import { ActionTypes as SidebarActionTypes } from '../reducers/Sidebar'
import { AnyAction, Dispatch } from 'redux'
import { AppState } from '../reducers'
import { batchActions } from 'redux-batched-actions'
@@ -40,6 +41,11 @@ const debouncedSelectTopic = debounce((topic: q.TreeNode<TopicViewModel>, dispat
type: ActionTypes.TREE_SELECT_TOPIC,
}
dispatch({
type: SidebarActionTypes.SIDEBAR_SET_COMPARE_MESSAGE,
message: undefined,
})
if (setTopicDispatch) {
dispatch(batchActions([selectTreeTopicDispatch, setTopicDispatch]))
} else {