mirror of
https://github.com/unraid/api.git
synced 2025-12-31 05:29:48 -06:00
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:
@@ -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}`);
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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: () => {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user