Enforce 256-character limit on chat messages with validation in ChatBoxComponent and schema updates.
This commit is contained in:
parent
bdda71229d
commit
b61b117f41
|
|
@ -20,6 +20,7 @@
|
||||||
[(ngModel)]="chatText"
|
[(ngModel)]="chatText"
|
||||||
(keyup.enter)="sendMessage()"
|
(keyup.enter)="sendMessage()"
|
||||||
placeholder="Type a message..."
|
placeholder="Type a message..."
|
||||||
|
maxlength="256"
|
||||||
/>
|
/>
|
||||||
<button (click)="sendMessage()">Send</button>
|
<button (click)="sendMessage()">Send</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,15 @@ export class ChatBoxComponent {
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
const message = this.chatText.trim();
|
const message = this.chatText.trim();
|
||||||
if (!message) return;
|
if (!message) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message.length > 256) {
|
||||||
|
this.matSnackBar.open('Message too long, it can only be 256 characters', 'Dismiss', {
|
||||||
|
duration: 3000
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const selectedChannel = this.chatService.selectedChannel();
|
const selectedChannel = this.chatService.selectedChannel();
|
||||||
const uuid = this.authService.getUuid();
|
const uuid = this.authService.getUuid();
|
||||||
|
|
|
||||||
|
|
@ -42,3 +42,4 @@ components:
|
||||||
message:
|
message:
|
||||||
type: string
|
type: string
|
||||||
description: The message to send
|
description: The message to send
|
||||||
|
maxLength: 256
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user