feat: prevent auto expand if GitHub native PR tree is enabled

This commit is contained in:
EnixCoda 2022-03-20 23:07:17 +08:00
parent 1e72cad644
commit 89c747206b
2 changed files with 7 additions and 2 deletions

View file

@ -27,7 +27,8 @@ export function isInRepoPage() {
export function isInCodePage() {
const branchListSelector = ['#branch-select-menu', '.branch-select-menu'].join()
return Boolean($(branchListSelector))
// The element may still exist in DOM for PR pages, but not visible
return Boolean($(branchListSelector, e => e.offsetWidth > 0 && e.offsetHeight > 0))
}
export function getIssueTitle() {
@ -259,3 +260,7 @@ export function getPath() {
.slice(1) // the first is the repo's name
return path
}
export function isNativePRFileTreeShown() {
return $('file-tree[data-target="diff-layout.fileTree"]')
}

View file

@ -168,7 +168,7 @@ export const GitHub: Platform = {
return await getRepositoryTreeData(metaData, path, recursive, accessToken)
},
shouldShow() {
return Boolean(DOMHelper.isInCodePage() || URLHelper.isInPullPage())
return Boolean(DOMHelper.isInCodePage() || (URLHelper.isInPullPage() && !DOMHelper.isNativePRFileTreeShown()))
},
shouldExpandAll() {
return Boolean(URLHelper.isInPullPage())