This commit is contained in:
병준 박 2019-11-07 11:37:53 +09:00
commit bb4cdfab26
2 changed files with 36 additions and 10 deletions

View File

@ -95,6 +95,7 @@
<perfect-scrollbar
fxFlex="1 1 auto"
#psChatContent
(psScrollUp)="scrollUpinit = true"
(psYReachStart)="onScrollup($event)"
>
<ucap-chat-messages

View File

@ -113,10 +113,13 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
userInfoListSubscription: Subscription;
eventListProcessing$: Observable<boolean>;
eventInfoStatus$: Observable<InfoResponse>;
eventRemain$: Observable<boolean>;
eventRemain = false;
sessionVerInfo: VersionInfo2Response;
eventRemain$: Observable<boolean>;
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;
}
}