mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5522 from overleaf/ae-compile-feature-flag
Only use the React compiler when showNewPdfPreview is set GitOrigin-RevId: 24bf8dc6a830e670ee8dc30b8e0329127de1a1a8
This commit is contained in:
parent
dd5bcd6098
commit
2bf422b76d
6 changed files with 20 additions and 1 deletions
|
@ -128,3 +128,4 @@ window.user = {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.project_id = 'storybook-project'
|
window.project_id = 'storybook-project'
|
||||||
|
window.showNewPdfPreview = true
|
||||||
|
|
|
@ -189,6 +189,7 @@ block append meta
|
||||||
meta(name="ol-showNewLogsUI" data-type="boolean" content=showNewLogsUI)
|
meta(name="ol-showNewLogsUI" data-type="boolean" content=showNewLogsUI)
|
||||||
meta(name="ol-logsUISubvariant" content=logsUISubvariant)
|
meta(name="ol-logsUISubvariant" content=logsUISubvariant)
|
||||||
meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
|
meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
|
||||||
|
meta(name="ol-showNewPdfPreview" data-type="boolean" content=showNewPdfPreview)
|
||||||
meta(name="ol-enablePdfCaching" data-type="boolean" content=enablePdfCaching)
|
meta(name="ol-enablePdfCaching" data-type="boolean" content=enablePdfCaching)
|
||||||
meta(name="ol-trackPdfDownload" data-type="boolean" content=trackPdfDownload)
|
meta(name="ol-trackPdfDownload" data-type="boolean" content=trackPdfDownload)
|
||||||
meta(name="ol-resetServiceWorker" data-type="boolean" content=resetServiceWorker)
|
meta(name="ol-resetServiceWorker" data-type="boolean" content=resetServiceWorker)
|
||||||
|
|
|
@ -51,6 +51,11 @@ export default class DocumentCompiler {
|
||||||
// The main "compile" function.
|
// The main "compile" function.
|
||||||
// Call this directly to run a compile now, otherwise call debouncedAutoCompile.
|
// Call this directly to run a compile now, otherwise call debouncedAutoCompile.
|
||||||
async compile(options = {}) {
|
async compile(options = {}) {
|
||||||
|
// only compile if the feature flag is enabled
|
||||||
|
if (!window.showNewPdfPreview) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// set "compiling" to true (in the React component's state), and return if it was already true
|
// set "compiling" to true (in the React component's state), and return if it was already true
|
||||||
let wasCompiling
|
let wasCompiling
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,9 @@ export function CompileProvider({ children }) {
|
||||||
|
|
||||||
// pass the "uncompiled" value up into the scope for use outside this context provider
|
// pass the "uncompiled" value up into the scope for use outside this context provider
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (window.showNewPdfPreview) {
|
||||||
setUncompiled(changedAt > 0)
|
setUncompiled(changedAt > 0)
|
||||||
|
}
|
||||||
}, [setUncompiled, changedAt])
|
}, [setUncompiled, changedAt])
|
||||||
|
|
||||||
// record changes to the autocompile setting
|
// record changes to the autocompile setting
|
||||||
|
|
|
@ -10,6 +10,14 @@ const example = pathToFileURL(
|
||||||
).toString()
|
).toString()
|
||||||
|
|
||||||
describe('<PdfJSViewer/>', function () {
|
describe('<PdfJSViewer/>', function () {
|
||||||
|
beforeEach(function () {
|
||||||
|
window.showNewPdfPreview = true
|
||||||
|
})
|
||||||
|
|
||||||
|
afterEach(function () {
|
||||||
|
window.showNewPdfPreview = undefined
|
||||||
|
})
|
||||||
|
|
||||||
it('loads all PDF pages', async function () {
|
it('loads all PDF pages', async function () {
|
||||||
renderWithEditorContext(<PdfJsViewer url={example} />)
|
renderWithEditorContext(<PdfJsViewer url={example} />)
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@ describe('<PdfPreview/>', function () {
|
||||||
var clock
|
var clock
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
|
window.showNewPdfPreview = true
|
||||||
clock = sinon.useFakeTimers({
|
clock = sinon.useFakeTimers({
|
||||||
shouldAdvanceTime: true,
|
shouldAdvanceTime: true,
|
||||||
now: Date.now(),
|
now: Date.now(),
|
||||||
|
@ -157,6 +158,7 @@ describe('<PdfPreview/>', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
|
window.showNewPdfPreview = undefined
|
||||||
clock.runAll()
|
clock.runAll()
|
||||||
clock.restore()
|
clock.restore()
|
||||||
fetchMock.reset()
|
fetchMock.reset()
|
||||||
|
|
Loading…
Reference in a new issue