This commit is contained in:
tiago.kayaya
2022-02-11 17:15:01 +01:00
parent 9eb51720b9
commit de1f91935e
8 changed files with 43 additions and 137 deletions
+3 -3
View File
@@ -235,7 +235,7 @@ export class ChatPage implements OnInit {
this.idSelected = '';
this.groupRoomId = data;
this.closeAllDesktopComponents();
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
}
else {
@@ -270,7 +270,7 @@ export class ChatPage implements OnInit {
}
openNewGroupPage() {
this.idSelected = '';
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
this.newGroup();
}
else {
@@ -280,7 +280,7 @@ export class ChatPage implements OnInit {
}
openEditGroupPage(rid) {
if (window.innerWidth < 801) {
if (window.innerWidth < 701) {
this.editGroup(rid);
}
else {
@@ -87,62 +87,6 @@ export class NewGroupPage implements OnInit {
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
//this.addGroupMessage.emit(res.result.rid);
/*
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
//this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}
this.isGroupCreated = true;
this.addContacts(res['group']);
if(this.documents.length > 0){
//If there is documents add
this.documents.forEach(async document => {
let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
let body = {
"message":
{
"rid": res['group']._id,
"msg": "",
"attachments": [{
"title": document.Assunto,
"description": document.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix"
}],
"file":{
"name": document.Assunto,
"type": "application/webtrix",
"ApplicationId": document.ApplicationType,
"DocId": document.Id,
"Assunto": document.Assunto,
}
}
}
this.chatService.sendMessage(body).toPromise();
});
}
}); */
}
async addContacts(room){
+1 -1
View File
@@ -83,8 +83,8 @@ export class ChatService {
params: params
}
return this.http.get(environment.apiChatUrl+'rooms.info', opts);
}
customsRooms(params:any){
let opts = {
headers: this.headers,
@@ -44,7 +44,7 @@ export class WsChatMethodsService {
private NfService: NfService,
private changeProfileService: ChangeProfileService,
) {
this.loadChat()
this.WsChatService.registerCallback({
@@ -63,7 +63,7 @@ export class WsChatMethodsService {
for (const id in this.dm) {
this.dm[id].hasLoadHistory = false
}
for (const id in this.group) {
this.group[id].hasLoadHistory = false
}
@@ -77,7 +77,7 @@ export class WsChatMethodsService {
this.storage.remove('Rooms');
})
// this.WsChatService.registerCallback({
// type:'Onmessage',
// funx:(message) => {
@@ -95,7 +95,7 @@ export class WsChatMethodsService {
// }
// } else if(message.msg =='changed' && message.collection == "stream-notify-room") {
// if(message.fields.eventName.includes('deleteMessage')) {
// // delete message
// // delete message
// const DeletedMessageId = message.fields.args[0]._id;
// setTimeout(()=>{
@@ -129,7 +129,7 @@ export class WsChatMethodsService {
clearChat() {
this.dm = {}
this.group = {}
this.group = {}
this._dm = []
this._group = []
@@ -137,7 +137,7 @@ export class WsChatMethodsService {
this.dmCount = 0;
this.groupCount = 0;
this.currentRoom = null
this.users = []
}
@@ -159,11 +159,11 @@ export class WsChatMethodsService {
if(this.getDmRoom(roomId)) {
this.currentRoom = this.getDmRoom(roomId)
} else if(this.getGroupRoom(roomId)) {
this.currentRoom = this.getGroupRoom(roomId)
this.currentRoom = this.getGroupRoom(roomId)
}
this.currentRoom.open()
}
@@ -176,7 +176,7 @@ export class WsChatMethodsService {
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
});
}
} catch(e){}
@@ -274,7 +274,7 @@ export class WsChatMethodsService {
lastMessage: this.getRoomLastMessage(roomData),
_updatedAt: new Date(roomData._updatedAt['$date'])
}
let roomId = this.getRoomId(roomData)
if(!this.dm[roomId] && !this.group[roomId]) {
@@ -284,18 +284,18 @@ export class WsChatMethodsService {
room.getAllUsers = this.getUsers
room.receiveMessageDelete();
room.sortRoomList = this.sortRoomList
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
} else {
this.group[roomId] = room
this._group.push(room)
this.groupCount++
}
} else {
@@ -376,7 +376,24 @@ export class WsChatMethodsService {
return this.WsChatService.leaveRoom(id);
}
async hideRoom(id) {
this._dm.forEach((md, index)=>{
if(md.id == id) {
this._dm.splice(index, 1)
delete this.dm[id]
}
});
this._group.forEach((group, index)=>{
if(group.id == id) {
this._group.splice(index, 1)
delete this.group[id]
}
})
}
hidingRoom(id?) {
//this.hideRoom(id);
return this.WsChatService.hidingRoom(id);
}
+4 -2
View File
@@ -254,6 +254,8 @@ export class WsChatService {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId ) { // same request send
resolve(message)
console.log(message);
return true
}
}})
@@ -636,7 +638,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
setTimeout(()=>{
this.ws.wsMsgQueue()
}, 10)
if(this.wsReconnect >= 1) {
for (const [key, value] of Object.entries(this.wsCallbacks)) {
if(value.type== 'reConnect') {
@@ -679,7 +681,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
} else {
let messageStr = JSON.stringify(message)
// console.log('messageStr', messageStr)
this.socket.send(messageStr)
}
return requestId
@@ -367,9 +367,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
console.log(res);
if (res.data == 'leave') {
this.getRoomInfo();
this.wsChatMethodsService.hidingRoom(this.roomId);
this.closeAllDesktopComponents.emit();
this.showEmptyContainer.emit();
this.wsChatMethodsService.hidingRoom(this.roomId);
}
else if (res.data == 'delete') {
this.closeAllDesktopComponents.emit();
@@ -113,64 +113,6 @@ export class NewGroupPage implements OnInit{
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
this.addGroupMessage.emit(res.result.rid);
/*
let body = { "name":name, }
this.chatService.addGroup(body).subscribe(res=>{
console.log('group created');
console.log(res['group']);
this.addGroupMessage.emit(res['group']._id); */
/* this.addGroupMessage.emit(res['group']._id);
if(this.thedate){
let countDownBody = {
"roomId": res['group']._id,
"customFields":{"countDownDate":this.thedate}
}
this.chatService.setGroupCustomFields(countDownBody).subscribe(res=>{
console.log(res);
});
}
if(this.documents.length > 0){
//If there is documents add
this.documents.forEach(async document => {
let url = await this.processesService.GetDocumentUrl(document.DocId, document.ApplicationId).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
let body = {
"message":
{
"rid": res['group']._id,
"msg": "",
"attachments": [{
"title": document.Assunto,
"description": document.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
//"thumb_url": "assets/images/webtrix-logo.png",
"message_link": url_no_options,
"type": "webtrix"
}],
"file":{
"name": document.Assunto,
"type": "application/webtrix",
"ApplicationId": document.ApplicationType,
"DocId": document.Id,
"Assunto": document.Assunto,
}
}
}
this.chatService.sendMessage(body).toPromise();
});
} */
//});
}
async addContacts(){
@@ -35,7 +35,7 @@ export class ChatPopoverPage implements OnInit {
}
close(action:any){
if( window.innerWidth <= 701){
if( window.innerWidth < 701){
this.popoverController.dismiss(action);
this.modalController.dismiss(action);
}
@@ -50,7 +50,7 @@ export class ChatPopoverPage implements OnInit {
async setRoomOwner(){
let classs;
if (window.innerWidth <= 800) {
if (window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'centered-rounded-modal'
@@ -68,6 +68,7 @@ export class ChatPopoverPage implements OnInit {
modal.onDidDismiss().then((res)=>{
if(res.data == 'success'){
this.leaveGroup();
//this.wsChatMethodsService.hidingRoom(this.roomId);
}
});
}