Merge with websocket branch

This commit is contained in:
Eudes Inácio
2022-01-19 09:12:30 +01:00
46 changed files with 1631 additions and 729 deletions
@@ -11,7 +11,7 @@
</div>
<div class="middle-container" *ngIf="!showMessageOptions">
<div class="middle add-ellipsis">
<ion-label class="title">{{roomName}}</ion-label>
<ion-label class="title">{{wsChatMethodsService.getGroupRoom(roomId).name}}</ion-label>
</div>
</div>
<div class="middle-container-options" *ngIf="showMessageOptions">
@@ -53,11 +53,11 @@
<div (click)="handleClick()" class="messages overflow-y-auto" #scrollMe>
<div class="welcome-text">
<ion-label>Esta conversa passou a grupo TIAGO</ion-label><br />
<ion-label>Esta conversa passou a grupo</ion-label><br />
<ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
<div *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}'>
<div class="title">
<ion-label>{{msg.u.name ?? ""}}</ion-label>
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
@@ -137,7 +137,6 @@
<div>
<div>
<div class="file">
<!-- <canvas id="pdf_canvas"></canvas> -->
<div (click)="viewDocument(msg.file, file.title_link)" class="file-details add-ellipsis cursor-pointer" *ngIf="msg.file">
<span *ngIf="msg.file.type">
<fa-icon *ngIf="msg.file.type == 'application/pdf'" icon="file-pdf" class="pdf-icon"></fa-icon>
@@ -184,6 +183,14 @@
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.t == 'au'" class="info-text-leave">
<div *ngFor="let user of allUsers">
<div *ngIf="msg.msg == user.username">
<ion-label>Adicionou {{user.name}}</ion-label><br />
</div>
</div>
{{last ? scrollToBottom() : ''}}
</div>
<div *ngIf="msg.file">
<div *ngIf="msg.file.type == 'application/meeting'" class="info-meeting">
<ion-label class="info-meeting-small">{{msg.u.name ?? ""}} criou esta reunião</ion-label><br />
@@ -25,6 +25,7 @@ import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
import { HttpEventType } from '@angular/common/http';
import { SqliteService } from 'src/app/services/sqlite.service';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
@Component({
selector: 'app-group-messages',
@@ -88,6 +89,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
private changeDetectorRef: ChangeDetectorRef,
private sqlservice: SqliteService,
private platform: Platform,
public wsChatMethodsService: WsChatMethodsService
) {
this.loggedUserChat = authService.ValidatedUserChat['data'];
this.isGroupCreated = true;
@@ -97,6 +99,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.modalController.dismiss();
}
};
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked;
setTimeout(()=>{
this.scrollToBottomClicked()
}, 50)
}
ngOnInit() {
@@ -208,7 +218,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
} catch(err) { }
}
scrollToBottomClicked(): void {
scrollToBottomClicked = () => {
try {
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
} catch(err) { }
@@ -312,18 +322,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
sendMessage(){
let body = {
"message": { "rid": this.roomId, "msg": this.message }
}
this.chatService.sendMessage(body).subscribe(res=> {
this.getRoomInfo();
this.scrollingOnce = true;
},(error) => {
});
sendMessage() {
this.wsChatMethodsService.getDmRoom(this.roomId).send(this.message)
this.message = "";
}