-
+
diff --git a/src/app/services/chat/room.service.ts b/src/app/services/chat/room.service.ts
index df2588caf..6c4b96aec 100644
--- a/src/app/services/chat/room.service.ts
+++ b/src/app/services/chat/room.service.ts
@@ -432,6 +432,7 @@ export class RoomService {
private calDateDuration(date = null) {
this.duration = showDateDuration(date || this._updatedAt);
+ this._updatedAt = date || this._updatedAt
}
diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts
index 3dbac3ea1..43ee37415 100644
--- a/src/app/services/chat/ws-chat-methods.service.ts
+++ b/src/app/services/chat/ws-chat-methods.service.ts
@@ -19,6 +19,10 @@ export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {}
+
+ _dm = []
+ _group = []
+
loadingWholeList = false
dmCount = 0;
@@ -45,31 +49,43 @@ export class WsChatMethodsService {
const rooms = await this.WsChatService.getRooms();
- const sortedRoomList = this.sortService.sortDate(rooms.result.update, "_updatedAt.$date")
-
this.WsChatService.registerCallback({
type:'Onmessage',
funx:(message)=>{
if(message.msg =='changed' && message.collection == "stream-room-messages") {
if(message.fields.args[0].rid) {
- const sortedRoomList = this.sortService.sortDate(rooms.result.update, "_updatedAt.$date")
+
+ setTimeout(()=>{
+ console.log('sort this._dm', this._dm)
+ this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
+ this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
+ }, 100)
+
+ }
+
+ }
+
+ if(message.msg =='changed' && message.collection == "stream-notify-room") {
+ if(message.fields.eventName.includes('deleteMessage')){
+ setTimeout(()=>{
+ console.log('sort this._dm', this._dm)
+ this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
+ this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
+ }, 100)
}
}
}
})
- console.log(rooms.result.update);
- console.log(sortedRoomList);
-
-
- //console.log("ROOMS" + JSON.stringify(rooms))
-
- sortedRoomList.forEach((roomData: room) => {
- this.prepareRoom(roomData);
+ await rooms.result.update.forEach( async (roomData: room) => {
+ await this.prepareRoom(roomData);
});
+ this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
+ this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
+
/* function compare( a, b ) {
if ( a.last_nom < b.last_nom ){
return -1;
@@ -161,9 +177,11 @@ export class WsChatMethodsService {
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++
}
}
diff --git a/src/app/services/functions/sort.service.ts b/src/app/services/functions/sort.service.ts
index 5c35022f8..6f65ab277 100644
--- a/src/app/services/functions/sort.service.ts
+++ b/src/app/services/functions/sort.service.ts
@@ -26,12 +26,18 @@ export class SortService {
}
sortDate(array = [], path: string) {
+
return array.sort( (a,b)=> {
- console.log("AAA"+new Date(this.ObjectService.deepFind(a, path)));
- console.log("BB"+new Date(this.ObjectService.deepFind(b, path)));
- //return (new Date(this.ObjectService.deepFind(a, path)) < new Date(this.ObjectService.deepFind(b, path))) ? -1 : ((new Date(this.ObjectService.deepFind(a, path)) > new Date(this.ObjectService.deepFind(b, path))) ? 1 : 0);
- return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime();
+
+ /* console.log("AAA"+new Date(this.ObjectService.deepFind(a, path)));
+
+ console.log("BB"+new Date(this.ObjectService.deepFind(b, path))); */
+
+ return (new Date(this.ObjectService.deepFind(a, path)) < new Date(this.ObjectService.deepFind(b, path))) ? -1 : ((new Date(this.ObjectService.deepFind(a, path)) > new Date(this.ObjectService.deepFind(b, path))) ? 1 : 0);
+
+ //return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime();
})
+
}
}