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 b77eb5ee..7df4f3e0 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 @@ -4,12 +4,13 @@ perfectScrollbar fxFlexFill #psChatContent + [bufferAmount]="10" (psScrollUp)="onScrollup($event)" (psYReachStart)="onYReachStart($event)" (psYReachEnd)="onYReachEnd($event)" [enableUnequalChildrenSizes]="true" > -
+
>(); @ViewChild(PerfectScrollbarDirective, { static: false }) - psChatContent?: PerfectScrollbarDirective; + psChatContent: PerfectScrollbarDirective; @ViewChild(VirtualScrollerComponent, { static: false }) private virtualScroller: VirtualScrollerComponent; @@ -135,6 +137,7 @@ export class MessagesComponent implements OnInit, OnDestroy { moment = moment; existReadHere = false; + fixScreen = false; constructor( private logger: NGXLogger, @@ -150,6 +153,13 @@ 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.initEventMore(); this.roomInfo = roomInfo; }); @@ -305,6 +315,9 @@ export class MessagesComponent implements OnInit, OnDestroy { return true; } if (curIndex > 0) { + if (!this.eventList[curIndex]) { + return false; + } return ( this.datePipe.transform( moment(this.eventList[curIndex].sendDate).toDate(), @@ -435,8 +448,10 @@ export class MessagesComponent implements OnInit, OnDestroy { if (!!this.virtualScroller) { const e = this.eventList.find(v => v.seq === eventSeq); - this.virtualScroller.scrollDebounceTime = 0; - this.virtualScroller.scrollInto(e); + this.fixScreen = true; + this.virtualScroller.scrollInto(e, false, undefined, 0, () => { + this.fixScreen = false; + }); } }