mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-18 13:48:58 +02:00
fix: settings change events now use preData and publish the change, not just the id
This commit is contained in:
parent
713d69fc7a
commit
82c34f44b2
@ -43,21 +43,24 @@ export default class SettingService {
|
||||
}
|
||||
|
||||
async insert(id: string, value: object, createdBy: string): Promise<void> {
|
||||
const exists = await this.settingStore.exists(id);
|
||||
if (exists) {
|
||||
const existingSettings = await this.settingStore.get<object>(id);
|
||||
if (existingSettings) {
|
||||
await this.settingStore.updateRow(id, value);
|
||||
await this.eventService.storeEvent(
|
||||
new SettingUpdatedEvent({
|
||||
createdBy,
|
||||
data: { id },
|
||||
}),
|
||||
new SettingUpdatedEvent(
|
||||
{
|
||||
createdBy,
|
||||
data: value,
|
||||
},
|
||||
existingSettings,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await this.settingStore.insert(id, value);
|
||||
await this.eventService.storeEvent(
|
||||
new SettingCreatedEvent({
|
||||
createdBy,
|
||||
data: { id },
|
||||
data: value,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -973,12 +973,18 @@ export class SettingDeletedEvent extends BaseEvent {
|
||||
export class SettingUpdatedEvent extends BaseEvent {
|
||||
readonly data: any;
|
||||
|
||||
readonly preData: any;
|
||||
|
||||
/**
|
||||
* @param createdBy accepts a string for backward compatibility. Prefer using IUser for standardization
|
||||
*/
|
||||
constructor(eventData: { createdBy: string | IUser; data: any }) {
|
||||
constructor(
|
||||
eventData: { createdBy: string | IUser; data: any },
|
||||
preData: any,
|
||||
) {
|
||||
super(SETTING_UPDATED, eventData.createdBy);
|
||||
this.data = eventData.data;
|
||||
this.preData = preData;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user