From 56892c18c53c94d0060b5e7c2b3cdbc44b107f1e Mon Sep 17 00:00:00 2001 From: leejh Date: Wed, 6 Nov 2019 19:11:08 +0900 Subject: [PATCH] =?UTF-8?q?bugfix=20::=20=EC=8A=A4=ED=81=AC=EB=A1=A4?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EC=A0=84=EB=8C=80=ED=99=94=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84.=20>=20perf?= =?UTF-8?q?ect=20scroll=20=EC=97=90=EC=84=9C=20=EC=B4=88=EA=B8=B0=20init?= =?UTF-8?q?=20=EC=8B=9C=20psYReachStart=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EA=B0=80=20=EB=AC=B4=EC=A1=B0=EA=B1=B4=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=ED=95=98=EC=97=AC=20=EC=9D=B4=EC=A0=84=EB=8C=80=ED=99=94=20?= =?UTF-8?q?=EB=8D=94=EB=B3=B4=EA=B8=B0=EB=A5=BC=20=EA=B0=95=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=ED=96=89=ED=95=98=EB=8D=98=20=EB=B2=84=EA=B7=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=88=98=EC=A0=95.=20>=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A1=A4=20UP=20=EC=97=90=20=EC=97=B0=EC=86=8D=ED=95=9C=20reac?= =?UTF-8?q?hStart=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=B0=9C=EC=83=9D?= =?UTF-8?q?=EC=8B=9C=EC=97=90=EB=A7=8C=20=EC=9D=B4=EC=A0=84=EB=8C=80?= =?UTF-8?q?=ED=99=94=20=EB=B3=B4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20?= =?UTF-8?q?=EC=88=98=ED=96=89=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.=20>=20=EB=B0=A9=EC=A0=95=EB=B3=B4=EA=B0=80=20?= =?UTF-8?q?=EB=B0=94=EB=80=8C=EB=A9=B4=20=ED=95=B4=EB=8B=B9=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=EB=A5=BC=20=EA=B5=AC=EB=B6=84=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B5=AC=EB=B6=84=EC=9E=90=EB=93=A4=EC=9D=84=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=ED=95=A8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/messages.component.html | 1 + .../components/messages.component.ts | 45 ++++++++++++++----- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html index f0bf30c8..b8ca98d6 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.html @@ -95,6 +95,7 @@ ; eventInfoStatus$: Observable; - eventRemain$: Observable; - eventRemain = false; sessionVerInfo: VersionInfo2Response; + eventRemain$: Observable; + eventRemain = false; // 이전대화가 남아 있는지 여부 + eventMorePosition = 0; // 이전대화를 불러올 경우 현재 스크롤 포지션 유지를 위한 값. 0 이면 초기로딩. + scrollUpinit = false; // ps 에서 초기 로딩시 scroll reach start 이벤트 발생 버그를 우회하기 위한 init 값으로 scrollUp 에 의해 true 로 된다. + isRecalledMessage = isRecalled; isCopyableMessage = isCopyable; isRecallableMessage = isRecallable; @@ -157,6 +160,10 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { select(AppStore.MessengerSelector.RoomSelector.roomInfo), tap(roomInfo => { this.roomInfo = roomInfo; + + // 방정보가 바뀌면 이전대화 보기 관련 값들을 초기화 한다. + this.scrollUpinit = false; + this.eventMorePosition = 0; }) ) .subscribe(); @@ -217,7 +224,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } ngAfterViewInit(): void { - this.readyToReply(); + // this.readyToReply(); } getRoomName() { @@ -298,13 +305,29 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } scrollToBottom(speed?: number): void { - speed = speed || 0; - if (this.psChatContent.directiveRef) { - this.psChatContent.directiveRef.update(); + if (this.eventMorePosition > 0) { + if (this.psChatContent.directiveRef) { + this.psChatContent.directiveRef.update(); - setTimeout(() => { - this.psChatContent.directiveRef.scrollToBottom(0, speed); - }); + setTimeout(() => { + this.psChatContent.directiveRef.scrollToTop( + this.psChatContent.directiveRef.elementRef.nativeElement + .scrollHeight - this.eventMorePosition, + speed + ); + + this.scrollUpinit = false; + }); + } + } else { + speed = speed || 0; + if (this.psChatContent.directiveRef) { + this.psChatContent.directiveRef.update(); + + setTimeout(() => { + this.psChatContent.directiveRef.scrollToBottom(0, speed); + }); + } } } @@ -360,7 +383,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } /** More Event */ onMoreEvent(seq: number) { - if (this.eventRemain) { + if (this.scrollUpinit && this.eventRemain) { this.store.dispatch( EventStore.info({ roomSeq: this.roomInfo.roomSeq, @@ -368,6 +391,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { requestCount: CONST.EVENT_INFO_READ_COUNT }) ); + this.scrollUpinit = false; + this.eventMorePosition = this.psChatContent.directiveRef.elementRef.nativeElement.scrollHeight; } }