0"
class="message-row view-previous"
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 95052648..e10ccebd 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
@@ -5,7 +5,9 @@ import {
EventEmitter,
Output,
ViewChild,
- OnDestroy
+ OnDestroy,
+ ElementRef,
+ Self
} from '@angular/core';
import {
@@ -102,7 +104,7 @@ export class MessagesComponent implements OnInit, OnDestroy {
existNewMessage = new EventEmitter>();
@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;
+ });
}
}