대화검색 로직 수정.

This commit is contained in:
leejinho 2020-01-07 13:45:34 +09:00
parent 92ab91ef09
commit 5d1b35dda7
4 changed files with 124 additions and 10 deletions

View File

@ -60,10 +60,7 @@ import {
} from '@app/types';
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError, finalize } from 'rxjs/operators';
import {
FileInfo,
FormComponent as UCapUiChatFormComponent
} from '@ucap-webmessenger/ui-chat';
import { FormComponent as UCapUiChatFormComponent } from '@ucap-webmessenger/ui-chat';
import { KEY_VER_INFO } from '@app/types';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import {
@ -148,6 +145,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
userInfoList: UserInfo[];
userInfoListSubscription: Subscription;
eventListProcessing$: Observable<boolean>;
searchEventListProcessing: boolean;
searchEventListProcessingSubscription: Subscription;
eventInfoStatus: InfoResponse;
eventInfoStatusSubscription: Subscription;
sessionVerInfo: VersionInfo2Response;
@ -166,7 +165,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
interval: any;
/** About Searching */
isShowSearchArea = true;
isShowSearchArea = false;
moreSearchProcessing = false;
searchText = '';
searchedList: Info<EventJson>[];
@ -258,6 +257,25 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
select(AppStore.MessengerSelector.EventSelector.infoListProcessing)
);
this.searchEventListProcessingSubscription = this.store
.pipe(
select(
AppStore.MessengerSelector.EventSelector.infoSearchListProcessing
),
tap(process => {
this.searchEventListProcessing = process;
if (!process && this.isShowSearchArea) {
this.doSearchTextInEvent(this.searchText);
this.snackBarService.open('대화검색을 마쳤습니다.', '확인', {
duration: 3000,
verticalPosition: 'top',
horizontalPosition: 'center'
});
}
})
)
.subscribe();
this.eventRemain$ = this.store.pipe(
select(AppStore.MessengerSelector.EventSelector.remainInfo),
tap(remainInfo => {
@ -298,9 +316,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
if (this.moreSearchProcessing) {
const baseseq = this.baseEventSeq;
setTimeout(() => {
this.onSearchChat(this.searchText, baseseq);
}, 800);
// setTimeout(() => {
// this.doSearchTextInEvent(this.searchText, baseseq);
// }, 800);
this.baseEventSeq = infoList[0].seq;
} else {
if (!!infoList && infoList.length > 0) {
@ -365,6 +383,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
if (!!this.eventInfoStatusSubscription) {
this.eventInfoStatusSubscription.unsubscribe();
}
if (!!this.searchEventListProcessingSubscription) {
this.searchEventListProcessingSubscription.unsubscribe();
}
clearInterval(this.interval);
}
@ -1487,6 +1508,19 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
onSearchChat(searchText: string, baseSeq?: number) {
this.searchText = searchText;
// CASE :: searching text after retrieve All event Infos.
this.store.dispatch(
EventStore.infoAll({
roomSeq: this.roomInfo.roomSeq,
baseSeq: this.eventList[0].seq,
requestCount:
environment.productConfig.CommonSetting.eventRequestDefaultCount * 2
})
);
// this.doSearchTextInEvent(searchText);
}
doSearchTextInEvent(searchText: string, baseSeq?: number): void {
this.searchedList = this.eventList.filter(event => {
let contents = '';
if (event.type === EventType.Character) {
@ -1568,6 +1602,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.moreSearchProcessing = true;
this.eventMorePosition = this.psChatContent.directiveRef.elementRef.nativeElement.scrollHeight;
// Case :: retrieve event infos step by step until include searchtext in event..
this.store.dispatch(
EventStore.infoForSearch({
req: {

View File

@ -48,6 +48,11 @@ export const infoForSearchEnd = createAction(
props()
);
export const infoAll = createAction(
'[Messenger::Event] Info All',
props<InfoRequest>()
);
export const fileInfo = createAction(
'[Messenger::Event] File Info',
props<{ req: FileInfoRequest }>()

View File

@ -82,7 +82,8 @@ import {
fileInfoFailure,
roomOpenAfterForward,
infoForSearch,
infoForSearchEnd
infoForSearchEnd,
infoAll
} from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import {
@ -388,6 +389,71 @@ export class Effects {
{ dispatch: false }
);
infoAll$ = createEffect(
() => {
let infoList: Info<EventJson>[];
return this.actions$.pipe(
ofType(infoAll),
tap(() => {
infoList = [];
}),
withLatestFrom(
this.store.pipe(
select(
(state: any) =>
state.messenger.event.infoSearchListProcessing as boolean
)
)
),
switchMap(([req, processing]) => {
return this.eventProtocolService.info(req).pipe(
map(async res => {
switch (res.SSVC_TYPE) {
case SSVC_TYPE_EVENT_INFO_DATA:
infoList.push(...(res as InfoData).infoList);
break;
case SSVC_TYPE_EVENT_INFO_RES:
{
this.store.dispatch(
infoMoreSuccess({
infoList,
res: res as InfoResponse,
remainInfo:
infoList.length === req.requestCount ? true : false
})
);
if (infoList.length > 0) {
if (infoList.length === req.requestCount && processing) {
// 재귀
this.store.dispatch(
infoAll({
roomSeq: req.roomSeq,
baseSeq: infoList[0].seq,
requestCount: req.requestCount
})
);
} else {
if (infoList.length < req.requestCount) {
this.store.dispatch(infoForSearchEnd({}));
}
}
} else {
this.store.dispatch(infoForSearchEnd({}));
}
}
break;
}
}),
catchError(error => of(infoFailure({ error })))
);
})
);
},
{ dispatch: false }
);
fileInfo$ = createEffect(
() => {
let fileInfoList: FileInfo[];

View File

@ -15,7 +15,8 @@ import {
infoMoreSuccess,
fileInfoSuccess,
infoForSearch,
infoForSearchEnd
infoForSearchEnd,
infoAll
} from './actions';
import * as AuthenticationStore from '@app/store/account/authentication';
import * as ChatStore from '@app/store/messenger/chat';
@ -42,6 +43,13 @@ export const reducer = createReducer(
infoSearchListProcessing: false
};
}),
on(infoAll, (state, action) => {
return {
...state,
infoListProcessing: true,
infoSearchListProcessing: true
};
}),
on(infoSuccess, (state, action) => {
return {