bug fixed
This commit is contained in:
parent
551f495698
commit
bab7b405a1
|
@ -289,6 +289,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
this.store.dispatch(EventStore.infoIntervalClear({}));
|
this.store.dispatch(EventStore.infoIntervalClear({}));
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.readyToReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.roomInfoSubject.next(roomInfo);
|
this.roomInfoSubject.next(roomInfo);
|
||||||
|
@ -377,7 +379,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
} else {
|
} else {
|
||||||
if (!!infoList && infoList.length > 0) {
|
if (!!infoList && infoList.length > 0) {
|
||||||
this.baseEventSeq = infoList[0].seq;
|
this.baseEventSeq = infoList[0].seq;
|
||||||
this.readyToReply();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,10 +28,11 @@ import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { FileDownloadItem } from '@ucap-webmessenger/api';
|
import { FileDownloadItem } from '@ucap-webmessenger/api';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Observable, Subscription, timer } from 'rxjs';
|
||||||
import { VirtualScrollerComponent, IPageInfo } from 'ngx-virtual-scroller';
|
import { VirtualScrollerComponent, IPageInfo } from 'ngx-virtual-scroller';
|
||||||
import { MessageBoxComponent } from './message-box.component';
|
import { MessageBoxComponent } from './message-box.component';
|
||||||
import { PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
|
import { PerfectScrollbarDirective } from 'ngx-perfect-scrollbar';
|
||||||
|
import { debounce } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ucap-chat-messages',
|
selector: 'ucap-chat-messages',
|
||||||
|
@ -181,46 +182,48 @@ export class MessagesComponent implements OnInit, OnDestroy {
|
||||||
this.existReadToHereEvent = true;
|
this.existReadToHereEvent = true;
|
||||||
/** [E] initializing by changed room */
|
/** [E] initializing by changed room */
|
||||||
|
|
||||||
if (this.roomInfo.roomSeq !== roomInfo.roomSeq) {
|
if (!this.roomInfo || this.roomInfo.roomSeq !== roomInfo.roomSeq) {
|
||||||
this.initEventMore();
|
this.initEventMore();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.eventListSubscription = this.eventList$.subscribe(eventList => {
|
this.eventListSubscription = this.eventList$
|
||||||
this.eventList = eventList;
|
.pipe(debounce(() => timer(100)))
|
||||||
|
.subscribe(eventList => {
|
||||||
|
this.eventList = eventList;
|
||||||
|
|
||||||
if (!!eventList && eventList.length > 0) {
|
|
||||||
if (!this.readToHereEvent && this.existReadToHereEvent) {
|
|
||||||
this.readToHereEvent = this.getReadHere();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
this.baseEventSeq > 0 &&
|
|
||||||
!!this.roomInfo &&
|
|
||||||
!!this.roomInfo.lastReadEventSeq &&
|
|
||||||
this.baseEventSeq <= this.roomInfo.lastReadEventSeq
|
|
||||||
) {
|
|
||||||
// 기존 대화 내용이 있는 상태에서 추가로 조회된 내용중에 read here 가 있을 경우.
|
|
||||||
this.firstCheckReadHere = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.readToHereEvent = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.changeDetectorRef.detectChanges();
|
|
||||||
|
|
||||||
if (this.searchingMode) {
|
|
||||||
const baseseq = this.baseEventSeq;
|
|
||||||
// setTimeout(() => {
|
|
||||||
// this.doSearchTextInEvent(this.searchText, baseseq);
|
|
||||||
// }, 800);
|
|
||||||
this.baseEventSeq = eventList[0].seq;
|
|
||||||
} else {
|
|
||||||
if (!!eventList && eventList.length > 0) {
|
if (!!eventList && eventList.length > 0) {
|
||||||
this.baseEventSeq = eventList[0].seq;
|
if (!this.readToHereEvent && this.existReadToHereEvent) {
|
||||||
this.ready();
|
this.readToHereEvent = this.getReadHere();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.baseEventSeq > 0 &&
|
||||||
|
!!this.roomInfo &&
|
||||||
|
!!this.roomInfo.lastReadEventSeq &&
|
||||||
|
this.baseEventSeq <= this.roomInfo.lastReadEventSeq
|
||||||
|
) {
|
||||||
|
// 기존 대화 내용이 있는 상태에서 추가로 조회된 내용중에 read here 가 있을 경우.
|
||||||
|
this.firstCheckReadHere = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.readToHereEvent = undefined;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
this.changeDetectorRef.detectChanges();
|
||||||
|
|
||||||
|
if (this.searchingMode) {
|
||||||
|
const baseseq = this.baseEventSeq;
|
||||||
|
// setTimeout(() => {
|
||||||
|
// this.doSearchTextInEvent(this.searchText, baseseq);
|
||||||
|
// }, 800);
|
||||||
|
this.baseEventSeq = eventList[0].seq;
|
||||||
|
} else {
|
||||||
|
if (!!eventList && eventList.length > 0) {
|
||||||
|
this.baseEventSeq = eventList[0].seq;
|
||||||
|
this.ready();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
this.newEventListSubscription = this.newEventList$.subscribe(
|
this.newEventListSubscription = this.newEventList$.subscribe(
|
||||||
newEventList => {
|
newEventList => {
|
||||||
this.newEventList = newEventList;
|
this.newEventList = newEventList;
|
||||||
|
@ -513,30 +516,27 @@ export class MessagesComponent implements OnInit, OnDestroy {
|
||||||
() => {
|
() => {
|
||||||
this.firstCheckReadHere = false;
|
this.firstCheckReadHere = false;
|
||||||
},
|
},
|
||||||
true,
|
false,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (
|
const lastEvent =
|
||||||
this.virtualScroller.viewPortInfo.endIndex ===
|
!!this.eventList && 0 < this.eventList.length
|
||||||
this.eventList.length - 2
|
? this.eventList[this.eventList.length - 1]
|
||||||
) {
|
: undefined;
|
||||||
this.swapScrollTo(
|
|
||||||
this.eventList[this.eventList.length - 1],
|
if (undefined === lastEvent) {
|
||||||
() => {},
|
return;
|
||||||
() => {},
|
|
||||||
false,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.swapScrollTo(
|
|
||||||
this.eventList[this.eventList.length - 1],
|
|
||||||
() => {},
|
|
||||||
() => {},
|
|
||||||
true,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
const isInViewPortItems = this.isInViewPortItems(lastEvent.seq);
|
||||||
|
this.swapScrollTo(
|
||||||
|
this.eventList[this.eventList.length - 1],
|
||||||
|
() => {},
|
||||||
|
() => {},
|
||||||
|
-1 === this.virtualScroller.viewPortInfo.endIndex ||
|
||||||
|
!isInViewPortItems,
|
||||||
|
!isInViewPortItems
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,9 +551,7 @@ export class MessagesComponent implements OnInit, OnDestroy {
|
||||||
clear() {}
|
clear() {}
|
||||||
|
|
||||||
gotoPosition(eventSeq: number) {
|
gotoPosition(eventSeq: number) {
|
||||||
const viewPortItemIndex = this.virtualScroller.viewPortItems.findIndex(
|
const isInViewPortItems = this.isInViewPortItems(eventSeq);
|
||||||
v => v.seq === eventSeq
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!!this.virtualScroller) {
|
if (!!this.virtualScroller) {
|
||||||
const e = this.eventList.find(v => v.seq === eventSeq);
|
const e = this.eventList.find(v => v.seq === eventSeq);
|
||||||
|
@ -568,13 +566,28 @@ export class MessagesComponent implements OnInit, OnDestroy {
|
||||||
chatMessageBox.shake();
|
chatMessageBox.shake();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
-1 === viewPortItemIndex,
|
!isInViewPortItems,
|
||||||
-1 === viewPortItemIndex,
|
!isInViewPortItems,
|
||||||
50
|
50
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isInViewPortItems(eventSeq: number): boolean {
|
||||||
|
if (undefined === eventSeq) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const viewPortItemIndex = this.virtualScroller.viewPortItems.findIndex(
|
||||||
|
v => v.seq === eventSeq
|
||||||
|
);
|
||||||
|
|
||||||
|
const newEvent =
|
||||||
|
!!this.newEventList &&
|
||||||
|
-1 !== this.newEventList.findIndex(e => e.seq === eventSeq);
|
||||||
|
|
||||||
|
return -1 !== viewPortItemIndex || newEvent;
|
||||||
|
}
|
||||||
|
|
||||||
onClickOpenProfile(userSeq: number) {
|
onClickOpenProfile(userSeq: number) {
|
||||||
this.openProfile.emit(userSeq);
|
this.openProfile.emit(userSeq);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user