mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 09:29:36 -05:00
1213709578
[web] migrate frontend logging to debugConsole GitOrigin-RevId: b03ff9030b03fff059738d2270bc4b4912e79f16
28 lines
1 KiB
JavaScript
28 lines
1 KiB
JavaScript
import getMeta from '../../../utils/meta'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
|
|
const hasTextEncoder = typeof TextEncoder !== 'undefined'
|
|
if (!hasTextEncoder) {
|
|
debugConsole.warn('TextEncoder is not available. Disabling pdf-caching.')
|
|
}
|
|
|
|
const isOpera =
|
|
Array.isArray(navigator.userAgentData?.brands) &&
|
|
navigator.userAgentData.brands.some(b => b.brand === 'Opera')
|
|
if (isOpera) {
|
|
debugConsole.warn('Browser cache is limited in Opera. Disabling pdf-caching.')
|
|
}
|
|
|
|
function isFlagEnabled(flag) {
|
|
if (!hasTextEncoder) return false
|
|
if (isOpera) return false
|
|
return getMeta('ol-splitTestVariants')?.[flag] === 'enabled'
|
|
}
|
|
|
|
export const cachedUrlLookupEnabled = isFlagEnabled(
|
|
'pdf-caching-cached-url-lookup'
|
|
)
|
|
export const prefetchingEnabled = isFlagEnabled('pdf-caching-prefetching')
|
|
export const prefetchLargeEnabled = isFlagEnabled('pdf-caching-prefetch-large')
|
|
export const enablePdfCaching = isFlagEnabled('pdf-caching-mode')
|
|
export const trackPdfDownloadEnabled = isFlagEnabled('track-pdf-download')
|