diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index bef7ee9c6..a276e2417 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -264,9 +264,6 @@ export class WsChatMethodsService { * @param roomData */ prepareRoom(roomData) { - let room:RoomService; - - room = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService) const setData = { @@ -277,36 +274,40 @@ export class WsChatMethodsService { lastMessage: this.getRoomLastMessage(roomData), _updatedAt: new Date(roomData._updatedAt['$date']) } - - room.setData(setData) - - room.receiveMessage() - room.getAllUsers = this.getUsers - room.receiveMessageDelete(); - room.sortRoomList = this.sortRoomList - + let roomId = this.getRoomId(roomData) - if(this.isIndividual(roomData)) { - - if(!this.dm[roomId]) { + if(!this.dm[roomId] && !this.group[roomId]) { + let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService) + room.setData(setData) + room.receiveMessage() + 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.dm[roomId].setData(setData) - } - - } else { - if(this.group[roomId]) { this.group[roomId] = room this._group.push(room) this.groupCount++ - } else { + + } + } else { + + if(this.dm[roomId]) { + this.dm[roomId].setData(setData) + } else if(this.group[roomId]) { this.group[roomId].setData(setData) } } + + }