fix: handle PR

This commit is contained in:
EnixCoda 2020-10-27 02:30:39 +08:00
parent 391c3e457c
commit 3115f78878
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
2 changed files with 10 additions and 19 deletions

View file

@ -61,17 +61,21 @@ export const setUpTree: BoundMethodCreator<[
},
})
visibleNodesGenerator.onUpdate(visibleNodes => dispatch.set({ visibleNodes }))
dispatch.set({ state: 'done' })
if (platform.shouldExpandAll?.()) {
visibleNodesGenerator.visibleNodes.nodes.forEach(node =>
dispatch.call(toggleNodeExpansion, node, { recursive: true }),
)
const unsubscribe = visibleNodesGenerator.onUpdate(visibleNodes => {
unsubscribe()
visibleNodes.nodes.forEach(node =>
dispatch.call(toggleNodeExpansion, node, { recursive: true }),
)
})
dispatch.call(search, '')
} else {
const targetPath = platform.getCurrentPath(metaData.branchName)
if (targetPath) dispatch.call(goTo, targetPath)
else dispatch.call(search, '')
}
dispatch.set({ state: 'done' })
}
export const handleKeyDown: BoundMethodCreator<[React.KeyboardEvent]> = dispatch => event => {

View file

@ -151,23 +151,10 @@ export const GitHub: Platform = {
url: `https://${window.location.host}/${metaData.userName}/${
metaData.repoName
}/pull/${pullId}/files${window.location.search}#${id || ''}`,
contents: undefined,
sha: item.sha,
}
})
const missingFolders = findMissingFolders(nodes)
nodes.push(
...missingFolders.map(
folder =>
({
name: folder.replace(/^.*\//, ''),
path: folder,
type: 'tree',
} as TreeNode),
),
)
const root = processTree(nodes)
return { root }
}