fix: debounce is too long (#1426)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Reduced the delay before configuration changes are processed,
resulting in faster response times to configuration updates throughout
the application.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Eli Bosley
2025-06-20 11:07:53 -04:00
committed by GitHub
parent 75ad8381bd
commit f12d231e63
4 changed files with 4 additions and 7 deletions

View File

@@ -85,7 +85,7 @@ class ApiConfigPersistence {
this.migrateFromMyServersConfig();
}
await this.persistenceHelper.persistIfChanged(this.filePath, this.config);
this.configService.changes$.pipe(debounceTime(500)).subscribe({
this.configService.changes$.pipe(debounceTime(25)).subscribe({
next: async ({ newValue, oldValue, path }) => {
if (path.startsWith('api')) {
this.logger.verbose(`Config changed: ${path} from ${oldValue} to ${newValue}`);

View File

@@ -33,8 +33,7 @@ export class ConnectConfigPersister implements OnModuleInit, OnModuleDestroy {
this.logger.verbose(`Config path: ${this.configPath}`);
await this.loadOrMigrateConfig();
// Persist changes to the config.
const HALF_SECOND = 500;
this.configService.changes$.pipe(debounceTime(HALF_SECOND)).subscribe({
this.configService.changes$.pipe(debounceTime(25)).subscribe({
next: async ({ newValue, oldValue, path }) => {
if (path.startsWith('connect.config')) {
this.logger.verbose(`Config changed: ${path} from ${oldValue} to ${newValue}`);

View File

@@ -80,11 +80,10 @@ export class MothershipConnectionService implements OnModuleInit, OnModuleDestro
if (this.identitySubscription) {
this.identitySubscription.unsubscribe();
}
const debounceTimeMs = 100;
this.identitySubscription = this.configService.changes$
.pipe(
filter((change) => Object.values(this.configKeys).includes(change.path)),
debounceTime(debounceTimeMs)
debounceTime(25)
)
.subscribe({
next: () => {

View File

@@ -42,8 +42,7 @@ export class PluginNameConfigPersister implements OnModuleInit {
}
// Automatically persist changes to the config file after a short delay.
const HALF_SECOND = 500;
this.configService.changes$.pipe(debounceTime(HALF_SECOND)).subscribe({
this.configService.changes$.pipe(debounceTime(25)).subscribe({
next: ({ newValue, oldValue, path: changedPath }) => {
// Only persist if the change is within this plugin's config namespace
if (changedPath.startsWith("plugin-name.") && newValue !== oldValue) {