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
@@ -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);
}