diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 6bdf2bc4..2ce56571 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -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; + 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[]; @@ -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: { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts index e31c8a5c..437b3bcf 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/actions.ts @@ -48,6 +48,11 @@ export const infoForSearchEnd = createAction( props() ); +export const infoAll = createAction( + '[Messenger::Event] Info All', + props() +); + export const fileInfo = createAction( '[Messenger::Event] File Info', props<{ req: FileInfoRequest }>() diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts index ce89f127..3026374e 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/effects.ts @@ -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[]; + + 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[]; diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/event/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/event/reducers.ts index 03de3a0f..893992de 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/event/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/event/reducers.ts @@ -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 {