mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-23 13:46:45 +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> {
|
async insert(id: string, value: object, createdBy: string): Promise<void> {
|
||||||
const exists = await this.settingStore.exists(id);
|
const existingSettings = await this.settingStore.get<object>(id);
|
||||||
if (exists) {
|
if (existingSettings) {
|
||||||
await this.settingStore.updateRow(id, value);
|
await this.settingStore.updateRow(id, value);
|
||||||
await this.eventService.storeEvent(
|
await this.eventService.storeEvent(
|
||||||
new SettingUpdatedEvent({
|
new SettingUpdatedEvent(
|
||||||
createdBy,
|
{
|
||||||
data: { id },
|
createdBy,
|
||||||
}),
|
data: value,
|
||||||
|
},
|
||||||
|
existingSettings,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
await this.settingStore.insert(id, value);
|
await this.settingStore.insert(id, value);
|
||||||
await this.eventService.storeEvent(
|
await this.eventService.storeEvent(
|
||||||
new SettingCreatedEvent({
|
new SettingCreatedEvent({
|
||||||
createdBy,
|
createdBy,
|
||||||
data: { id },
|
data: value,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -973,12 +973,18 @@ export class SettingDeletedEvent extends BaseEvent {
|
|||||||
export class SettingUpdatedEvent extends BaseEvent {
|
export class SettingUpdatedEvent extends BaseEvent {
|
||||||
readonly data: any;
|
readonly data: any;
|
||||||
|
|
||||||
|
readonly preData: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param createdBy accepts a string for backward compatibility. Prefer using IUser for standardization
|
* @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);
|
super(SETTING_UPDATED, eventData.createdBy);
|
||||||
this.data = eventData.data;
|
this.data = eventData.data;
|
||||||
|
this.preData = preData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user