This commit is contained in:
Peter Maquiran
2022-03-21 15:12:20 +01:00
11 changed files with 60 additions and 33 deletions
@@ -210,6 +210,7 @@ export class WsChatMethodsService {
* @description sort room list by last message date
*/
sortRoomList =() => {
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
}
@@ -265,6 +266,16 @@ export class WsChatMethodsService {
})
}
private fix_updatedAt(message) {
if (message.result) {
message.result._updatedAt = message.result._updatedAt['$date']
} else if(message._updatedAt) {
if(message._updatedAt.hasOwnProperty('$date')) {
message._updatedAt = message._updatedAt['$date']
}
}
return message
}
/**
* @description create a representation of an room in these instance this.dm, this.group ...
@@ -276,13 +287,16 @@ export class WsChatMethodsService {
/**
* @description data used to define or create room
*/
roomData = this.fix_updatedAt(roomData)
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']),
_updatedAt: new Date( roomData._updatedAt || roomData._updatedAt['$date']),
u : roomData.u || {},
members: roomData.members
}
@@ -297,7 +311,7 @@ export class WsChatMethodsService {
room.getAllUsers = this.getUsers
room.receiveMessageDelete();
room.sortRoomList = this.sortRoomList
// create individual room
if(this.isIndividual(roomData)) {
@@ -412,9 +426,9 @@ export class WsChatMethodsService {
}
hidingRoom(id?) {
return this.WsChatService.hidingRoom(id).then(()=>{
// this.hideRoom(id)
// this.hideRoom(id)
})
}