From 243cbf0fc7faf9d9ee48bc52ef76ae1a3e034f27 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Mon, 20 Jan 2020 17:26:38 +0900 Subject: [PATCH] bug fixed --- .../src/lib/components/messages.component.ts | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) 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 546f53bd..7c78ab41 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 @@ -7,7 +7,8 @@ import { ViewChild, OnDestroy, ChangeDetectionStrategy, - ElementRef + ElementRef, + ChangeDetectorRef } from '@angular/core'; import { @@ -146,6 +147,7 @@ export class MessagesComponent implements OnInit, OnDestroy { constructor( private logger: NGXLogger, private datePipe: DatePipe, + private changeDetectorRef: ChangeDetectorRef, private translateService: TranslateService ) {} @@ -157,12 +159,12 @@ export class MessagesComponent implements OnInit, OnDestroy { this.loginRes = loginRes; }); this.roomInfoSubscription = this.roomInfo$.subscribe(roomInfo => { - this.eventList = undefined; - this.newEventList = undefined; - this.searchedList = undefined; - this.eventInfoStatus = undefined; - this.eventRemained = undefined; - this.userInfos = undefined; + // this.eventList = undefined; + // this.newEventList = undefined; + // this.searchedList = undefined; + // this.eventInfoStatus = undefined; + // this.eventRemained = undefined; + // this.userInfos = undefined; this.initEventMore(); this.roomInfo = roomInfo; @@ -180,6 +182,7 @@ export class MessagesComponent implements OnInit, OnDestroy { } this.eventList = eventList; + this.changeDetectorRef.detectChanges(); if (this.searchingMode) { const baseseq = this.baseEventSeq; @@ -284,6 +287,9 @@ export class MessagesComponent implements OnInit, OnDestroy { } getUnreadCount(message: Info): string | number { + // if (!this.userInfos || 0 === this.userInfos.length) { + // return ''; + // } const unreadCnt = this.userInfos.filter(user => { if (message.senderSeq === user.seq) { // 본인 글은 unreadCount 에 포함하지 않는다. @@ -392,9 +398,6 @@ export class MessagesComponent implements OnInit, OnDestroy { setTimeout(() => { this.scrollToBottom(); - // setTimeout(() => { - // this.chatMessagesContainer.nativeElement.classList.remove('hide'); - // }, 100); }); } @@ -433,23 +436,15 @@ export class MessagesComponent implements OnInit, OnDestroy { this.firstCheckReadHere = false; } else { - this.virtualScroller.scrollInto( - this.eventList[this.eventList.length - 1], + this.virtualScroller.scrollToIndex( + this.eventList.length - 1, true, 0, 0, () => { - if (!this.scrollUpInitalized) { - this.chatMessagesContainer.nativeElement.classList.remove( - 'hide' - ); - } + this.chatMessagesContainer.nativeElement.classList.remove('hide'); } ); - - // setTimeout(() => { - // this.psChatContent.scrollToBottom(0, speed); - // }); } } }