mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix(pjax): prevent pjax:end event handler trigger too many times
fix #4
This commit is contained in:
parent
6b4591c9de
commit
b5865febc4
1 changed files with 14 additions and 8 deletions
|
|
@ -68,14 +68,20 @@ export default class GitakoSideBar extends preact.Component {
|
|||
this.setState({ loading: true })
|
||||
}
|
||||
|
||||
onPJAXEnd = () => {
|
||||
const { metaData } = this.state
|
||||
this.setState({ loading: false })
|
||||
this.setShouldShow(URLHelper.isInCodePage(metaData))
|
||||
this.decorateGitHubPageContent()
|
||||
DOMHelper.scrollToRepoContent()
|
||||
DOMHelper.focusSearchInput()
|
||||
}
|
||||
onPJAXEnd = (() => {
|
||||
let lastLocation
|
||||
return () => {
|
||||
if (location.href !== lastLocation) {
|
||||
lastLocation = location.href
|
||||
const { metaData } = this.state
|
||||
this.setState({ loading: false })
|
||||
this.setShouldShow(URLHelper.isInCodePage(metaData))
|
||||
this.decorateGitHubPageContent()
|
||||
DOMHelper.scrollToRepoContent()
|
||||
DOMHelper.focusSearchInput()
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
decorateGitHubPageContent() {
|
||||
DOMHelper.attachCopyFileBtn()
|
||||
|
|
|
|||
Loading…
Reference in a new issue