mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor(DOM helper): move decorateGitHubPageContent
This commit is contained in:
parent
7efced17e5
commit
3bf8d6f767
2 changed files with 13 additions and 8 deletions
|
|
@ -34,7 +34,7 @@ export default class SideBar extends preact.Component {
|
|||
try {
|
||||
const metaDataFromUrl = URLHelper.parse()
|
||||
this.setState({ metaData: metaDataFromUrl })
|
||||
this.decorateGitHubPageContent()
|
||||
DOMHelper.decorateGitHubPageContent()
|
||||
const accessToken = await storageHelper.getAccessToken()
|
||||
this.setState({ hasAccessToken: !!accessToken })
|
||||
const metaDataFromAPI = await GitHubHelper.getRepoMeta({ ...metaDataFromUrl, accessToken })
|
||||
|
|
@ -76,19 +76,13 @@ export default class SideBar extends preact.Component {
|
|||
const { metaData } = this.state
|
||||
this.setState({ loading: false })
|
||||
this.setShouldShow(URLHelper.isInCodePage(metaData))
|
||||
this.decorateGitHubPageContent()
|
||||
DOMHelper.decorateGitHubPageContent()
|
||||
DOMHelper.scrollToRepoContent()
|
||||
DOMHelper.focusSearchInput()
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
decorateGitHubPageContent() {
|
||||
DOMHelper.attachCopyFileBtn()
|
||||
DOMHelper.attachCopySnippet()
|
||||
DOMHelper.attachPJAX('github')
|
||||
}
|
||||
|
||||
setShouldShow = shouldShow => {
|
||||
this.setState({ shouldShow })
|
||||
DOMHelper.setBodyIndent(shouldShow)
|
||||
|
|
|
|||
|
|
@ -288,11 +288,22 @@ function clickOnNodeElement(index = 0) {
|
|||
nodeElements[index].click()
|
||||
}
|
||||
|
||||
/**
|
||||
* a combination of few above functions
|
||||
*/
|
||||
function decorateGitHubPageContent() {
|
||||
attachPJAX('github')
|
||||
attachCopyFileBtn()
|
||||
attachCopySnippet()
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
attachPJAX,
|
||||
attachCopyFileBtn,
|
||||
attachCopySnippet,
|
||||
clickOnNodeElement,
|
||||
decorateGitHubPageContent,
|
||||
focusSearchInput,
|
||||
focusFileExplorer,
|
||||
getCurrentPageType,
|
||||
|
|
|
|||
Loading…
Reference in a new issue