Timer 대화방의 대화 자동 삭제 기능 추가.
This commit is contained in:
parent
86ee7dd515
commit
bf9bcd967b
@ -102,6 +102,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|||||||
files: File[];
|
files: File[];
|
||||||
fileItems: DataTransferItemList;
|
fileItems: DataTransferItemList;
|
||||||
|
|
||||||
|
/** Timer 대화방의 대화 삭제를 위한 interval */
|
||||||
|
interval: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
private sessionStorageService: SessionStorageService,
|
private sessionStorageService: SessionStorageService,
|
||||||
@ -173,6 +176,12 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.psChatContent.directiveRef.scrollToBottom(0, 0);
|
this.psChatContent.directiveRef.scrollToBottom(0, 0);
|
||||||
|
|
||||||
|
this.interval = setInterval(() => {
|
||||||
|
if (!!this.roomInfo.isTimeRoom) {
|
||||||
|
this.store.dispatch(EventStore.infoIntervalClear({}));
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
@ -185,6 +194,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
|
|||||||
if (!!this.userInfoListSubscription) {
|
if (!!this.userInfoListSubscription) {
|
||||||
this.userInfoListSubscription.unsubscribe();
|
this.userInfoListSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearInterval(this.interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
|
@ -37,6 +37,11 @@ export const infoMoreSuccess = createAction(
|
|||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const infoIntervalClear = createAction(
|
||||||
|
'[Messenger::Event] Info Interval Clear',
|
||||||
|
props()
|
||||||
|
);
|
||||||
|
|
||||||
export const infoFailure = createAction(
|
export const infoFailure = createAction(
|
||||||
'[Messenger::Event] Info Failure',
|
'[Messenger::Event] Info Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
@ -182,6 +187,6 @@ export const delNotification = createAction(
|
|||||||
export const delInfoList = createAction(
|
export const delInfoList = createAction(
|
||||||
'[Messenger::Event] Delete InfoList',
|
'[Messenger::Event] Delete InfoList',
|
||||||
props<{
|
props<{
|
||||||
eventSeq: number;
|
eventSeqs: number[];
|
||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
@ -68,7 +68,8 @@ import {
|
|||||||
forwardAfterRoomOpen,
|
forwardAfterRoomOpen,
|
||||||
sendMass,
|
sendMass,
|
||||||
sendMassFailure,
|
sendMassFailure,
|
||||||
infoMoreSuccess
|
infoMoreSuccess,
|
||||||
|
infoIntervalClear
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
import {
|
import {
|
||||||
@ -158,6 +159,45 @@ export class Effects {
|
|||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
infoIntervalClear$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(infoIntervalClear),
|
||||||
|
withLatestFrom(
|
||||||
|
this.store.pipe(
|
||||||
|
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
|
||||||
|
),
|
||||||
|
this.store.pipe(
|
||||||
|
select(
|
||||||
|
(state: any) =>
|
||||||
|
state.messenger.event.infoList.entities as Dictionary<Info>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
map(([action, roomInfo, eventList]) => {
|
||||||
|
if (roomInfo.isTimeRoom && roomInfo.timeRoomInterval > 0) {
|
||||||
|
const delEventSeq: number[] = [];
|
||||||
|
// tslint:disable-next-line: forin
|
||||||
|
for (const key in eventList) {
|
||||||
|
const event: Info = eventList[key];
|
||||||
|
if (
|
||||||
|
new Date().getTime() - new Date(event.sendDate).getTime() >=
|
||||||
|
roomInfo.timeRoomInterval * 1000
|
||||||
|
) {
|
||||||
|
delEventSeq.push(event.seq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delEventSeq.length > 0) {
|
||||||
|
this.store.dispatch(delInfoList({ eventSeqs: delEventSeq }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
read$ = createEffect(() =>
|
read$ = createEffect(() =>
|
||||||
this.actions$.pipe(
|
this.actions$.pipe(
|
||||||
ofType(read),
|
ofType(read),
|
||||||
@ -533,7 +573,7 @@ export class Effects {
|
|||||||
tap(([noti, roomInfo]) => {
|
tap(([noti, roomInfo]) => {
|
||||||
// 현재 방이 오픈되어 있으면 방내용 갱신
|
// 현재 방이 오픈되어 있으면 방내용 갱신
|
||||||
if (!!roomInfo && roomInfo.roomSeq === noti.roomSeq) {
|
if (!!roomInfo && roomInfo.roomSeq === noti.roomSeq) {
|
||||||
this.store.dispatch(delInfoList({ eventSeq: noti.eventSeq }));
|
this.store.dispatch(delInfoList({ eventSeqs: [noti.eventSeq] }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 대화 > 리스트의 항목 갱신
|
// 대화 > 리스트의 항목 갱신
|
||||||
|
@ -97,11 +97,11 @@ export const reducer = createReducer(
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
on(delInfoList, (state, action) => {
|
on(delInfoList, (state, action) => {
|
||||||
const eventSeq = action.eventSeq;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
infoList: adapterInfoList.removeOne(eventSeq, { ...state.infoList })
|
infoList: adapterInfoList.removeMany(action.eventSeqs, {
|
||||||
|
...state.infoList
|
||||||
|
})
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user