Skip to content
Snippets Groups Projects
Commit 1438b021 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-11169 : Properties overview in the new admin UI - improve performance of...

SSDM-11169 : Properties overview in the new admin UI - improve performance of navigation browser by reducing the number of re-renders when a filter value is typed
parent cd1e3a49
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ export default class BrowserController { ...@@ -33,6 +33,7 @@ export default class BrowserController {
context.initState({ context.initState({
loaded: false, loaded: false,
filter: '', filter: '',
usedFilter: '',
nodes: [], nodes: [],
selectedId: null, selectedId: null,
selectedObject: null, selectedObject: null,
...@@ -43,12 +44,8 @@ export default class BrowserController { ...@@ -43,12 +44,8 @@ export default class BrowserController {
load() { load() {
return this.doLoadNodes().then(loadedNodes => { return this.doLoadNodes().then(loadedNodes => {
const { const { filter, nodes, selectedId, selectedObject } =
filter, this.context.getState()
nodes,
selectedId,
selectedObject
} = this.context.getState()
let newNodes = this._createNodes(loadedNodes) let newNodes = this._createNodes(loadedNodes)
newNodes = this._filterNodes(newNodes, filter) newNodes = this._filterNodes(newNodes, filter)
...@@ -64,6 +61,7 @@ export default class BrowserController { ...@@ -64,6 +61,7 @@ export default class BrowserController {
this.context.setState({ this.context.setState({
loaded: true, loaded: true,
usedFilter: filter,
nodes: newNodes nodes: newNodes
}) })
}) })
...@@ -120,35 +118,42 @@ export default class BrowserController { ...@@ -120,35 +118,42 @@ export default class BrowserController {
} }
filterChange(newFilter) { filterChange(newFilter) {
const { this.context.setState({
filter, filter: newFilter
nodes, })
selectedId,
selectedObject
} = this.context.getState()
let initialNodes = null
if (newFilter.startsWith(filter)) { if (this.filterTimerId) {
initialNodes = nodes clearTimeout(this.filterTimerId)
} else { this.filterTimerId = null
initialNodes = this.loadedNodes
} }
let newNodes = this._createNodes(initialNodes) this.filterTimerId = setTimeout(async () => {
newNodes = this._filterNodes(newNodes, newFilter) const { filter, usedFilter, nodes, selectedId, selectedObject } =
newNodes = this._setNodesExpanded( this.context.getState()
newNodes,
this._getParentNodes(newNodes),
true
)
newNodes = this._setNodesSelected(newNodes, selectedId, selectedObject)
this._sortNodes(newNodes)
this.context.setState({ let initialNodes = null
filter: newFilter,
nodes: newNodes if (filter.startsWith(usedFilter)) {
}) initialNodes = nodes
} else {
initialNodes = this.loadedNodes
}
let newNodes = this._createNodes(initialNodes)
newNodes = this._filterNodes(newNodes, newFilter)
newNodes = this._setNodesExpanded(
newNodes,
this._getParentNodes(newNodes),
true
)
newNodes = this._setNodesSelected(newNodes, selectedId, selectedObject)
this._sortNodes(newNodes)
this.context.setState({
usedFilter: filter,
nodes: newNodes
})
}, 200)
} }
nodeExpand(nodeId) { nodeExpand(nodeId) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment