This commit is contained in:
Peter Maquiran
2022-02-10 21:50:15 +01:00
parent 54020c2247
commit 4b66eb6713
4 changed files with 28 additions and 21 deletions
@@ -193,11 +193,6 @@ export class WsChatMethodsService {
console.log('rooms', rooms)
this.dm = {}
this.group = {}
this._dm = []
this._group = []
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
});
@@ -273,14 +268,17 @@ export class WsChatMethodsService {
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)
room.setData({
const 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.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
@@ -290,13 +288,24 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData)
if(this.isIndividual(roomData)) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
if(!this.dm[roomId]) {
this.dm[roomId] = room
this._dm.push(room)
this.dmCount++
} else {
this.dm[roomId].setData(setData)
}
} else {
this.group[roomId] = room
this._group.push(room)
this.groupCount++
if(this.group[roomId]) {
this.group[roomId] = room
this._group.push(room)
this.groupCount++
} else {
this.group[roomId].setData(setData)
}
}
}