@@ -9,14 +9,14 @@ import { plainToInstance } from 'class-transformer';
99import  {  validateOrReject  }  from  'class-validator' ; 
1010import  {  parse  as  parseIni  }  from  'ini' ; 
1111import  {  isEqual  }  from  'lodash-es' ; 
12- import  {  debounceTime  }  from  'rxjs/operators' ; 
12+ import  {  bufferTime  }  from  'rxjs/operators' ; 
1313
1414import  type  {  MyServersConfig  as  LegacyConfig  }  from  '../model/my-servers-config.model.js' ; 
1515import  {  ConfigType ,  MyServersConfig  }  from  '../model/connect-config.model.js' ; 
1616
1717@Injectable ( ) 
1818export  class  ConnectConfigPersister  implements  OnModuleInit ,  OnModuleDestroy  { 
19-     constructor ( private  readonly  configService : ConfigService < ConfigType > )  { } 
19+     constructor ( private  readonly  configService : ConfigService < ConfigType ,   true > )  { } 
2020
2121    private  logger  =  new  Logger ( ConnectConfigPersister . name ) ; 
2222    get  configPath ( )  { 
@@ -33,10 +33,10 @@ export class ConnectConfigPersister implements OnModuleInit, OnModuleDestroy {
3333        this . logger . verbose ( `Config path: ${ this . configPath }  ) ; 
3434        await  this . loadOrMigrateConfig ( ) ; 
3535        // Persist changes to the config. 
36-         this . configService . changes$ . pipe ( debounceTime ( 25 ) ) . subscribe ( { 
37-             next : async  ( {  newValue ,  oldValue ,  path  } )  =>  { 
38-                 if   ( path . startsWith ( 'connect.config' ) )   { 
39-                      this . logger . verbose ( `Config changed:  ${ path }  from  ${ oldValue }  to  ${ newValue } ` ) ; 
36+         this . configService . changes$ . pipe ( bufferTime ( 25 ) ) . subscribe ( { 
37+             next : async  ( changes )  =>  { 
38+                 const   connectConfigChanged   =   changes . some ( ( {   path  } )   =>   path . startsWith ( 'connect.config' ) ) ; 
39+                 if   ( connectConfigChanged )   { 
4040                    await  this . persist ( ) ; 
4141                } 
4242            } , 
@@ -60,7 +60,7 @@ export class ConnectConfigPersister implements OnModuleInit, OnModuleDestroy {
6060                return  false ; 
6161            } 
6262        }  catch  ( error )  { 
63-             this . logger . error ( `Error loading config (will overwrite file):`  ,   error ) ; 
63+             this . logger . error ( error ,   `Error loading config (will overwrite file)`  ) ; 
6464        } 
6565        const  data  =  JSON . stringify ( config ,  null ,  2 ) ; 
6666        this . logger . verbose ( `Persisting config to ${ this . configPath } ${ data }  ) ; 
@@ -69,7 +69,7 @@ export class ConnectConfigPersister implements OnModuleInit, OnModuleDestroy {
6969            this . logger . verbose ( `Config persisted to ${ this . configPath }  ) ; 
7070            return  true ; 
7171        }  catch  ( error )  { 
72-             this . logger . error ( `Error persisting config to '${ this . configPath } :`  ,   error ) ; 
72+             this . logger . error ( error ,   `Error persisting config to '${ this . configPath } `  ) ; 
7373            return  false ; 
7474        } 
7575    } 
0 commit comments