|
145 | 145 |
|
146 | 146 | constructor(){
|
147 | 147 | super();
|
| 148 | + this._crtPoll = 10; |
| 149 | + |
| 150 | + this._quickPoll = 2; |
| 151 | + this._longPoll = 15; |
| 152 | + this._pollSteps = 1.4; |
148 | 153 | // Start listening to server messages
|
149 | 154 | global.pydio.observe("server_message", function(xml){
|
150 | 155 | var task = XMLUtils.XPathSelectSingleNode(xml, 'tree/task');
|
|
169 | 174 | taskMap.set(task.getId(), task);
|
170 | 175 | });
|
171 | 176 | this._tasksList = taskMap;
|
172 |
| - this.notify("tasks_updated"); |
173 |
| - if(tasks.length){ |
174 |
| - global.pydio.notify("poller.frequency", {value:2}); |
175 |
| - }else{ |
176 |
| - global.pydio.notify("poller.frequency", {}); |
177 |
| - } |
| 177 | + this.notifyAndSetPollerSpeed(tasks); |
178 | 178 | }
|
179 | 179 | }
|
180 | 180 | }.bind(this));
|
|
193 | 193 | let taskMap = new Map();
|
194 | 194 | tasks.map(function(t){taskMap.set(t.getId(), t)});
|
195 | 195 | this._tasksList = taskMap;
|
196 |
| - this.notify("tasks_updated"); |
197 |
| - if(tasks.length){ |
198 |
| - global.pydio.notify("poller.frequency", {value:2}); |
199 |
| - }else{ |
200 |
| - global.pydio.notify("poller.frequency", {}); |
201 |
| - } |
| 196 | + this.notifyAndSetPollerSpeed(tasks); |
202 | 197 | }.bind(this));
|
203 | 198 | }
|
204 | 199 | // Add local tasks
|
|
210 | 205 | return this._tasksList;
|
211 | 206 | }
|
212 | 207 |
|
| 208 | + notifyAndSetPollerSpeed(tasks){ |
| 209 | + this.notify("tasks_updated"); |
| 210 | + if(tasks.length){ |
| 211 | + this._crtPoll = this._quickPoll; |
| 212 | + global.pydio.notify("poller.frequency", {value:this._quickPoll}); |
| 213 | + }else{ |
| 214 | + this._crtPoll *= this._pollSteps; |
| 215 | + if(this._crtPoll >= this._longPoll){ |
| 216 | + global.pydio.notify("poller.frequency", {}); |
| 217 | + }else{ |
| 218 | + global.pydio.notify("poller.frequency", {value:this._crtPoll}); |
| 219 | + } |
| 220 | + } |
| 221 | + } |
| 222 | + |
213 | 223 | enqueueLocalTask(task){
|
214 | 224 | if(!this._localTasks) {
|
215 | 225 | this._localTasks = new Map();
|
|
0 commit comments