fix(useOnline): only log if actually faking state (#2924)
Co-authored-by: Dominik Pschenitschni <mail@celement.de> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/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/client" />
|
||||||
/// <reference types="vite-svg-loader" />
|
/// <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'
|
import type {ConfigurableWindow} from '@vueuse/core'
|
||||||
|
|
||||||
export function useOnline(options?: ConfigurableWindow) {
|
export function useOnline(options?: ConfigurableWindow) {
|
||||||
|
const isOnline = useNetworkOnline(options)
|
||||||
const fakeOnlineState = !!import.meta.env.VITE_IS_ONLINE
|
const fakeOnlineState = !!import.meta.env.VITE_IS_ONLINE
|
||||||
if (fakeOnlineState) {
|
if (isOnline.value === false && fakeOnlineState) {
|
||||||
console.log('Setting fake online state', fakeOnlineState)
|
console.log('Setting fake online state', fakeOnlineState)
|
||||||
|
return ref(true)
|
||||||
}
|
}
|
||||||
|
return isOnline
|
||||||
return fakeOnlineState
|
|
||||||
? ref(true)
|
|
||||||
: useNetworkOnline(options)
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user