mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
feat: expand all folders when in pr
This commit is contained in:
parent
0515d3cb2d
commit
e2aee2cdd6
3 changed files with 14 additions and 3 deletions
|
|
@ -68,11 +68,18 @@ export const setUpTree: BoundMethodCreator<[
|
|||
})
|
||||
|
||||
visibleNodesGenerator.init()
|
||||
|
||||
tasksAfterRender.push(DOMHelper.focusSearchInput)
|
||||
dispatch.set({ state: 'done' })
|
||||
const targetPath = platform.getCurrentPath(metaData.branchName)
|
||||
if (targetPath) dispatch.call(goTo, targetPath)
|
||||
|
||||
if (platform.shouldExpandAll?.()) {
|
||||
visibleNodesGenerator.visibleNodes.nodes.forEach(node =>
|
||||
dispatch.call(toggleNodeExpansion, node, { skipScrollToNode: true, recursive: true }),
|
||||
)
|
||||
dispatch.call(updateVisibleNodes)
|
||||
} else {
|
||||
const targetPath = platform.getCurrentPath(metaData.branchName)
|
||||
if (targetPath) dispatch.call(goTo, targetPath)
|
||||
}
|
||||
}
|
||||
|
||||
export const execAfterRender: BoundMethodCreator = dispatch => () => {
|
||||
|
|
|
|||
|
|
@ -203,6 +203,9 @@ export const GitHub: Platform = {
|
|||
shouldShow() {
|
||||
return Boolean(DOMHelper.isInCodePage() || URLHelper.isInPullPage())
|
||||
},
|
||||
shouldExpandAll() {
|
||||
return Boolean(URLHelper.isInPullPage())
|
||||
},
|
||||
getCurrentPath(branchName) {
|
||||
return URLHelper.getCurrentPath(branchName)
|
||||
},
|
||||
|
|
|
|||
1
src/platforms/platform.d.ts
vendored
1
src/platforms/platform.d.ts
vendored
|
|
@ -7,6 +7,7 @@ type Platform = {
|
|||
): Promise<Pick<MetaData, 'userUrl' | 'repoUrl' | 'defaultBranchName'>>
|
||||
getTreeData(metaData: MetaData, accessToken?: string): Promise<TreeNode>
|
||||
shouldShow(): boolean
|
||||
shouldExpandAll?(): boolean
|
||||
getCurrentPath(branchName: string): string[] | null
|
||||
setOAuth(code: string): Promise<string | null>
|
||||
getOAuthLink(): string
|
||||
|
|
|
|||
Loading…
Reference in a new issue