Просмотр исходного кода

fix(core): Correctly publish ChangeChannelEvent with new channel IDs. (#4176)

Drayke 1 день назад
Родитель
Сommit
4f31ba3b8e
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      packages/core/src/service/services/channel.service.ts

+ 10 - 2
packages/core/src/service/services/channel.service.ts

@@ -203,6 +203,10 @@ export class ChannelService {
             id => !assignedChannels.some(ec => idsAreEqual(ec.channelId, id)),
             id => !assignedChannels.some(ec => idsAreEqual(ec.channelId, id)),
         );
         );
 
 
+        if (!newChannelIds.length) {
+            return entity;
+        }
+
         await this.connection
         await this.connection
             .getRepository(ctx, entityType)
             .getRepository(ctx, entityType)
             .createQueryBuilder()
             .createQueryBuilder()
@@ -210,7 +214,9 @@ export class ChannelService {
             .of(entity.id)
             .of(entity.id)
             .add(newChannelIds);
             .add(newChannelIds);
 
 
-        await this.eventBus.publish(new ChangeChannelEvent(ctx, entity, channelIds, 'assigned', entityType));
+        await this.eventBus.publish(
+            new ChangeChannelEvent(ctx, entity, newChannelIds, 'assigned', entityType),
+        );
         return entity;
         return entity;
     }
     }
 
 
@@ -249,7 +255,9 @@ export class ChannelService {
             .relation('channels')
             .relation('channels')
             .of(entity.id)
             .of(entity.id)
             .remove(existingChannelIds);
             .remove(existingChannelIds);
-        await this.eventBus.publish(new ChangeChannelEvent(ctx, entity, channelIds, 'removed', entityType));
+        await this.eventBus.publish(
+            new ChangeChannelEvent(ctx, entity, existingChannelIds, 'removed', entityType),
+        );
         return entity;
         return entity;
     }
     }