mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
improve chat
This commit is contained in:
@@ -136,7 +136,9 @@ export class ChatPage implements OnInit {
|
|||||||
this.modalController.dismiss();
|
this.modalController.dismiss();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
|
this.load()
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -144,45 +146,6 @@ export class ChatPage implements OnInit {
|
|||||||
console.log(this.loggedUserChat);
|
console.log(this.loggedUserChat);
|
||||||
|
|
||||||
this.segment = "Contactos";
|
this.segment = "Contactos";
|
||||||
|
|
||||||
// this.authService.userData$.subscribe((res: any) => {
|
|
||||||
// this.loggedUser = res;
|
|
||||||
// console.log(this.loggedUser);
|
|
||||||
// this.load();
|
|
||||||
|
|
||||||
// // this.getDirectMessagesDB();
|
|
||||||
// });
|
|
||||||
|
|
||||||
/* websocket functions */
|
|
||||||
//this.sendMsg();
|
|
||||||
|
|
||||||
/* Fim websocket functions */
|
|
||||||
// this.hideRefreshButton();
|
|
||||||
// this.getChatMembers();
|
|
||||||
|
|
||||||
//Teste
|
|
||||||
// let t = this.showDateDuration(new Date());
|
|
||||||
// console.log(t);
|
|
||||||
|
|
||||||
// this.setStatus('away');
|
|
||||||
/* if(this.dataService.get("newGroup")){
|
|
||||||
this.openNewGroupPage();
|
|
||||||
} */
|
|
||||||
|
|
||||||
// this.router.events.forEach((event) => {
|
|
||||||
// if (event instanceof NavigationStart && event.url.startsWith('/home/chat')) {
|
|
||||||
// if (this.dataService.get("newGroup")) {
|
|
||||||
// this.openNewGroupPage();
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// this.closeAllDesktopComponents();
|
|
||||||
// this.showEmptyComponent = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// this.dataService.set("newGroup", false);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
numSequence(n: number): Array<number> {
|
numSequence(n: number): Array<number> {
|
||||||
@@ -224,21 +187,6 @@ export class ChatPage implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* loadMessage(){
|
|
||||||
this.chatService.messages.subscribe(msg => {
|
|
||||||
console.log("Response from websocket: " + msg);
|
|
||||||
});
|
|
||||||
} */
|
|
||||||
/* sendMsg() {
|
|
||||||
console.log("new message from client to websocket: ", this.message);
|
|
||||||
this.chatService.messages.next(this.message);
|
|
||||||
this.message.msg = "";
|
|
||||||
} */
|
|
||||||
|
|
||||||
|
|
||||||
/* Fim websockets functions */
|
|
||||||
|
|
||||||
closeAllDesktopComponents() {
|
closeAllDesktopComponents() {
|
||||||
this.showMessages = false;
|
this.showMessages = false;
|
||||||
this.showContacts = false;
|
this.showContacts = false;
|
||||||
@@ -570,7 +518,7 @@ export class ChatPage implements OnInit {
|
|||||||
//Check if modal is opened
|
//Check if modal is opened
|
||||||
if (this.segment == "Contactos" && this.showMessages != true) {
|
if (this.segment == "Contactos" && this.showMessages != true) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
await this.getDirectMessages();
|
//await this.getDirectMessages();
|
||||||
//console.log('Timer contactos list running')
|
//console.log('Timer contactos list running')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -579,7 +527,7 @@ export class ChatPage implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await this.getDirectMessages();
|
//await this.getDirectMessages();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -734,12 +682,12 @@ export class ChatPage implements OnInit {
|
|||||||
//Check if modal is opened
|
//Check if modal is opened
|
||||||
if (this.segment == "Grupos" && this.showGroupMessages != true) {
|
if (this.segment == "Grupos" && this.showGroupMessages != true) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
await this.getGroups();
|
//await this.getGroups();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await this.getGroups();
|
//await this.getGroups();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
</ion-refresher-content>
|
</ion-refresher-content>
|
||||||
</ion-refresher> -->
|
</ion-refresher> -->
|
||||||
<div (click)="handleClick()" class="messages" #scrollMe>
|
<div (click)="handleClick()" class="messages" #scrollMe>
|
||||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of ChatServiceGPR.getRoom(this.roomId).mmm; let last = last"
|
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of ChatServiceGPR.getRoom(this.roomId).massages; let last = last"
|
||||||
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
|
[class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
|
||||||
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
|
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="openPreview(msg)" *ngIf="msg.msg !=''">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
|
|||||||
@@ -9,5 +9,24 @@ export class MessageService {
|
|||||||
mentions = []
|
mentions = []
|
||||||
msg = ''
|
msg = ''
|
||||||
rid = ''
|
rid = ''
|
||||||
|
ts = {}
|
||||||
|
u = {}
|
||||||
|
_id =''
|
||||||
|
_updatedAt = {}
|
||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
|
setData({channels, mentions, msg ,rid ,ts, u, _id, _updatedAt}) {
|
||||||
|
this.channels = channels
|
||||||
|
this.mentions = mentions
|
||||||
|
this.msg = msg
|
||||||
|
this.rid = rid
|
||||||
|
this.ts = ts
|
||||||
|
this.u = u
|
||||||
|
this._id = _id
|
||||||
|
this._updatedAt = _updatedAt
|
||||||
|
}
|
||||||
|
|
||||||
|
delete() {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { ChatUserService } from 'src/app/services/chat/chat-user.service'
|
|||||||
})
|
})
|
||||||
export class RoomService {
|
export class RoomService {
|
||||||
|
|
||||||
massages: {[key: string]: MessageService} = {}
|
massages: MessageService[] = []
|
||||||
lastMessage: MessageService;
|
lastMessage: MessageService;
|
||||||
|
|
||||||
chatUser: ChatUserService[] = []
|
chatUser: ChatUserService[] = []
|
||||||
@@ -35,8 +35,7 @@ export class RoomService {
|
|||||||
this.id,
|
this.id,
|
||||||
this.constructor.name+this.id,
|
this.constructor.name+this.id,
|
||||||
(Chatmessage)=>{
|
(Chatmessage)=>{
|
||||||
this.hasLoadHistory = false
|
this.massages.push(Chatmessage.result)
|
||||||
this.loadHistory()
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -50,9 +49,15 @@ export class RoomService {
|
|||||||
|
|
||||||
if(this.hasLoadHistory){ return false }
|
if(this.hasLoadHistory){ return false }
|
||||||
|
|
||||||
this.RocketChatClientService.loadHistory(this.id, limit).then((message:any)=>{
|
this.RocketChatClientService.loadHistory(this.id, limit).then((message:any) => {
|
||||||
console.log('loadHistory', message)
|
console.log('loadHistory', message)
|
||||||
this.mmm = message.result.messages.reverse()
|
|
||||||
|
message.result.messages.reverse().forEach(element => {
|
||||||
|
const message = new MessageService()
|
||||||
|
message.setData(element)
|
||||||
|
this.massages.push(message)
|
||||||
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.hasLoadHistory = true
|
this.hasLoadHistory = true
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
</ion-refresher-content>
|
</ion-refresher-content>
|
||||||
</ion-refresher>
|
</ion-refresher>
|
||||||
<div class="messages" #scrollMe>
|
<div class="messages" #scrollMe>
|
||||||
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of ChatServiceGPR.getRoom(roomId).mmm; let last = last">
|
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of ChatServiceGPR.getRoom(roomId).massages; let last = last">
|
||||||
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
|
<div class='message-item incoming-{{msg.u.username!=loggedUser.me.username}} max-width-45' *ngIf="msg.msg !=''">
|
||||||
<div class="message-item-options d-flex justify-content-end">
|
<div class="message-item-options d-flex justify-content-end">
|
||||||
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
<fa-icon [matMenuTriggerFor]="beforeMenu" icon="chevron-down" class="message-options-icon cursor-pointer"></fa-icon>
|
||||||
|
|||||||
Reference in New Issue
Block a user