mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
save
This commit is contained in:
@@ -138,39 +138,21 @@ export class ChatPage implements OnInit {
|
||||
|
||||
this.showLoader = true;
|
||||
|
||||
console.log("CHAT PAGE");
|
||||
|
||||
/* wsService.messages.subscribe(msg => {
|
||||
console.log("Response from Websocket server: "+msg);
|
||||
}); */
|
||||
|
||||
//this.load()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
console.log(this.loggedUserChat);
|
||||
|
||||
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")){
|
||||
@@ -232,28 +214,6 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
/* loadWsChatMessages(){
|
||||
this.chatService.messages.subscribe(msg => {
|
||||
console.log("Response from Websocket server: "+msg);
|
||||
});
|
||||
} */
|
||||
|
||||
|
||||
/* loadMessage(){
|
||||
this.wsService.messages.subscribe(msg => {
|
||||
console.log("Response from websocket: " + msg);
|
||||
});
|
||||
}
|
||||
sendMsg() {
|
||||
console.log("new message from client to websocket: ", this.message);
|
||||
this.wsService.messages.next(this.message);
|
||||
this.message.msg = "";
|
||||
this.loadMessage();
|
||||
} */
|
||||
|
||||
|
||||
/* Fim websockets functions */
|
||||
|
||||
closeAllDesktopComponents() {
|
||||
this.showMessages = false;
|
||||
this.showContacts = false;
|
||||
@@ -396,33 +356,20 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
|
||||
onSegmentChange() {
|
||||
this.load();
|
||||
//this.load();
|
||||
}
|
||||
|
||||
doRefresh(event) {
|
||||
setTimeout(() => {
|
||||
this.load();
|
||||
//this.load();
|
||||
event.target.complete();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
refreshing() {
|
||||
this.load();
|
||||
//this.load();
|
||||
}
|
||||
|
||||
load() {
|
||||
switch (this.segment) {
|
||||
case "Contactos":
|
||||
this.showLoader = true;
|
||||
this.getDirectMessages();
|
||||
break;
|
||||
|
||||
case "Grupos":
|
||||
this.showLoader = true;
|
||||
this.getGroups();
|
||||
break;
|
||||
}
|
||||
}
|
||||
customRoom() {
|
||||
let params = new HttpParams();
|
||||
params = params.set("types", "c");
|
||||
@@ -558,47 +505,6 @@ export class ChatPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async getDirectMessages(event?) {
|
||||
this.chatService.getAllDirectMessages().subscribe(async (res: any) => {
|
||||
this.showLoader = false;
|
||||
this.transformDataRoomList(res.ims)
|
||||
this.getDirectMessagesDB()
|
||||
//console.log('Chat list', res);
|
||||
|
||||
if (res != 200) {
|
||||
/* if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
||||
this.userDirectMessages = res.ims.sort((a, b) => {
|
||||
var dateA = new Date(a._updatedAt).getTime();
|
||||
var dateB = new Date(b._updatedAt).getTime();
|
||||
return dateB - dateA;
|
||||
});
|
||||
} */
|
||||
//console.log(res.ims);
|
||||
|
||||
//console.log(this.userDirectMessages);
|
||||
|
||||
if (this.route.url != "/home/chat") {
|
||||
//console.log("Timer message stop")
|
||||
}
|
||||
else {
|
||||
//console.log('TIMER');
|
||||
//Check if modal is opened
|
||||
if (this.segment == "Contactos" && this.showMessages != true) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
//await this.getDirectMessages();
|
||||
//console.log('Timer contactos list running')
|
||||
}
|
||||
else {
|
||||
//console.log('No timer!');
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//await this.getDirectMessages();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
showDateDuration(start: any) {
|
||||
return this.timeService.showDateDuration(start);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<ion-label>Esta conversa passou a grupo TIAGO</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 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 != '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>
|
||||
|
||||
@@ -23,6 +23,7 @@ import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
@@ -82,7 +83,8 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private fileService: FileService,
|
||||
private toastService: ToastService,
|
||||
public ThemeService: ThemeService,
|
||||
private changeDetectorRef: ChangeDetectorRef
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
public wsChatMethodsService: WsChatMethodsService
|
||||
) {
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = true;
|
||||
@@ -92,6 +94,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.modalController.dismiss();
|
||||
}
|
||||
};
|
||||
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
Reference in New Issue
Block a user