Debounce select topic action
This commit is contained in:
2
app/package-lock.json
generated
2
app/package-lock.json
generated
@@ -2301,7 +2301,7 @@
|
||||
}
|
||||
},
|
||||
"electron-telemetry": {
|
||||
"version": "git+https://github.com/thomasnordquist/electron-telemetry.git#b6bd0bd6c0f84d387e1a0c970338517a78d67717",
|
||||
"version": "git+https://github.com/thomasnordquist/electron-telemetry.git#a58a28de84874b16fb3d60ae9e83f5a94d873353",
|
||||
"from": "git+https://github.com/thomasnordquist/electron-telemetry.git",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"electron-nucleus": "^1.11.0",
|
||||
"electron-telemetry": "git+https://github.com/thomasnordquist/electron-telemetry.git",
|
||||
"html-webpack-plugin": "^4.0.0-beta.5",
|
||||
"lodash.debounce": "^4.0.8",
|
||||
"number-abbreviate": "^2.0.0",
|
||||
"react": "^16.8.0-alpha.1",
|
||||
"react-dom": "^16.7.0",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user