fix(useOnline): only log if actually faking state
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
b71d41c5ec
commit
3c0b50da67
|
@ -1,3 +1,11 @@
|
|||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-svg-loader" />
|
||||
/// <reference types="cypress" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_IS_ONLINE: boolean
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
|
@ -3,12 +3,11 @@ import {useOnline as useNetworkOnline} from '@vueuse/core'
|
|||
import type {ConfigurableWindow} from '@vueuse/core'
|
||||
|
||||
export function useOnline(options?: ConfigurableWindow) {
|
||||
const isOnline = useNetworkOnline(options)
|
||||
const fakeOnlineState = !!import.meta.env.VITE_IS_ONLINE
|
||||
if (fakeOnlineState) {
|
||||
if (isOnline.value === false && fakeOnlineState) {
|
||||
console.log('Setting fake online state', fakeOnlineState)
|
||||
return ref(true)
|
||||
}
|
||||
|
||||
return fakeOnlineState
|
||||
? ref(true)
|
||||
: useNetworkOnline(options)
|
||||
return isOnline
|
||||
}
|
Reference in New Issue