mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
fix bug in create new room
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
<div class="item-date" [class.item-date-active]="group.value.id ==idSelected" *ngIf="group.value.customFields.countDownDate">{{countDownDate(group.value.customFields.countDownDate, group.value.id)}}</div>
|
||||
</div>
|
||||
<div *ngIf="group.value.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.value.id ==idSelected">
|
||||
<div class="item-message">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div>
|
||||
<div *ngIf="group.value.lastMessage.u.name" class="item-message">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div>
|
||||
<div class="item-files add-ellipsis" *ngIf="group.value.file">
|
||||
<fa-icon *ngIf="group.value.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon>
|
||||
<fa-icon *ngIf="group.value.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon>
|
||||
|
||||
@@ -298,7 +298,6 @@ export class ChatPage implements OnInit {
|
||||
this.openGroupMessagesModal(rid);
|
||||
}
|
||||
else {
|
||||
alert('HERE OPEN')
|
||||
this.idSelected = rid;
|
||||
this.closeAllDesktopComponents();
|
||||
this.showEmptyComponent = false;
|
||||
|
||||
@@ -39,7 +39,7 @@ export class RoomService {
|
||||
private sqlservice: SqliteService,
|
||||
) { }
|
||||
|
||||
setData({ customFields, id, name, t, lastMessage, _updatedAt }) {
|
||||
setData({ customFields, id, name, t, lastMessage = new MessageService(), _updatedAt }) {
|
||||
this.customFields = customFields
|
||||
this.id = id
|
||||
this.name = name
|
||||
@@ -62,6 +62,7 @@ export class RoomService {
|
||||
/* this.ToastService._chatMessage({message:'Nova mensagem', sender:'Gilson'}) */
|
||||
const message = new MessageService()
|
||||
message.setData(ChatMessage)
|
||||
|
||||
this.lastMessage.msg = message.msg
|
||||
if (message.t == 'r') { this.name = message.msg }
|
||||
this.calDateDuration(ChatMessage._updatedAt)
|
||||
|
||||
@@ -46,35 +46,7 @@ export class WsChatMethodsService {
|
||||
// console.log("ROOMS" + JSON.stringify(rooms))
|
||||
|
||||
rooms.result.update.forEach((roomData: room) => {
|
||||
let room:RoomService;
|
||||
|
||||
//console.log(roomData);
|
||||
|
||||
|
||||
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice)
|
||||
room.setData({
|
||||
customFields: roomData.customFields,
|
||||
id: this.getRoomId(roomData),
|
||||
name: this.getRoomName(roomData),
|
||||
t: roomData.t,
|
||||
lastMessage: this.getRoomLastMessage(roomData),
|
||||
_updatedAt: new Date(roomData._updatedAt['$date'])
|
||||
})
|
||||
|
||||
room.receiveMessage()
|
||||
|
||||
let roomId = this.getRoomId(roomData)
|
||||
|
||||
if(this.isIndividual(roomData)) {
|
||||
this.dm[roomId] = room
|
||||
this.dmCount++
|
||||
} else {
|
||||
this.group[roomId] = room
|
||||
this.groupCount++
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.prepareRoom(roomData);
|
||||
});
|
||||
|
||||
this.loadingWholeList = false
|
||||
@@ -99,6 +71,52 @@ export class WsChatMethodsService {
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
subscribeToRoomUpdate(id, roomData) {
|
||||
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
})
|
||||
this.WsChatService.streamRoomMessages(id).then((subscription)=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
})
|
||||
this.WsChatService.streamNotifyLogged().then((subscription=>{
|
||||
console.log('streamRoomMessages', subscription)
|
||||
}))
|
||||
|
||||
this.prepareRoom(roomData);
|
||||
|
||||
this.getGroupRoom(id).loadHistory();
|
||||
|
||||
}
|
||||
|
||||
prepareRoom(roomData){
|
||||
let room:RoomService;
|
||||
|
||||
room = new RoomService(this.WsChatService, new MessageService(), this.storage, this.platform, this.sqlservice)
|
||||
room.setData({
|
||||
customFields: roomData.customFields,
|
||||
id: this.getRoomId(roomData),
|
||||
name: this.getRoomName(roomData),
|
||||
t: roomData.t,
|
||||
lastMessage: this.getRoomLastMessage(roomData),
|
||||
_updatedAt: new Date(roomData._updatedAt['$date'])
|
||||
})
|
||||
|
||||
room.receiveMessage()
|
||||
|
||||
let roomId = this.getRoomId(roomData)
|
||||
|
||||
if(this.isIndividual(roomData)) {
|
||||
this.dm[roomId] = room
|
||||
this.dmCount++
|
||||
} else {
|
||||
this.group[roomId] = room
|
||||
this.groupCount++
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
leaveRoom(id?) {
|
||||
return this.WsChatService.leaveRoom(id);
|
||||
}
|
||||
@@ -111,6 +129,10 @@ export class WsChatMethodsService {
|
||||
return this.WsChatService.addRoomOwner(roomid, userId);
|
||||
}
|
||||
|
||||
createPrivateRoom(groupName, username, customFields){
|
||||
return this.WsChatService.createPrivateRoom(groupName, username, customFields);
|
||||
}
|
||||
|
||||
getDmRoom(id): RoomService {
|
||||
try {
|
||||
return this.dm[id]
|
||||
@@ -142,7 +164,7 @@ export class WsChatMethodsService {
|
||||
return roomData._id
|
||||
}
|
||||
|
||||
getRoomLastMessage(roomData: room) {
|
||||
getRoomLastMessage(roomData: room):any {
|
||||
return roomData.lastMessage
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,36 @@ export class WsChatService {
|
||||
|
||||
joinRoom(){}
|
||||
deleteMessage() {}
|
||||
createRoom() {}
|
||||
createPrivateRoom(groupName, username, customFields) {
|
||||
const requestId = uuidv4()
|
||||
|
||||
var message = {
|
||||
msg: "method",
|
||||
method: "createPrivateGroup",
|
||||
id: requestId,
|
||||
params: [
|
||||
groupName,
|
||||
[username],
|
||||
false,
|
||||
customFields,
|
||||
{
|
||||
"broadcast":false,
|
||||
"encrypted":false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
this.ws.send({message, requestId});
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
|
||||
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
|
||||
resolve(message)
|
||||
return true
|
||||
}
|
||||
}})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ import { analyzeAndValidateNgModules } from '@angular/compiler';
|
||||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
import { ModalController, NavParams, PickerController, PopoverController } from '@ionic/angular';
|
||||
import { AuthService } from 'src/app/services/auth.service';
|
||||
import { ChatService } from 'src/app/services/chat.service';
|
||||
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
||||
import { DataService } from 'src/app/services/data.service';
|
||||
import { ProcessesService } from 'src/app/services/processes.service';
|
||||
import { GroupDurationPage } from 'src/app/shared/popover/group-duration/group-duration.page';
|
||||
@@ -25,6 +27,7 @@ export class NewGroupPage implements OnInit{
|
||||
//groupName:string;
|
||||
task:any;
|
||||
documents: any;
|
||||
loggedUserChat: any;
|
||||
|
||||
@Input() groupName:string;
|
||||
@Output() addGroupMessage:EventEmitter<any> = new EventEmitter<any>();
|
||||
@@ -37,8 +40,11 @@ export class NewGroupPage implements OnInit{
|
||||
private dataService:DataService,
|
||||
private processesService: ProcessesService,
|
||||
private router: Router,
|
||||
public wsChatMethodsService: WsChatMethodsService,
|
||||
private authService: AuthService,
|
||||
)
|
||||
{
|
||||
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
||||
this.isGroupCreated = false;
|
||||
//this.groupName = this.navParams.get('name');
|
||||
}
|
||||
@@ -86,16 +92,37 @@ export class NewGroupPage implements OnInit{
|
||||
this.addGroupMessage.emit();
|
||||
}
|
||||
|
||||
createGroup(){
|
||||
async createGroup(){
|
||||
let name = this.groupName.split(' ').join('-');
|
||||
//Take out all special characters in string
|
||||
name = name.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
let body = { "name":name, }
|
||||
this.chatService.addGroup(body).subscribe(res=>{
|
||||
|
||||
let customFields = {}
|
||||
let res:any;
|
||||
|
||||
if(this.thedate){
|
||||
let customFields = {
|
||||
"countDownDate":this.thedate
|
||||
}
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
else{
|
||||
res = await this.wsChatMethodsService.createPrivateRoom(name, this.loggedUserChat.me.username, customFields);
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
this.wsChatMethodsService.subscribeToRoomUpdate(res.result.rid, res.result);
|
||||
this.addGroupMessage.emit(res.result.rid);
|
||||
|
||||
/* 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); */
|
||||
|
||||
/* this.addGroupMessage.emit(res['group']._id);
|
||||
|
||||
if(this.thedate){
|
||||
let countDownBody = {
|
||||
@@ -139,11 +166,11 @@ export class NewGroupPage implements OnInit{
|
||||
}
|
||||
this.chatService.sendMessage(body).toPromise();
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
|
||||
|
||||
});
|
||||
//});
|
||||
}
|
||||
|
||||
async addContacts(){
|
||||
|
||||
Reference in New Issue
Block a user