Debounce select topic action

This commit is contained in:
Thomas Nordquist
2019-01-25 20:57:20 +01:00
parent 98369b278a
commit 697b57a141
5 changed files with 11 additions and 5 deletions

View File

@@ -5,8 +5,13 @@ import { Dispatch, AnyAction } from 'redux'
import { setTopic } from './Publish'
import { TopicViewModel } from '../TopicViewModel'
import { batchActions } from 'redux-batched-actions'
const debounce = require('lodash.debounce')
export const selectTopic = (topic: q.TreeNode<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState) => {
debouncedSelectTopic(topic, dispatch, getState)
}
const debouncedSelectTopic = debounce((topic: q.TreeNode<TopicViewModel>, dispatch: Dispatch<any>, getState: () => AppState) => {
const { selectedTopic } = getState().tree
if (selectedTopic === topic) {
return
@@ -36,7 +41,7 @@ export const selectTopic = (topic: q.TreeNode<TopicViewModel>) => (dispatch: Dis
} else {
dispatch(selectTreeTopicDispatch)
}
}
}, 70)
export const showTree = (tree?: q.Tree<TopicViewModel>) => (dispatch: Dispatch<any>, getState: () => AppState): AnyAction => {
const visibleTree = getState().tree.tree

View File

@@ -225,7 +225,7 @@ class TreeNode extends React.Component<Props, State> {
private setHover = debounce((hover: boolean) => {
this.setState({ mouseOver: hover })
}, 5)
}, 45)
private didClickNode = (event: React.MouseEvent) => {
event.stopPropagation()