mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
handle rejected promises in pdf viewer
This commit is contained in:
parent
182dfabbae
commit
b4f527b099
1 changed files with 17 additions and 4 deletions
|
@ -59,7 +59,8 @@ define [
|
||||||
# console.log 'resolved q.all, page size is', result
|
# console.log 'resolved q.all, page size is', result
|
||||||
$scope.numPages = result.numPages
|
$scope.numPages = result.numPages
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
$scope.$emit 'pdf:error', 'loading initial document parameters'
|
$scope.$emit 'pdf:error', error
|
||||||
|
return $q.reject(error)
|
||||||
|
|
||||||
@setScale = (scale, containerHeight, containerWidth) ->
|
@setScale = (scale, containerHeight, containerWidth) ->
|
||||||
$scope.loaded.then () ->
|
$scope.loaded.then () ->
|
||||||
|
@ -87,6 +88,9 @@ define [
|
||||||
numScale * $scope.pdfPageSize[1]
|
numScale * $scope.pdfPageSize[1]
|
||||||
]
|
]
|
||||||
# console.log 'in setScale result', $scope.scale.scale, $scope.defaultPageSize
|
# console.log 'in setScale result', $scope.scale.scale, $scope.defaultPageSize
|
||||||
|
.catch (error) ->
|
||||||
|
$scope.$emit 'pdf:error', error
|
||||||
|
return $q.reject(error)
|
||||||
|
|
||||||
@redraw = (position) ->
|
@redraw = (position) ->
|
||||||
# console.log 'in redraw'
|
# console.log 'in redraw'
|
||||||
|
@ -302,6 +306,10 @@ define [
|
||||||
spinner.remove(element)
|
spinner.remove(element)
|
||||||
ctrl.redraw(origposition)
|
ctrl.redraw(origposition)
|
||||||
$timeout renderVisiblePages
|
$timeout renderVisiblePages
|
||||||
|
scope.loadSuccess = true
|
||||||
|
.catch (error) ->
|
||||||
|
scope.$emit 'pdf:error', error
|
||||||
|
return $q.reject(error)
|
||||||
|
|
||||||
elementTimer = null
|
elementTimer = null
|
||||||
spinnerTimer = null
|
spinnerTimer = null
|
||||||
|
@ -364,9 +372,13 @@ define [
|
||||||
if scope.loadCount > 3 || error.match(/^Missing PDF/i) || error.match(/^loading/i)
|
if scope.loadCount > 3 || error.match(/^Missing PDF/i) || error.match(/^loading/i)
|
||||||
scope.$emit 'pdf:error:display'
|
scope.$emit 'pdf:error:display'
|
||||||
return
|
return
|
||||||
ctrl.load()
|
if scope.loadSuccess
|
||||||
# trigger a redraw
|
ctrl.load()
|
||||||
scope.scale = angular.copy (scope.scale)
|
# trigger a redraw
|
||||||
|
scope.scale = angular.copy (scope.scale)
|
||||||
|
else
|
||||||
|
scope.$emit 'pdf:error:display'
|
||||||
|
return
|
||||||
|
|
||||||
scope.$on 'pdf:page:size-change', (event, pageNum, delta) ->
|
scope.$on 'pdf:page:size-change', (event, pageNum, delta) ->
|
||||||
#console.log 'page size change event', pageNum, delta
|
#console.log 'page size change event', pageNum, delta
|
||||||
|
@ -400,6 +412,7 @@ define [
|
||||||
# console.log 'loading pdf', newVal, oldVal
|
# console.log 'loading pdf', newVal, oldVal
|
||||||
return unless newVal?
|
return unless newVal?
|
||||||
scope.loadCount = 0; # new pdf, so reset load count
|
scope.loadCount = 0; # new pdf, so reset load count
|
||||||
|
scope.loadSuccess = false
|
||||||
ctrl.load()
|
ctrl.load()
|
||||||
# trigger a redraw
|
# trigger a redraw
|
||||||
scope.scale = angular.copy (scope.scale)
|
scope.scale = angular.copy (scope.scale)
|
||||||
|
|
Loading…
Reference in a new issue