mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 16:25:43 +00:00
Unsubscribe autocompile listener if disabled
This commit is contained in:
parent
cca7f55322
commit
a9e94f6a6d
1 changed files with 15 additions and 5 deletions
|
@ -72,16 +72,26 @@ define [
|
|||
$scope.pdf.view = 'errors'
|
||||
$scope.pdf.renderingError = true
|
||||
|
||||
triggerAutoCompile = () ->
|
||||
if (!ide.$scope.hasLintingError)
|
||||
$scope.recompile()
|
||||
|
||||
autoCompileListener = null
|
||||
toggleAutoCompile = (enabling) ->
|
||||
if enabling
|
||||
autoCompileListener = ide.$scope.$on "ide:opAcknowledged", _.debounce(triggerAutoCompile, 3000)
|
||||
else
|
||||
autoCompileListener() if autoCompileListener
|
||||
autoCompileListener = null
|
||||
|
||||
$scope.autocompile_enabled = localStorage("autocompile_enabled:#{$scope.project_id}") or false
|
||||
$scope.$watch "autocompile_enabled", (newValue, oldValue) ->
|
||||
if newValue? and oldValue != newValue
|
||||
localStorage("autocompile_enabled:#{$scope.project_id}", newValue)
|
||||
toggleAutoCompile(newValue)
|
||||
|
||||
# TODO: toggle listener when setting changed?
|
||||
ide.$scope.$on "ide:opAcknowledged", _.debounce(() ->
|
||||
if (!ide.$scope.hasLintingError)
|
||||
$scope.recompile()
|
||||
, 3000) if window.user?.betaProgram and $scope.autocompile_enabled
|
||||
if window.user?.betaProgram and $scope.autocompile_enabled
|
||||
toggleAutoCompile(true)
|
||||
|
||||
# abort compile if syntax checks fail
|
||||
$scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}")
|
||||
|
|
Loading…
Add table
Reference in a new issue