Skip to content

Commit f12d231

Browse files
authored
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 -->
1 parent 75ad838 commit f12d231

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

api/src/unraid-api/config/api-config.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ApiConfigPersistence {
8585
this.migrateFromMyServersConfig();
8686
}
8787
await this.persistenceHelper.persistIfChanged(this.filePath, this.config);
88-
this.configService.changes$.pipe(debounceTime(500)).subscribe({
88+
this.configService.changes$.pipe(debounceTime(25)).subscribe({
8989
next: async ({ newValue, oldValue, path }) => {
9090
if (path.startsWith('api')) {
9191
this.logger.verbose(`Config changed: ${path} from ${oldValue} to ${newValue}`);

packages/unraid-api-plugin-connect/src/service/config.persistence.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ 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-
const HALF_SECOND = 500;
37-
this.configService.changes$.pipe(debounceTime(HALF_SECOND)).subscribe({
36+
this.configService.changes$.pipe(debounceTime(25)).subscribe({
3837
next: async ({ newValue, oldValue, path }) => {
3938
if (path.startsWith('connect.config')) {
4039
this.logger.verbose(`Config changed: ${path} from ${oldValue} to ${newValue}`);

packages/unraid-api-plugin-connect/src/service/connection.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@ export class MothershipConnectionService implements OnModuleInit, OnModuleDestro
8080
if (this.identitySubscription) {
8181
this.identitySubscription.unsubscribe();
8282
}
83-
const debounceTimeMs = 100;
8483
this.identitySubscription = this.configService.changes$
8584
.pipe(
8685
filter((change) => Object.values(this.configKeys).includes(change.path)),
87-
debounceTime(debounceTimeMs)
86+
debounceTime(25)
8887
)
8988
.subscribe({
9089
next: () => {

packages/unraid-api-plugin-generator/src/templates/config.persistence.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export class PluginNameConfigPersister implements OnModuleInit {
4242
}
4343

4444
// Automatically persist changes to the config file after a short delay.
45-
const HALF_SECOND = 500;
46-
this.configService.changes$.pipe(debounceTime(HALF_SECOND)).subscribe({
45+
this.configService.changes$.pipe(debounceTime(25)).subscribe({
4746
next: ({ newValue, oldValue, path: changedPath }) => {
4847
// Only persist if the change is within this plugin's config namespace
4948
if (changedPath.startsWith("plugin-name.") && newValue !== oldValue) {

0 commit comments

Comments
 (0)