Merge pull request #6100 from tsiegleauq/pending-chat
Add pending state for chat message
This commit is contained in:
commit
7a076b1d2d
@ -34,13 +34,15 @@
|
||||
</span>
|
||||
</mat-hint>
|
||||
<mat-label>{{ 'Message' | translate }}</mat-label>
|
||||
<mat-spinner *ngIf="messagePending" matSuffix diameter="30"></mat-spinner>
|
||||
<button
|
||||
mat-icon-button
|
||||
matSuffix
|
||||
type="submit"
|
||||
color="accent"
|
||||
matTooltip=" {{ 'Send' | translate }}"
|
||||
[disabled]="!chatinput.value?.trim()?.length || newMessageForm.invalid"
|
||||
*ngIf="!messagePending"
|
||||
[disabled]="!chatinput.value?.trim()?.length || newMessageForm.invalid || messagePending"
|
||||
>
|
||||
<mat-icon>send</mat-icon>
|
||||
</button>
|
||||
|
@ -26,6 +26,7 @@ import { ViewChatGroup } from '../../models/view-chat-group';
|
||||
export class ChatTabsComponent extends BaseViewComponentDirective implements OnInit {
|
||||
public chatGroupSubject: BehaviorSubject<ViewChatGroup[]>;
|
||||
public newMessageForm: FormGroup;
|
||||
public messagePending = false;
|
||||
private messageControl: AbstractControl;
|
||||
public chatMessageMaxLength = 512;
|
||||
private selectedTabIndex = 0;
|
||||
@ -91,8 +92,12 @@ export class ChatTabsComponent extends BaseViewComponentDirective implements OnI
|
||||
}
|
||||
|
||||
public send(): void {
|
||||
if (this.messagePending) {
|
||||
return;
|
||||
}
|
||||
const message = this.messageControl.value?.trim();
|
||||
if (message) {
|
||||
this.messagePending = true;
|
||||
const payload = {
|
||||
text: message,
|
||||
chatgroup_id: this.chatGroupFromIndex.id
|
||||
@ -102,6 +107,9 @@ export class ChatTabsComponent extends BaseViewComponentDirective implements OnI
|
||||
.then(() => {
|
||||
this.clearTextInput();
|
||||
})
|
||||
.finally(() => {
|
||||
this.messagePending = false;
|
||||
})
|
||||
.catch(this.raiseError);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user