mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor(FileExplorer): split logic of setting up tree data
This commit is contained in:
parent
f75eeadc4f
commit
0b3cc7f61a
2 changed files with 11 additions and 8 deletions
|
|
@ -37,8 +37,9 @@ export default class FileExplorer extends React.Component {
|
|||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { init } = this.props
|
||||
const { init, setUpTree, treeData } = this.props
|
||||
init()
|
||||
setUpTree(treeData)
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
|
|
@ -48,8 +49,8 @@ export default class FileExplorer extends React.Component {
|
|||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (nextProps.treeData !== this.props.treeData) {
|
||||
const { init } = nextProps
|
||||
init()
|
||||
const { setUpTree } = nextProps
|
||||
setUpTree()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ function getVisibleParentNode(nodes, focusedNode, depths) {
|
|||
const tasksAfterRender = []
|
||||
const visibleNodesGenerator = new VisibleNodesGenerator()
|
||||
|
||||
const init = dispatch => () => dispatch(async (state, { treeData, metaData, compressSingletonFolder }) => {
|
||||
if (!treeData) {
|
||||
dispatch(setStateText, 'Fetching Tree Data...')
|
||||
return
|
||||
}
|
||||
const init = dispatch => () => dispatch(async () => {
|
||||
dispatch(setStateText, 'Fetching File List...')
|
||||
})
|
||||
|
||||
const setUpTree = dispatch => () => dispatch(async (state, { treeData, metaData, compressSingletonFolder }) => {
|
||||
if (!treeData) return
|
||||
dispatch(setStateText, 'Rendering File List...')
|
||||
const { root } = treeParser.parse(treeData, metaData)
|
||||
visibleNodesGenerator.setCompress(compressSingletonFolder)
|
||||
|
|
@ -225,6 +226,7 @@ const updateVisibleNodes = dispatch => () => {
|
|||
|
||||
export default {
|
||||
init,
|
||||
setUpTree,
|
||||
execAfterRender,
|
||||
setStateText,
|
||||
handleKeyDown,
|
||||
|
|
|
|||
Loading…
Reference in a new issue