mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-07 20:02:42 +00:00
catch errors in pdf viewer and reload if necessary
if more than 3 reloads, display error to the user
This commit is contained in:
parent
7f750ae692
commit
bf8bc27de0
2 changed files with 15 additions and 1 deletions
|
@ -10,6 +10,9 @@ define [
|
|||
$scope.recompile(isAutoCompile: true)
|
||||
$scope.hasPremiumCompile = $scope.project.features.compileGroup == "priority"
|
||||
|
||||
$scope.$on "pdf:error:display", () ->
|
||||
$scope.pdf.error = true
|
||||
|
||||
sendCompileRequest = (options = {}) ->
|
||||
url = "/project/#{$scope.project_id}/compile"
|
||||
if options.isAutoCompile
|
||||
|
|
|
@ -25,7 +25,7 @@ define [
|
|||
# $scope.pages = []
|
||||
|
||||
$scope.document.destroy() if $scope.document?
|
||||
|
||||
scope.loadCount = scope.loadCount? ? scope.loadCount + 1 : 1
|
||||
# TODO need a proper url manipulation library to add to query string
|
||||
$scope.document = new PDFRenderer($scope.pdfSrc + '&pdfng=true' , {
|
||||
scale: 1,
|
||||
|
@ -293,6 +293,16 @@ define [
|
|||
]
|
||||
#scope.$apply()
|
||||
|
||||
scope.$on 'pdf:error', (event, error) ->
|
||||
return if error == 'cancelled'
|
||||
# check if too many retries or file is missing
|
||||
if scope.loadCount > 3 || error.match(/^Missing PDF/i)
|
||||
scope.$emit 'pdf:error:display'
|
||||
return
|
||||
ctrl.load()
|
||||
# trigger a redraw
|
||||
scope.scale = angular.copy (scope.scale)
|
||||
|
||||
element.on 'scroll', () ->
|
||||
#console.log 'scroll event', element.scrollTop(), 'adjusting?', scope.adjustingScroll
|
||||
if scope.adjustingScroll
|
||||
|
@ -317,6 +327,7 @@ define [
|
|||
scope.$watch 'pdfSrc', (newVal, oldVal) ->
|
||||
# console.log 'loading pdf', newVal, oldVal
|
||||
return unless newVal?
|
||||
scope.loadCount = 0; # new pdf, so reset load count
|
||||
ctrl.load()
|
||||
# trigger a redraw
|
||||
scope.scale = angular.copy (scope.scale)
|
||||
|
|
Loading…
Add table
Reference in a new issue