Skip to content

Commit a44a92c

Browse files
committed
refactor(settings): remove setBulk method and update initialization logic
- Removed the setBulk method from CachedSettings to streamline the settings loading process. - Updated the initializeSettings function to set records individually instead of using bulk loading, enhancing clarity and maintainability.
1 parent 96ffc6a commit a44a92c

2 files changed

Lines changed: 3 additions & 19 deletions

File tree

apps/meteor/app/settings/server/CachedSettings.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ export interface ICachedSettings {
5656

5757
set(record: ISetting): void;
5858

59-
/**
60-
* Bulk load records into the store without emitting or registering ready listeners.
61-
* Use during initial load; call initialized() after.
62-
*/
63-
setBulk(records: ISetting[]): void;
64-
6559
getConfig(config?: OverCustomSettingsConfig): SettingsConfig;
6660

6761
watchByRegex(regex: RegExp, cb: (...args: [string, SettingValue]) => void, config?: OverCustomSettingsConfig): () => void;
@@ -344,16 +338,6 @@ export class CachedSettings
344338
this.emit('*', [record._id, this.store.get(record._id)?.value]);
345339
}
346340

347-
/**
348-
* Bulk load records into the store without emitting or registering ready listeners.
349-
* Use during initial load only; call initialized() after.
350-
*/
351-
public setBulk(records: ISetting[]): void {
352-
for (const record of records) {
353-
this.store.set(record._id, record);
354-
}
355-
}
356-
357341
public getConfig = (config?: OverCustomSettingsConfig): SettingsConfig => ({
358342
debounce: process.env.TEST_MODE ? 0 : 500,
359343
...config,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { ISetting } from '@rocket.chat/core-typings';
21
import type { Settings } from '@rocket.chat/models';
32

43
import type { ICachedSettings } from './CachedSettings';
54

6-
// eslint-disable-next-line @typescript-eslint/naming-convention
75
export async function initializeSettings({ model, settings }: { model: typeof Settings; settings: ICachedSettings }): Promise<void> {
86
const records = await model.find().toArray();
9-
settings.setBulk(records as ISetting[]);
7+
for (const record of records) {
8+
settings.set(record);
9+
}
1010
settings.initialized();
1111
}

0 commit comments

Comments
 (0)