feat: overwrite header style more aggressive

This commit is contained in:
EnixCoda 2019-11-21 14:32:15 +08:00
parent 619d18a6bb
commit 8138a0539a
No known key found for this signature in database
GPG key ID: FE06F5DFC1C9B8E4
2 changed files with 7 additions and 3 deletions

View file

@ -53,6 +53,7 @@ export const init: BoundMethodCreator = dispatch => async () => {
dispatch.set({ disabled: true })
return
}
DOMHelper.markGitakoReadyState(true)
dispatch.set({
errorDueToAuth: false,
showSettings: false,
@ -120,7 +121,6 @@ export const init: BoundMethodCreator = dispatch => async () => {
const shouldShow =
intelligentToggle === null ? URLHelper.isInCodePage(metaData) : intelligentToggle
dispatch.call(setShouldShow, shouldShow)
DOMHelper.markGitakoReadyState()
} catch (err) {
dispatch.call(handleError, err)
} finally {
@ -141,6 +141,7 @@ export const handleError: BoundMethodCreator<[Error]> = dispatch => async err =>
dispatch.set({ errorDueToAuth: true })
dispatch.call(setShowSettings, true)
} else {
DOMHelper.markGitakoReadyState(false)
dispatch.call(setError, 'Gitako ate a bug, but it should recovery soon!')
throw err
}

View file

@ -13,10 +13,13 @@ NProgress.configure({ showSpinner: false })
/**
* when gitako is ready, make page's header narrower
* or cancel it
*/
export function markGitakoReadyState() {
export function markGitakoReadyState(ready: boolean) {
const readyClassName = 'gitako-ready'
document.body.classList.add(readyClassName)
const classList = document.body.classList
if (ready) classList.add(readyClassName)
else classList.remove(readyClassName)
}
/**