mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05: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.view = 'errors'
|
||||||
$scope.pdf.renderingError = true
|
$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.autocompile_enabled = localStorage("autocompile_enabled:#{$scope.project_id}") or false
|
||||||
$scope.$watch "autocompile_enabled", (newValue, oldValue) ->
|
$scope.$watch "autocompile_enabled", (newValue, oldValue) ->
|
||||||
if newValue? and oldValue != newValue
|
if newValue? and oldValue != newValue
|
||||||
localStorage("autocompile_enabled:#{$scope.project_id}", newValue)
|
localStorage("autocompile_enabled:#{$scope.project_id}", newValue)
|
||||||
|
toggleAutoCompile(newValue)
|
||||||
|
|
||||||
# TODO: toggle listener when setting changed?
|
if window.user?.betaProgram and $scope.autocompile_enabled
|
||||||
ide.$scope.$on "ide:opAcknowledged", _.debounce(() ->
|
toggleAutoCompile(true)
|
||||||
if (!ide.$scope.hasLintingError)
|
|
||||||
$scope.recompile()
|
|
||||||
, 3000) if window.user?.betaProgram and $scope.autocompile_enabled
|
|
||||||
|
|
||||||
# abort compile if syntax checks fail
|
# abort compile if syntax checks fail
|
||||||
$scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}")
|
$scope.stop_on_validation_error = localStorage("stop_on_validation_error:#{$scope.project_id}")
|
||||||
|
|
Loading…
Reference in a new issue