mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Set up and automatic refresh of labels
This commit is contained in:
parent
b871cdab4c
commit
efd01081f7
1 changed files with 19 additions and 3 deletions
|
@ -1,21 +1,37 @@
|
||||||
define [
|
define [
|
||||||
], () ->
|
], () ->
|
||||||
|
|
||||||
|
AUTOMATIC_REFRESH_PERIOD = 1000 * 60 * 10
|
||||||
|
|
||||||
class LabelsManager
|
class LabelsManager
|
||||||
constructor: (@ide, @$scope) ->
|
constructor: (@ide, @$scope) ->
|
||||||
@$scope.$root._labels = this
|
@$scope.$root._labels = this
|
||||||
|
|
||||||
@state =
|
@state =
|
||||||
documents: {}
|
documents: {} # map of DocId => List[Label]
|
||||||
|
|
||||||
@loadLabelsTimeout = null
|
@loadLabelsTimeout = null
|
||||||
|
@periodicLoadInterval = null
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
(self) ->
|
(self) ->
|
||||||
self.$scope.$on 'document:opened', (e, doc) ->
|
# set up a regular re-load
|
||||||
# console.log ">> [LabelsManager] document opened"
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
|
(self) ->
|
||||||
|
self.periodicLoadInterval = setInterval(
|
||||||
(self) ->
|
(self) ->
|
||||||
self.loadLabelsFromOpenDoc()
|
self.loadLabelsFromOpenDoc()
|
||||||
|
, AUTOMATIC_REFRESH_PERIOD
|
||||||
|
, self
|
||||||
|
)
|
||||||
|
, AUTOMATIC_REFRESH_PERIOD
|
||||||
|
, self
|
||||||
|
)
|
||||||
|
# listen for document open
|
||||||
|
self.$scope.$on 'document:opened', (e, doc) ->
|
||||||
|
setTimeout(
|
||||||
|
(self) ->
|
||||||
|
self.scheduleLoadLabelsFromOpenDoc()
|
||||||
, 1000
|
, 1000
|
||||||
, self
|
, self
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue