forked from vikunja/frontend
fix(useOnline): only log if actually faking state (#2924)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: vikunja/frontend#2924 Co-authored-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de> Co-committed-by: Dominik Pschenitschni <dpschen@noreply.kolaente.de>
This commit is contained in:
parent
0f7b7f72d0
commit
a029887102
10
env.d.ts
vendored
10
env.d.ts
vendored
@ -1,3 +1,11 @@
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite-svg-loader" />
|
||||
/// <reference types="cypress" />
|
||||
/// <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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user