@@ -68,6 +68,7 @@ export class Repository {
68
68
public remoteChangedFiles : number = 0 ;
69
69
public isIncomplete : boolean = false ;
70
70
public needCleanUp : boolean = false ;
71
+ private remoteChangedUpdateInterval ?: NodeJS . Timer ;
71
72
72
73
private lastPromptAuth ?: Thenable < boolean | undefined > ;
73
74
@@ -129,6 +130,7 @@ export class Repository {
129
130
this . isIncomplete = false ;
130
131
this . needCleanUp = false ;
131
132
}
133
+
132
134
get root ( ) : string {
133
135
return this . repository . root ;
134
136
}
@@ -234,27 +236,33 @@ export class Repository {
234
236
this . disposables . push ( this . unversioned ) ;
235
237
this . disposables . push ( this . conflicts ) ;
236
238
237
- const updateFreqNew = configuration . get < number > (
238
- "remoteChanges.checkFrequency" ,
239
- 300
239
+ // Dispose the setInterval of Remote Changes
240
+ this . disposables . push (
241
+ toDisposable ( ( ) => {
242
+ if ( this . remoteChangedUpdateInterval ) {
243
+ clearInterval ( this . remoteChangedUpdateInterval ) ;
244
+ }
245
+ } )
240
246
) ;
241
- if ( updateFreqNew ) {
242
- const interval = setInterval ( ( ) => {
243
- this . updateRemoteChangedFiles ( ) ;
244
- } , 1000 * updateFreqNew ) ;
245
247
246
- this . disposables . push (
247
- toDisposable ( ( ) => {
248
- clearInterval ( interval ) ;
249
- } )
250
- ) ;
251
- }
248
+ this . createRemoteChangedInterval ( ) ;
252
249
253
- this . status ( ) ;
250
+ this . updateRemoteChangedFiles ( ) ;
254
251
255
- if ( updateFreqNew ) {
256
- this . updateRemoteChangedFiles ( ) ;
257
- }
252
+ // On change config, dispose current interval and create a new.
253
+ configuration . onDidChange ( e => {
254
+ if ( e . affectsConfiguration ( "svn.remoteChanges.checkFrequency" ) ) {
255
+ if ( this . remoteChangedUpdateInterval ) {
256
+ clearInterval ( this . remoteChangedUpdateInterval ) ;
257
+ }
258
+
259
+ this . createRemoteChangedInterval ( ) ;
260
+
261
+ this . updateRemoteChangedFiles ( ) ;
262
+ }
263
+ } ) ;
264
+
265
+ this . status ( ) ;
258
266
259
267
this . disposables . push (
260
268
workspace . onDidSaveTextDocument ( document => {
@@ -263,9 +271,37 @@ export class Repository {
263
271
) ;
264
272
}
265
273
274
+ private createRemoteChangedInterval ( ) {
275
+ const updateFreq = configuration . get < number > (
276
+ "remoteChanges.checkFrequency" ,
277
+ 300
278
+ ) ;
279
+
280
+ if ( ! updateFreq ) {
281
+ return ;
282
+ }
283
+
284
+ this . remoteChangedUpdateInterval = setInterval ( ( ) => {
285
+ this . updateRemoteChangedFiles ( ) ;
286
+ } , 1000 * updateFreq ) ;
287
+ }
288
+
266
289
@debounce ( 1000 )
267
290
public async updateRemoteChangedFiles ( ) {
268
- this . run ( Operation . StatusRemote ) ;
291
+ const updateFreq = configuration . get < number > (
292
+ "remoteChanges.checkFrequency" ,
293
+ 300
294
+ ) ;
295
+
296
+ if ( updateFreq ) {
297
+ this . run ( Operation . StatusRemote ) ;
298
+ } else {
299
+ // Remove list of remote changes
300
+ if ( this . remoteChanges ) {
301
+ this . remoteChanges . dispose ( ) ;
302
+ this . remoteChanges = undefined ;
303
+ }
304
+ }
269
305
}
270
306
271
307
private onFSChange ( uri : Uri ) : void {
@@ -339,6 +375,7 @@ export class Repository {
339
375
includeExternals : combineExternal ,
340
376
checkRemoteChanges
341
377
} ) ) || [ ] ;
378
+
342
379
const fileConfig = workspace . getConfiguration ( "files" , Uri . file ( this . root ) ) ;
343
380
344
381
const filesToExclude = fileConfig . get < any > ( "exclude" ) ;
0 commit comments