대화검색 로직 수정.

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'; } from '@app/types';
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError, finalize } from 'rxjs/operators'; import { tap, take, map, catchError, finalize } from 'rxjs/operators';
import { import { FormComponent as UCapUiChatFormComponent } from '@ucap-webmessenger/ui-chat';
FileInfo,
FormComponent as UCapUiChatFormComponent
} from '@ucap-webmessenger/ui-chat';
import { KEY_VER_INFO } from '@app/types'; import { KEY_VER_INFO } from '@app/types';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { import {
@ -148,6 +145,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
userInfoList: UserInfo[]; userInfoList: UserInfo[];
userInfoListSubscription: Subscription; userInfoListSubscription: Subscription;
eventListProcessing$: Observable<boolean>; eventListProcessing$: Observable<boolean>;
searchEventListProcessing: boolean;
searchEventListProcessingSubscription: Subscription;
eventInfoStatus: InfoResponse; eventInfoStatus: InfoResponse;
eventInfoStatusSubscription: Subscription; eventInfoStatusSubscription: Subscription;
sessionVerInfo: VersionInfo2Response; sessionVerInfo: VersionInfo2Response;
@ -166,7 +165,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
interval: any; interval: any;
/** About Searching */ /** About Searching */
isShowSearchArea = true; isShowSearchArea = false;
moreSearchProcessing = false; moreSearchProcessing = false;
searchText = ''; searchText = '';
searchedList: Info<EventJson>[]; searchedList: Info<EventJson>[];
@ -258,6 +257,25 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
select(AppStore.MessengerSelector.EventSelector.infoListProcessing) 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( this.eventRemain$ = this.store.pipe(
select(AppStore.MessengerSelector.EventSelector.remainInfo), select(AppStore.MessengerSelector.EventSelector.remainInfo),
tap(remainInfo => { tap(remainInfo => {
@ -298,9 +316,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
if (this.moreSearchProcessing) { if (this.moreSearchProcessing) {
const baseseq = this.baseEventSeq; const baseseq = this.baseEventSeq;
setTimeout(() => { // setTimeout(() => {
this.onSearchChat(this.searchText, baseseq); // this.doSearchTextInEvent(this.searchText, baseseq);
}, 800); // }, 800);
this.baseEventSeq = infoList[0].seq; this.baseEventSeq = infoList[0].seq;
} else { } else {
if (!!infoList && infoList.length > 0) { if (!!infoList && infoList.length > 0) {
@ -365,6 +383,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
if (!!this.eventInfoStatusSubscription) { if (!!this.eventInfoStatusSubscription) {
this.eventInfoStatusSubscription.unsubscribe(); this.eventInfoStatusSubscription.unsubscribe();
} }
if (!!this.searchEventListProcessingSubscription) {
this.searchEventListProcessingSubscription.unsubscribe();
}
clearInterval(this.interval); clearInterval(this.interval);
} }
@ -1487,6 +1508,19 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
onSearchChat(searchText: string, baseSeq?: number) { onSearchChat(searchText: string, baseSeq?: number) {
this.searchText = searchText; 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 => { this.searchedList = this.eventList.filter(event => {
let contents = ''; let contents = '';
if (event.type === EventType.Character) { if (event.type === EventType.Character) {
@ -1568,6 +1602,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.moreSearchProcessing = true; this.moreSearchProcessing = true;
this.eventMorePosition = this.psChatContent.directiveRef.elementRef.nativeElement.scrollHeight; this.eventMorePosition = this.psChatContent.directiveRef.elementRef.nativeElement.scrollHeight;
// Case :: retrieve event infos step by step until include searchtext in event..
this.store.dispatch( this.store.dispatch(
EventStore.infoForSearch({ EventStore.infoForSearch({
req: { req: {

View File

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

View File

@ -82,7 +82,8 @@ import {
fileInfoFailure, fileInfoFailure,
roomOpenAfterForward, roomOpenAfterForward,
infoForSearch, infoForSearch,
infoForSearchEnd infoForSearchEnd,
infoAll
} from './actions'; } from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { import {
@ -388,6 +389,71 @@ export class Effects {
{ dispatch: false } { 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( fileInfo$ = createEffect(
() => { () => {
let fileInfoList: FileInfo[]; let fileInfoList: FileInfo[];

View File

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