Skip to content

Commit 6aec136

Browse files
authored
fix: allow the composition of unchanged edited message (#1578)
1 parent 0b9be45 commit 6aec136

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/messageComposer/messageComposer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ export class MessageComposer extends WithSubscriptions {
306306
const initiatedWithoutDraft = this.lastChange.draftUpdate === null;
307307
const composingMessageFromScratch = initiatedWithoutDraft && !this.editedMessage;
308308

309-
// does not mean that the original editted message is different from the current state
309+
// does not mean that the original edited message is different from the current state
310310
const editedMessageWasUpdated =
311311
!!this.editedMessage?.updated_at &&
312312
new Date(this.editedMessage.updated_at).getTime() < this.lastChange.stateUpdate;

src/messageComposer/middleware/messageComposer/compositionValidation.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ export const createCompositionValidationMiddleware = (
2828
const hasExceededMaxLength =
2929
typeof maxLengthOnSend === 'number' && inputText.length > maxLengthOnSend;
3030

31-
const editedMessageIsUnchanged =
32-
composer.editedMessage && !composer.lastChangeOriginIsLocal;
33-
34-
if (isEmptyMessage || editedMessageIsUnchanged || hasExceededMaxLength) {
31+
if (isEmptyMessage || hasExceededMaxLength) {
3532
return await discard();
3633
}
3734

test/unit/MessageComposer/middleware/messageComposer/compositionValidation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ describe('stream-io/message-composer-middleware/data-validation', () => {
322322
expect(result.status).toBeUndefined;
323323
});
324324

325-
it('should discard composition for edited message without any local change', async () => {
325+
it('should not discard composition for edited message without any local change', async () => {
326326
const { messageComposer, validationMiddleware } = setupMiddleware();
327327
const localMessage: LocalMessage = {
328328
attachments: [],
@@ -355,7 +355,7 @@ describe('stream-io/message-composer-middleware/data-validation', () => {
355355
}),
356356
);
357357

358-
expect(result.status).toBe('discard');
358+
expect(result.status).toBeUndefined();
359359
});
360360

361361
it('should not discard composition for newly composed message initiated with draft', async () => {

0 commit comments

Comments
 (0)