mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-11 15:56:44 -05:00
aeade59677
[web] pdf-caching: disable pdf-caching in Opera browser GitOrigin-RevId: 8c0cefc4fa4fccd74c58649c000be14643788514
27 lines
970 B
JavaScript
27 lines
970 B
JavaScript
import getMeta from '../../../utils/meta'
|
|
|
|
const hasTextEncoder = typeof TextEncoder !== 'undefined'
|
|
if (!hasTextEncoder) {
|
|
console.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) {
|
|
console.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')
|