mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
refactor: move use progress bar
Independent from platform
This commit is contained in:
parent
1d1724ae84
commit
dca643f4e5
4 changed files with 15 additions and 14 deletions
|
|
@ -14,7 +14,6 @@ import { run } from 'utils/general'
|
|||
import { useCatchNetworkError } from 'utils/hooks/useCatchNetworkError'
|
||||
import { useLoadedContext } from 'utils/hooks/useLoadedContext'
|
||||
import { loadWithPJAX, useOnPJAXDone, usePJAX } from 'utils/hooks/usePJAX'
|
||||
import { useProgressBar } from 'utils/hooks/useProgressBar'
|
||||
import { useStateIO } from 'utils/hooks/useStateIO'
|
||||
import { SideBarErrorContext } from '../containers/ErrorContext'
|
||||
import { RepoContext } from '../containers/RepoContext'
|
||||
|
|
@ -98,7 +97,6 @@ export function SideBar() {
|
|||
platform.usePlatformHooks?.()
|
||||
|
||||
usePJAX()
|
||||
useProgressBar()
|
||||
|
||||
// Hide sidebar when error due to auth but token is set #128
|
||||
const hideSidebarOnInvalidToken: boolean =
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { resolveGitModules } from 'utils/gitSubmodule'
|
||||
import { useProgressBar } from 'utils/hooks/useProgressBar'
|
||||
import { sortFoldersToFront } from 'utils/treeParser'
|
||||
import * as API from './API'
|
||||
import * as DOMHelper from './DOMHelper'
|
||||
|
|
@ -169,4 +170,7 @@ export const Gitea: Platform = {
|
|||
getOAuthLink() {
|
||||
return `${window.location.protocol}//${window.location.host}/api/v1/user/applications/oauth2`
|
||||
},
|
||||
usePlatformHooks() {
|
||||
useProgressBar()
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { platform } from 'platforms'
|
|||
import * as React from 'react'
|
||||
import { resolveGitModules } from 'utils/gitSubmodule'
|
||||
import { useOnPJAXDone } from 'utils/hooks/usePJAX'
|
||||
import { useProgressBar } from 'utils/hooks/useProgressBar'
|
||||
import { sortFoldersToFront } from 'utils/treeParser'
|
||||
import * as API from './API'
|
||||
import * as DOMHelper from './DOMHelper'
|
||||
|
|
@ -174,6 +175,9 @@ export const Gitee: Platform = {
|
|||
setOAuth(code) {
|
||||
return API.OAuth(code)
|
||||
},
|
||||
usePlatformHooks() {
|
||||
useProgressBar()
|
||||
},
|
||||
}
|
||||
|
||||
export function useGiteeAttachCopySnippetButton(copySnippetButton: boolean) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import * as NProgress from 'nprogress'
|
||||
import { platform } from 'platforms'
|
||||
import { GitHub } from 'platforms/GitHub'
|
||||
import * as React from 'react'
|
||||
import { useEvent } from 'react-use'
|
||||
|
||||
|
|
@ -13,14 +11,11 @@ const progressBar = {
|
|||
},
|
||||
}
|
||||
|
||||
const isGitHub = platform === GitHub
|
||||
// use native progress bar on GitHub
|
||||
export const useProgressBar = isGitHub
|
||||
? function () {}
|
||||
: function useProgressBar() {
|
||||
React.useEffect(() => {
|
||||
NProgress.configure({ showSpinner: false })
|
||||
}, [])
|
||||
useEvent('pjax:fetch', progressBar.mount, window)
|
||||
useEvent('pjax:unload', progressBar.unmount, window)
|
||||
}
|
||||
export function useProgressBar() {
|
||||
React.useEffect(() => {
|
||||
NProgress.configure({ showSpinner: false })
|
||||
}, [])
|
||||
useEvent('pjax:fetch', progressBar.mount, window)
|
||||
useEvent('pjax:unload', progressBar.unmount, window)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue