mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #598 from sharelatex/as-improve-auto-compile-ux
Improve "infrequent edit" auto compile UX
This commit is contained in:
commit
d0b64b317f
1 changed files with 21 additions and 3 deletions
|
@ -6,6 +6,7 @@ define [
|
||||||
"services/log-hints-feedback"
|
"services/log-hints-feedback"
|
||||||
], (App, Ace, HumanReadableLogs, BibLogParser) ->
|
], (App, Ace, HumanReadableLogs, BibLogParser) ->
|
||||||
AUTO_COMPILE_TIMEOUT = 5000
|
AUTO_COMPILE_TIMEOUT = 5000
|
||||||
|
OP_ACKNOWLEDGEMENT_TIMEOUT = 1100
|
||||||
|
|
||||||
App.controller "PdfController", ($scope, $http, ide, $modal, synctex, event_tracking, logHintsFeedback, localStorage) ->
|
App.controller "PdfController", ($scope, $http, ide, $modal, synctex, event_tracking, logHintsFeedback, localStorage) ->
|
||||||
# enable per-user containers by default
|
# enable per-user containers by default
|
||||||
|
@ -74,14 +75,29 @@ define [
|
||||||
$scope.pdf.view = 'errors'
|
$scope.pdf.view = 'errors'
|
||||||
$scope.pdf.renderingError = true
|
$scope.pdf.renderingError = true
|
||||||
|
|
||||||
|
autoCompileTimeout = null
|
||||||
triggerAutoCompile = () ->
|
triggerAutoCompile = () ->
|
||||||
if (!ide.$scope.hasLintingError)
|
return if autoCompileTimeout
|
||||||
$scope.recompile(isBackgroundAutoCompile: true)
|
|
||||||
|
timeSinceLastCompile = Date.now() - $scope.recompiledAt
|
||||||
|
# If time is non-monotonic, assume that the user's system clock has been
|
||||||
|
# changed and continue with recompile
|
||||||
|
isTimeNonMonotonic = timeSinceLastPoll < 0;
|
||||||
|
|
||||||
|
if isTimeNonMonotonic || timeSinceLastCompile >= AUTO_COMPILE_TIMEOUT
|
||||||
|
if (!ide.$scope.hasLintingError)
|
||||||
|
$scope.recompile(isBackgroundAutoCompile: true)
|
||||||
|
else
|
||||||
|
# Extend remainder of timeout
|
||||||
|
autoCompileTimeout = setTimeout () ->
|
||||||
|
autoCompileTimeout = null
|
||||||
|
triggerAutoCompile()
|
||||||
|
, AUTO_COMPILE_TIMEOUT - timeSinceLastCompile
|
||||||
|
|
||||||
autoCompileListener = null
|
autoCompileListener = null
|
||||||
toggleAutoCompile = (enabling) ->
|
toggleAutoCompile = (enabling) ->
|
||||||
if enabling
|
if enabling
|
||||||
autoCompileListener = ide.$scope.$on "ide:opAcknowledged", _.debounce(triggerAutoCompile, AUTO_COMPILE_TIMEOUT)
|
autoCompileListener = ide.$scope.$on "ide:opAcknowledged", _.debounce(triggerAutoCompile, OP_ACKNOWLEDGEMENT_TIMEOUT)
|
||||||
else
|
else
|
||||||
autoCompileListener() if autoCompileListener
|
autoCompileListener() if autoCompileListener
|
||||||
autoCompileListener = null
|
autoCompileListener = null
|
||||||
|
@ -422,6 +438,8 @@ define [
|
||||||
$scope.pdf.renderingError = false
|
$scope.pdf.renderingError = false
|
||||||
$scope.pdf.error = true
|
$scope.pdf.error = true
|
||||||
$scope.pdf.view = 'errors'
|
$scope.pdf.view = 'errors'
|
||||||
|
.finally () ->
|
||||||
|
$scope.recompiledAt = Date.now()
|
||||||
|
|
||||||
# This needs to be public.
|
# This needs to be public.
|
||||||
ide.$scope.recompile = $scope.recompile
|
ide.$scope.recompile = $scope.recompile
|
||||||
|
|
Loading…
Reference in a new issue