From aed1c7fb6710dcc757caa693c2aa5bc1a822607c Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 21 Jan 2020 16:36:48 +0900 Subject: [PATCH] =?UTF-8?q?=EC=97=AC=EA=B8=B0=EA=B9=8C=EC=A7=80=20?= =?UTF-8?q?=EC=9D=BD=EC=9D=8C=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/components/messages.component.html | 2 +- .../src/lib/components/messages.component.ts | 27 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html index d2fbc690..c718c1c0 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.html @@ -58,7 +58,7 @@ [mine]="message.senderSeq === loginRes.userSeq" [highlight]="isHighlightedEvent(message.seq)" [existReadToHere]=" - readToHereEvent && readToHereEvent.seq === message.seq + !!readToHereEvent && readToHereEvent.seq === message.seq " [dateChanged]="getDateSplitter(message)" [senderName]="getUserName(message.senderSeq)" diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 4c20b283..dc65835c 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -169,20 +169,26 @@ export class MessagesComponent implements OnInit, OnDestroy { this.roomInfo = roomInfo; }); this.eventListSubscription = this.eventList$.subscribe(eventList => { + if (!!eventList && eventList.length > 0 && this.baseEventSeq === 0) { + this.initRoomLastEventSeq = eventList[eventList.length - 1].seq; + } + if ( !!eventList && eventList.length > 0 && + this.baseEventSeq > 0 && !!this.roomInfo && !!this.roomInfo.lastReadEventSeq && this.baseEventSeq <= this.roomInfo.lastReadEventSeq ) { - // 조회된 내용중에 read here 가 있을 경우. + // 기존 대화 내용이 있는 상태에서 추가로 조회된 내용중에 read here 가 있을 경우. this.firstCheckReadHere = false; } - this.readToHereEvent = eventList.find(e => this.getReadHere(e)); - this.eventList = eventList; + + this.readToHereEvent = this.getReadHere(); + this.changeDetectorRef.detectChanges(); if (this.searchingMode) { @@ -339,7 +345,7 @@ export class MessagesComponent implements OnInit, OnDestroy { return false; } - getReadHere(message: Info): boolean { + getReadHere(): Info | undefined { if ( !!this.roomInfo && !!this.roomInfo.lastReadEventSeq && @@ -351,20 +357,13 @@ export class MessagesComponent implements OnInit, OnDestroy { this.roomInfo.roomType === RoomType.Multi ) { if (!this.roomInfo.isTimeRoom) { - const messageIndex = this.eventList.findIndex( - v => v.seq === message.seq + return this.eventList.find( + v => v.seq === this.roomInfo.lastReadEventSeq + 1 ); - - if ( - this.eventList[messageIndex].seq === - this.roomInfo.lastReadEventSeq + 1 - ) { - return true; - } } } } - return false; + return undefined; } getStringReadHereMore(): string {