Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@ctrl/ngx-emoji-mart": "^6.2.0",
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@stream-io/stream-chat-css": "2.7.0",
"@stream-io/stream-chat-css": "2.8.1",
"@stream-io/transliterate": "^1.5.2",
"angular-mentions": "^1.4.0",
"dayjs": "^1.10.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,36 @@ describe('MessageInputComponent', () => {
expect(sendMessageSpy).not.toHaveBeenCalled();
});

it(`shouldn't send messages with only spaces`, () => {
const textarea = queryTextarea();
component.textareaValue = ' '; // single space
textarea?.send.next();
fixture.detectChanges();

expect(sendMessageSpy).not.toHaveBeenCalled();
});

it(`should remove text if attachments are uploaded, but text contains only space characters`, () => {
attachmentService.mapToAttachments.and.returnValue([
{
type: 'image',
img_url: 'url',
},
]);
const textarea = queryTextarea();
component.textareaValue = ' '; // multiple spaces
textarea?.send.next();
fixture.detectChanges();

expect(sendMessageSpy).toHaveBeenCalledWith(
'',
jasmine.any(Array),
jasmine.any(Object),
undefined,
undefined
);
});

it('should apply CSS class if attachments are present', () => {
const cssClass = 'str-chat__input-flat-has-attachments';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,17 @@ export class MessageInputComponent
return;
}
const attachments = this.attachmentService.mapToAttachments();
const text = this.textareaValue;
if (!text && (!attachments || attachments.length === 0)) {
let text = this.textareaValue;
const textContainsOnlySpaceChars = !text.replace(/ /g, ''); //spcae
if (
(!text || textContainsOnlySpaceChars) &&
(!attachments || attachments.length === 0)
) {
return;
}
if (textContainsOnlySpaceChars) {
text = '';
}
if (this.containsLinks && !this.canSendLinks) {
this.notificationService.addTemporaryNotification(
'streamChat.Sending links is not allowed in this conversation'
Expand Down