From efd01081f7a821188bb0e854b142374198db5675 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 24 May 2017 14:28:27 +0100 Subject: [PATCH] Set up and automatic refresh of labels --- .../coffee/ide/labels/LabelsManager.coffee | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/services/web/public/coffee/ide/labels/LabelsManager.coffee b/services/web/public/coffee/ide/labels/LabelsManager.coffee index 36226feeaf..a8f0d618ee 100644 --- a/services/web/public/coffee/ide/labels/LabelsManager.coffee +++ b/services/web/public/coffee/ide/labels/LabelsManager.coffee @@ -1,21 +1,37 @@ define [ ], () -> + + AUTOMATIC_REFRESH_PERIOD = 1000 * 60 * 10 + class LabelsManager constructor: (@ide, @$scope) -> @$scope.$root._labels = this @state = - documents: {} + documents: {} # map of DocId => List[Label] @loadLabelsTimeout = null + @periodicLoadInterval = null setTimeout( (self) -> + # set up a regular re-load + setTimeout( + (self) -> + self.periodicLoadInterval = setInterval( + (self) -> + self.loadLabelsFromOpenDoc() + , AUTOMATIC_REFRESH_PERIOD + , self + ) + , AUTOMATIC_REFRESH_PERIOD + , self + ) + # listen for document open self.$scope.$on 'document:opened', (e, doc) -> - # console.log ">> [LabelsManager] document opened" setTimeout( (self) -> - self.loadLabelsFromOpenDoc() + self.scheduleLoadLabelsFromOpenDoc() , 1000 , self )