event_send_res, noti 시 호출되는 newInfo 에서 read request 하던것을 상황에 따라 처리하기위해서 대화창 component, notification service 에서 처리하도록 수정.

(아직 tray, blur 상태일때의 처리는 되어 있지 않음)
This commit is contained in:
leejinho 2020-03-31 09:26:48 +09:00
parent 589eb0206d
commit 77efd35742
4 changed files with 84 additions and 42 deletions

View File

@ -13,7 +13,7 @@
(closeRightDrawer)="onCloseRightDrawer()" (closeRightDrawer)="onCloseRightDrawer()"
(sendCall)="onClickSendClickToCall($event)" (sendCall)="onClickSendClickToCall($event)"
></app-layout-messenger-messages> ></app-layout-messenger-messages>
<!-- 아래와 같이 display 효과를 쓰려면 block 대산 flex 사용. (화면 전환이 매끄럽지만 스크롤이 그대로인 문제 있음.) -->
<app-layout-messenger-organization <app-layout-messenger-organization
(openProfile)="onClickOpenProfile($event)" (openProfile)="onClickOpenProfile($event)"
(createConference)="onClickConferenceCreate($event)" (createConference)="onClickConferenceCreate($event)"

View File

@ -74,7 +74,8 @@ import {
UserSelectDialogType, UserSelectDialogType,
RightDrawer, RightDrawer,
KEY_STICKER_HISTORY, KEY_STICKER_HISTORY,
KEY_AUTH_INFO KEY_AUTH_INFO,
MainMenu
} from '@app/types'; } from '@app/types';
import { import {
RoomInfo, RoomInfo,
@ -191,6 +192,8 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
environmentsInfo: EnvironmentsInfo; environmentsInfo: EnvironmentsInfo;
authInfo: AuthResponse; authInfo: AuthResponse;
unreadSubscription: Subscription;
loginResSubscription: Subscription; loginResSubscription: Subscription;
loginResSubject = new BehaviorSubject<LoginResponse>(undefined); loginResSubject = new BehaviorSubject<LoginResponse>(undefined);
@ -300,6 +303,35 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
this.loginResSubject.next(loginRes); this.loginResSubject.next(loginRes);
}); });
this.unreadSubscription = combineLatest([
this.store.pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo)),
this.store.pipe(
select(AppStore.MessengerSelector.SettingsSelector.gnbMenuIndex)
),
this.store.pipe(
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList)
)
])
.pipe(
map(([roomInfo, gnbMenuIndex, eventList]) => {
if (
!!roomInfo &&
!!roomInfo.roomSeq &&
!!eventList &&
eventList.length > 0 &&
gnbMenuIndex !== MainMenu.Organization
) {
this.store.dispatch(
EventStore.read({
roomSeq: roomInfo.roomSeq,
lastReadSeq: eventList[eventList.length - 1].seq
})
);
}
})
)
.subscribe();
this.roomInfoSubscription = this.store this.roomInfoSubscription = this.store
.pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo)) .pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo))
.subscribe(roomInfo => { .subscribe(roomInfo => {
@ -505,6 +537,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
if (!!this.loginResSubscription) { if (!!this.loginResSubscription) {
this.loginResSubscription.unsubscribe(); this.loginResSubscription.unsubscribe();
} }
if (!!this.unreadSubscription) {
this.unreadSubscription.unsubscribe();
}
if (!!this.roomInfoSubscription) { if (!!this.roomInfoSubscription) {
this.roomInfoSubscription.unsubscribe(); this.roomInfoSubscription.unsubscribe();
} }

View File

@ -275,12 +275,53 @@ export class AppNotificationService {
noti noti
); );
// Event..
this.store.dispatch( this.store.dispatch(
EventStore.sendNotification({ EventStore.sendNotification({
noti noti
}) })
); );
// unread count..
if (
!!curRoomInfo &&
!!curRoomInfo.roomSeq &&
curRoomInfo.roomSeq === noti.roomSeq &&
gnbMenuIndex !== MainMenu.Organization
) {
// 현재 방이 열려 있고, 조직도탭을 보고 있지 않다면 대화방을 보고 있다고 판단하고 event_read_req 한다.
this.store.dispatch(
EventStore.read({
roomSeq: noti.roomSeq,
lastReadSeq: noti.info.seq
})
);
} else {
// not opened room :: unread count increased
if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_RES) {
/**
* RES noti .
* unread count .
*/
} else {
if (
!!roomList &&
!!roomList[noti.roomSeq] &&
noti.info.type !== EventType.Join &&
noti.info.type !== EventType.Exit &&
noti.info.type !== EventType.ForcedExit
) {
const noReadCnt = roomList[noti.roomSeq].noReadCnt;
this.store.dispatch(
SyncStore.updateUnreadCount({
roomSeq: noti.roomSeq,
noReadCnt: noReadCnt + 1
})
);
}
}
}
// notification.. // notification..
if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI) { if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI) {
let doNoti = true; let doNoti = true;

View File

@ -95,7 +95,12 @@ import {
RoomProtocolService, RoomProtocolService,
OpenResponse OpenResponse
} from '@ucap-webmessenger/protocol-room'; } from '@ucap-webmessenger/protocol-room';
import { LoginInfo, KEY_LOGIN_INFO, EnvironmentsInfo } from '@app/types'; import {
LoginInfo,
KEY_LOGIN_INFO,
EnvironmentsInfo,
MainMenu
} from '@app/types';
import { Dictionary } from '@ngrx/entity'; import { Dictionary } from '@ngrx/entity';
import { openSuccess, openFailure } from '../room'; import { openSuccess, openFailure } from '../room';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
@ -914,18 +919,6 @@ export class Effects {
if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) { if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) {
this.store.dispatch(appendInfoList({ info: action.info })); this.store.dispatch(appendInfoList({ info: action.info }));
if (
action.SVC_TYPE === SVC_TYPE_EVENT &&
action.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI
) {
this.store.dispatch(
read({
roomSeq: action.roomSeq,
lastReadSeq: action.info.seq
})
);
}
if (action.info.type === EventType.File) { if (action.info.type === EventType.File) {
// File 정보 수집. // File 정보 수집.
this.store.dispatch( this.store.dispatch(
@ -938,33 +931,6 @@ export class Effects {
}) })
); );
} }
} else {
// not opened room :: unread count increased
if (
action.SVC_TYPE === SVC_TYPE_EVENT &&
action.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_RES
) {
/**
* RES noti .
* unread count .
*/
} else {
if (
!!trgtRoomInfos &&
!!trgtRoomInfos[action.roomSeq] &&
action.info.type !== EventType.Join &&
action.info.type !== EventType.Exit &&
action.info.type !== EventType.ForcedExit
) {
const noReadCnt = trgtRoomInfos[action.roomSeq].noReadCnt;
this.store.dispatch(
SyncStore.updateUnreadCount({
roomSeq: action.roomSeq,
noReadCnt: noReadCnt + 1
})
);
}
}
} }
// 대화 > 리스트 :: finalEventMessage refresh // 대화 > 리스트 :: finalEventMessage refresh