From 77efd357428a4ec87ade24a0834f8d40485d3806 Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 31 Mar 2020 09:26:48 +0900 Subject: [PATCH] =?UTF-8?q?event=5Fsend=5Fres,=20noti=20=EC=8B=9C=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=EB=90=98=EB=8A=94=20newInfo=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20read=20request=20=ED=95=98=EB=8D=98=EA=B2=83?= =?UTF-8?q?=EC=9D=84=20=EC=83=81=ED=99=A9=EC=97=90=20=EB=94=B0=EB=9D=BC=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=ED=95=98=EA=B8=B0=EC=9C=84=ED=95=B4=EC=84=9C?= =?UTF-8?q?=20=EB=8C=80=ED=99=94=EC=B0=BD=20component,=20notification=20se?= =?UTF-8?q?rvice=20=EC=97=90=EC=84=9C=20=EC=B2=98=EB=A6=AC=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95.=20(=EC=95=84=EC=A7=81?= =?UTF-8?q?=20tray,=20blur=20=EC=83=81=ED=83=9C=EC=9D=BC=EB=95=8C=EC=9D=98?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC=EB=8A=94=20=EB=90=98=EC=96=B4=20=EC=9E=88?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/main-contents.component.html | 2 +- .../main-contents/messages.component.ts | 37 ++++++++++++++- .../src/app/services/notification.service.ts | 41 +++++++++++++++++ .../src/app/store/messenger/event/effects.ts | 46 +++---------------- 4 files changed, 84 insertions(+), 42 deletions(-) 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