@@ -68,6 +68,7 @@ export class Repository {
6868 public remoteChangedFiles : number = 0 ;
6969 public isIncomplete : boolean = false ;
7070 public needCleanUp : boolean = false ;
71+ private remoteChangedUpdateInterval ?: NodeJS . Timer ;
7172
7273 private lastPromptAuth ?: Thenable < boolean | undefined > ;
7374
@@ -129,6 +130,7 @@ export class Repository {
129130 this . isIncomplete = false ;
130131 this . needCleanUp = false ;
131132 }
133+
132134 get root ( ) : string {
133135 return this . repository . root ;
134136 }
@@ -234,27 +236,33 @@ export class Repository {
234236 this . disposables . push ( this . unversioned ) ;
235237 this . disposables . push ( this . conflicts ) ;
236238
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+ } )
240246 ) ;
241- if ( updateFreqNew ) {
242- const interval = setInterval ( ( ) => {
243- this . updateRemoteChangedFiles ( ) ;
244- } , 1000 * updateFreqNew ) ;
245247
246- this . disposables . push (
247- toDisposable ( ( ) => {
248- clearInterval ( interval ) ;
249- } )
250- ) ;
251- }
248+ this . createRemoteChangedInterval ( ) ;
252249
253- this . status ( ) ;
250+ this . updateRemoteChangedFiles ( ) ;
254251
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 ( ) ;
258266
259267 this . disposables . push (
260268 workspace . onDidSaveTextDocument ( document => {
@@ -263,9 +271,37 @@ export class Repository {
263271 ) ;
264272 }
265273
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+
266289 @debounce ( 1000 )
267290 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+ }
269305 }
270306
271307 private onFSChange ( uri : Uri ) : void {
@@ -339,6 +375,7 @@ export class Repository {
339375 includeExternals : combineExternal ,
340376 checkRemoteChanges
341377 } ) ) || [ ] ;
378+
342379 const fileConfig = workspace . getConfiguration ( "files" , Uri . file ( this . root ) ) ;
343380
344381 const filesToExclude = fileConfig . get < any > ( "exclude" ) ;
0 commit comments