refactoring of chat search

This commit is contained in:
richard-loafle 2020-01-31 10:41:52 +09:00
parent de0a6b016e
commit 6657461150
3 changed files with 38 additions and 27 deletions

View File

@ -1772,10 +1772,13 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
// CASE :: searching text after retrieve All event Infos.
this.store.dispatch(
EventStore.infoAll({
roomSeq: this.roomInfoSubject.value.roomSeq,
baseSeq: this.eventListSubject.value[0].seq,
requestCount:
environment.productConfig.CommonSetting.eventRequestDefaultCount * 2
req: {
roomSeq: this.roomInfoSubject.value.roomSeq,
baseSeq: this.eventListSubject.value[0].seq,
requestCount:
environment.productConfig.CommonSetting.eventRequestDefaultCount * 2
},
infoList: undefined
})
);

View File

@ -50,7 +50,7 @@ export const infoForSearchEnd = createAction(
export const infoAll = createAction(
'[Messenger::Event] Info All',
props<InfoRequest>()
props<{ req: InfoRequest; infoList: Info<EventJson>[] }>()
);
export const fileInfo = createAction(

View File

@ -412,7 +412,10 @@ export class Effects {
)
)
),
switchMap(([req, processing]) => {
switchMap(([params, processing]) => {
const req = params.req;
const mergedInfoList = params.infoList;
return this.eventProtocolService.info(req).pipe(
map(async res => {
switch (res.SSVC_TYPE) {
@ -421,31 +424,36 @@ export class Effects {
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({
if (
infoList.length > 0 &&
infoList.length >= req.requestCount &&
processing
) {
// 재귀
this.store.dispatch(
infoAll({
req: {
roomSeq: req.roomSeq,
baseSeq: infoList[0].seq,
requestCount: req.requestCount
})
);
} else {
if (infoList.length < req.requestCount) {
this.store.dispatch(infoForSearchEnd({}));
}
}
},
infoList: !!mergedInfoList
? [...infoList, ...mergedInfoList]
: infoList
})
);
} else {
this.store.dispatch(
infoMoreSuccess({
infoList: !!mergedInfoList
? [...infoList, ...mergedInfoList]
: infoList,
res: res as InfoResponse,
remainInfo:
infoList.length === req.requestCount ? true : false
})
);
this.store.dispatch(infoForSearchEnd({}));
}
}