Enforce 256-character limit on chat messages with validation in ChatBoxComponent and schema updates.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
[(ngModel)]="chatText"
|
||||
(keyup.enter)="sendMessage()"
|
||||
placeholder="Type a message..."
|
||||
maxlength="256"
|
||||
/>
|
||||
<button (click)="sendMessage()">Send</button>
|
||||
</div>
|
||||
|
||||
@@ -39,7 +39,15 @@ export class ChatBoxComponent {
|
||||
|
||||
sendMessage() {
|
||||
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 uuid = this.authService.getUuid();
|
||||
|
||||
Reference in New Issue
Block a user