diff --git a/projects/stream-chat-angular/src/lib/channel.service.spec.ts b/projects/stream-chat-angular/src/lib/channel.service.spec.ts index 33a1ff3b..88063b30 100644 --- a/projects/stream-chat-angular/src/lib/channel.service.spec.ts +++ b/projects/stream-chat-angular/src/lib/channel.service.spec.ts @@ -1365,6 +1365,8 @@ describe('ChannelService', () => { it('should update message', () => { const message = mockMessage(); + // @ts-expect-error we exclude this + delete message.readBy; void service.updateMessage(message); expect(mockChatClient.updateMessage).toHaveBeenCalledWith(message); @@ -1408,11 +1410,14 @@ describe('ChannelService', () => { ); }); - it('should remove translation object before updating message', () => { + it('should remove translation object and readyBy before updating message', () => { const message = mockMessage(); + // @ts-expect-error we exclude this + delete message.readBy; void service.updateMessage({ ...message, i18n: { en_text: 'Translation', language: 'en' }, + readBy: [], }); expect(mockChatClient.updateMessage).toHaveBeenCalledWith(message); diff --git a/projects/stream-chat-angular/src/lib/channel.service.ts b/projects/stream-chat-angular/src/lib/channel.service.ts index ae5dc59c..a6e7b895 100644 --- a/projects/stream-chat-angular/src/lib/channel.service.ts +++ b/projects/stream-chat-angular/src/lib/channel.service.ts @@ -891,10 +891,17 @@ export class ChannelService< * @param message Mesage to be updated */ async updateMessage(message: StreamMessage<T>) { - let messageToUpdate = { ...message }; + let messageToUpdate = { + ...message, + }; delete messageToUpdate.i18n; if (this.beforeUpdateMessage) { - messageToUpdate = await this.beforeUpdateMessage(messageToUpdate); + messageToUpdate = await this.beforeUpdateMessage( + messageToUpdate as StreamMessage + ); + } + if (messageToUpdate.readBy) { + delete (messageToUpdate as Omit<StreamMessage<T>, 'readBy'>).readBy; } if (message.moderation_details) { return this.resendMessage(message);