From c00b6e444c11ae492a99c424eea1b02dd2fe50da Mon Sep 17 00:00:00 2001 From: Peter Maquiran Date: Sat, 29 Jan 2022 19:44:20 +0100 Subject: [PATCH] improve code --- .../services/chat/ws-chat-methods.service.ts | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/app/services/chat/ws-chat-methods.service.ts b/src/app/services/chat/ws-chat-methods.service.ts index ba9068d47..ebb3792a3 100644 --- a/src/app/services/chat/ws-chat-methods.service.ts +++ b/src/app/services/chat/ws-chat-methods.service.ts @@ -91,39 +91,35 @@ export class WsChatMethodsService { if(message.fields.args[0].rid) { 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() + this.sortRoomList() + }, 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() + + this.sortRoomList() }, 100) } } } }) - 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() - + this.sortRoomList() this.loadingWholeList = false } - + sortRoomList() { + this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse() + this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse() + } subscribeToRoom() {