Merge pull request #4279 from overleaf/bg-revert-async-apply-in-pdfcontroller

revert async apply in PdfController

GitOrigin-RevId: 20628ca8c9ba06528271e1323ba062d6b563e08e
This commit is contained in:
Jakob Ackermann 2021-06-29 11:54:54 +02:00 committed by Copybot
parent 103873a013
commit 343ab44172
2 changed files with 32 additions and 47 deletions

View file

@ -357,6 +357,9 @@ If the project has been renamed please look in your project list for a new proje
x => x[1]
)
// Allow service worker to be removed via the websocket
ide.$scope.$on('service-worker:unregister', unregisterServiceWorker)
return ide.socket.on('project:publicAccessLevel:changed', data => {
if (data.newAccessLevel != null) {
ide.$scope.project.publicAccesLevel = data.newAccessLevel
@ -369,7 +372,7 @@ If the project has been renamed please look in your project list for a new proje
if (getMeta('ol-resetServiceWorker')) {
unregisterServiceWorker()
} else if (getMeta('ol-enablePdfCaching')) {
loadServiceWorker({ timeout: 5000 })
loadServiceWorker()
}
export default angular.bootstrap(document.body, ['SharelatexApp'])

View file

@ -6,10 +6,6 @@ import { react2angular } from 'react2angular'
import { rootContext } from '../../../shared/context/root-context'
import 'ace/ace'
import getMeta from '../../../utils/meta'
import {
waitForServiceWorker,
unregisterServiceWorker,
} from '../../pdfng/directives/serviceWorkerManager'
import { trackPdfDownload } from './PdfJsMetrics'
const AUTO_COMPILE_MAX_WAIT = 5000
@ -275,12 +271,6 @@ App.controller(
}
})
const serviceWorker = getMeta('ol-enablePdfCaching')
? waitForServiceWorker()
: Promise.resolve()
ide.$scope.$on('service-worker:unregister', unregisterServiceWorker)
function sendCompileRequest(options) {
if (options == null) {
options = {}
@ -321,8 +311,7 @@ App.controller(
checkType = 'silent'
}
return serviceWorker.then(() =>
$http.post(
return $http.post(
url,
{
rootDoc_id: options.rootDocOverride_id || null,
@ -335,7 +324,6 @@ App.controller(
},
{ params }
)
)
}
function buildPdfDownloadUrl(pdfDownloadDomain, url) {
@ -832,15 +820,12 @@ App.controller(
.then(function (response) {
const { data } = response
const compileTimeClientE2E = performance.now() - t0
$scope.$applyAsync(() => {
$scope.pdf.view = 'pdf'
$scope.pdf.compiling = false
parseCompileResponse(data, compileTimeClientE2E)
})
})
.catch(function (response) {
const { status } = response
$scope.$applyAsync(() => {
if (status === 429) {
$scope.pdf.rateLimited = true
}
@ -854,12 +839,9 @@ App.controller(
$scope.pdf.compileFailed = true
}
})
})
.finally(() => {
$scope.$applyAsync(() => {
$scope.lastFinishedCompileAt = Date.now()
})
})
}
// This needs to be public.