diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.html index 402303dc..05987d7a 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.html @@ -13,7 +13,7 @@ (closeRightDrawer)="onCloseRightDrawer()" (sendCall)="onClickSendClickToCall($event)" > - + (undefined); @@ -300,6 +303,35 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { 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 .pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo)) .subscribe(roomInfo => { @@ -505,6 +537,9 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { if (!!this.loginResSubscription) { this.loginResSubscription.unsubscribe(); } + if (!!this.unreadSubscription) { + this.unreadSubscription.unsubscribe(); + } if (!!this.roomInfoSubscription) { this.roomInfoSubscription.unsubscribe(); } diff --git a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts index 0728adae..6ac6a5cc 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -275,12 +275,53 @@ export class AppNotificationService { noti ); + // Event.. this.store.dispatch( EventStore.sendNotification({ 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.. if (notiOrRes.SSVC_TYPE === SSVC_TYPE_EVENT_SEND_NOTI) { let doNoti = true; 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 f0fc2253..f01a16cb 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 @@ -95,7 +95,12 @@ import { RoomProtocolService, OpenResponse } 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 { openSuccess, openFailure } from '../room'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; @@ -914,18 +919,6 @@ export class Effects { if (!!roomInfo && roomInfo.roomSeq === action.roomSeq) { 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) { // File 정보 수집. 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