From 77bc91aa391f35e83f08cc4fbed76187ed27f745 Mon Sep 17 00:00:00 2001 From: leejinho Date: Tue, 28 Jan 2020 13:26:32 +0900 Subject: [PATCH] =?UTF-8?q?#=20=EC=9D=B4=EC=8A=88=EC=B2=98=EB=A6=AC=20184?= =?UTF-8?q?=201:1=EB=8C=80=ED=99=94=EB=B0=A9=20=EC=83=81=EB=8C=80=EB=B0=A9?= =?UTF-8?q?=EC=9D=B4=20=EB=B0=A9=20=EB=82=98=EA=B0=80=EA=B8=B0=20=EC=8B=9C?= =?UTF-8?q?=EB=8C=80=ED=99=94=20=EC=83=81=EB=8C=80=20=EC=97=86=EC=9D=8C=20?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=ED=91=9C=EC=8B=9C=EB=90=A8=20185=20?= =?UTF-8?q?=ED=9A=8C=EC=9D=98=EC=A4=91,=20=EC=83=81=ED=83=9C=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=9E=85=EB=A0=A5=20=ED=9B=84=20X?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=ED=9B=84=20=ED=8E=B8=EC=A7=91=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EC=84=A0=ED=83=9D=20=EC=8B=9C=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20186=20=EA=B7=B8=EB=A3=B9=EB=8C=80=ED=99=94=EB=B0=A9=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=ED=9B=84=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EB=B0=9C=EC=8B=A0=20=EC=8B=9C=20=EC=97=AC=EA=B8=B0=EA=B9=8C?= =?UTF-8?q?=EC=A7=80=20=EC=9D=BD=EC=9D=8C=20=EA=B8=B0=EB=8A=A5=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C=EB=90=A8=20187=20=EA=B7=B8=EB=A3=B9=20=EB=8C=80?= =?UTF-8?q?=ED=99=94=EB=B0=A9=20=EC=9D=BD=EC=9D=8C=20=ED=91=9C=EC=8B=9C=20?= =?UTF-8?q?=EC=B9=B4=EC=9A=B4=ED=8A=B8=20=EC=98=A4=EB=A5=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/messages.component.ts | 6 ++ .../native/components/top-bar.component.html | 15 ++++- .../src/app/services/notification.service.ts | 41 ++++++++++--- .../src/app/store/messenger/room/actions.ts | 9 +++ .../src/app/store/messenger/room/effects.ts | 29 +++++++++- .../src/app/store/messenger/room/reducers.ts | 15 ++++- .../src/app/store/messenger/sync/actions.ts | 6 ++ .../src/app/store/messenger/sync/reducers.ts | 49 +++++++++++++++- .../src/lib/components/messages.component.ts | 57 +++++++++++-------- .../src/lib/components/profile.component.html | 18 +----- .../src/lib/components/list-item.component.ts | 21 ++++--- 11 files changed, 207 insertions(+), 59 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 7177bf8f..b0311a2e 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -467,6 +467,11 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } get _roomUserInfos() { + if (this.roomInfoSubject.value.roomType === RoomType.Single) { + return this.userInfoListSubject.value.filter(roomUserInfo => { + return this.loginResSubject.value.userSeq !== roomUserInfo.seq; + }); + } else { return this.userInfoListSubject.value .filter(roomUserInfo => { return ( @@ -475,6 +480,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { ); }) .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)); + } } getRoomNameByRoomUser(roomUserInfos: (UserInfo | UserInfoShort)[]) { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html index 47ebce10..e67132ad 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html @@ -361,7 +361,10 @@ onApplyStatusMessage(1, statusMessage1.value) " (edit)="$event.stopPropagation()" - (cancel)="$event.stopPropagation()" + (cancel)=" + $event.stopPropagation(); + statusMessage1.value = loginRes?.statusMessage1 + " class="form-eidt" > {{ loginRes?.statusMessage1 }} @@ -386,7 +389,10 @@ onApplyStatusMessage(2, statusMessage2.value) " (edit)="$event.stopPropagation()" - (cancel)="$event.stopPropagation()" + (cancel)=" + $event.stopPropagation(); + statusMessage2.value = loginRes?.statusMessage2 + " class="form-eidt" > {{ loginRes?.statusMessage2 }} @@ -411,7 +417,10 @@ onApplyStatusMessage(3, statusMessage3.value) " (edit)="$event.stopPropagation()" - (cancel)="$event.stopPropagation()" + (cancel)=" + $event.stopPropagation(); + statusMessage3.value = loginRes?.statusMessage3 + " class="form-eidt" > {{ loginRes?.statusMessage3 }} 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 cabed623..06b4b4a4 100644 --- a/projects/ucap-webmessenger-app/src/app/services/notification.service.ts +++ b/projects/ucap-webmessenger-app/src/app/services/notification.service.ts @@ -11,7 +11,8 @@ import { AuthenticationProtocolService, LogoutResponse, LogoutRemoteNotification, - LogoutNotification + LogoutNotification, + LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { NGXLogger } from 'ngx-logger'; @@ -446,7 +447,15 @@ export class AppNotificationService { .subscribe(); this.roomProtocolService.notification$ .pipe( - tap(notiOrRes => { + withLatestFrom( + this.store.pipe( + select( + (state: any) => + state.account.authentication.loginRes as LoginResponse + ) + ) + ), + tap(([notiOrRes, loginResInfo]) => { switch (notiOrRes.SSVC_TYPE) { case SSVC_TYPE_ROOM_INVITE_RES: { @@ -506,11 +515,29 @@ export class AppNotificationService { 'Notification::roomProtocolService::ExitNotification', noti ); - this.store.dispatch( - RoomStore.exitNotification({ - noti - }) - ); + + if (noti.SENDER_SEQ === loginResInfo.userSeq) { + this.store.dispatch( + RoomStore.exitNotification({ + noti + }) + ); + } else { + this.store.dispatch( + RoomStore.exitNotificationOthers({ + noti + }) + ); + + if (!!noti && !!noti.SENDER_SEQ) { + this.store.dispatch( + SyncStore.clearRoomUsers({ + roomSeq: noti.roomSeq, + userSeqs: [noti.SENDER_SEQ] + }) + ); + } + } } break; case SSVC_TYPE_ROOM_EXIT_FORCING_RES: diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts index 884db051..02427292 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/actions.ts @@ -42,6 +42,11 @@ export const infoFailure = createAction( props<{ error: any }>() ); +export const clearRoomUser = createAction( + '[Messenger::Room] clear room users', + props<{ userSeqs: number[] }>() +); + export const inviteNotification = createAction( '[Messenger::Room] Invite Notification', props<{ noti: InviteNotification }>() @@ -51,6 +56,10 @@ export const exitNotification = createAction( '[Messenger::Room] Exit Notification', props<{ noti: ExitNotification }>() ); +export const exitNotificationOthers = createAction( + '[Messenger::Room] Exit Notification By Others', + props<{ noti: ExitNotification }>() +); export const exitForcing = createAction( '[Messenger::Room] Exit Forcing', diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts index 262522ac..966aa15a 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/effects.ts @@ -67,7 +67,9 @@ import { updateTimeRoomIntervalFailure, exitForcing, exitForcingFailure, - exitForcingSuccess + exitForcingSuccess, + exitNotificationOthers, + clearRoomUser } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -340,6 +342,31 @@ export class Effects { }, { dispatch: false } ); + exitNotificationOthers$ = createEffect( + () => { + return this.actions$.pipe( + ofType(exitNotificationOthers), + withLatestFrom( + this.store.pipe( + select((state: any) => state.messenger.room.roomInfo as RoomInfo) + ) + ), + tap(([action, roomInfo]) => { + if ( + !!roomInfo && + roomInfo.roomSeq === action.noti.roomSeq && + !!action.noti && + !!action.noti.SENDER_SEQ + ) { + this.store.dispatch( + clearRoomUser({ userSeqs: [action.noti.SENDER_SEQ] }) + ); + } + }) + ); + }, + { dispatch: false } + ); updateFontNotification$ = createEffect( () => { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts index aa09416f..5969f577 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/room/reducers.ts @@ -4,7 +4,8 @@ import { infoSuccess, updateSuccess, updateRoomUserLastReadSeq, - updateTimeRoomIntervalSuccess + updateTimeRoomIntervalSuccess, + clearRoomUser } from './actions'; import * as AuthenticationStore from '@app/store/account/authentication'; @@ -26,6 +27,18 @@ export const reducer = createReducer( }; }), + on(clearRoomUser, (state, action) => { + return { + ...state, + userInfoList: adapterUserInfo.removeMany(action.userSeqs, { + ...state.userInfoList + }), + userInfoShortList: adapterUserInfoShort.removeMany(action.userSeqs, { + ...state.userInfoShortList + }) + }; + }), + on(updateSuccess, (state, action) => { return { ...state, diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts index 340d503c..342f2a60 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/actions.ts @@ -263,3 +263,9 @@ export const delGroupFailure = createAction( '[Messenger::Sync] Group Del Failure', props<{ error: any }>() ); + +/** 방 인원 클리어 */ +export const clearRoomUsers = createAction( + '[Messenger::Sync] Clear room users.', + props<{ roomSeq: string; userSeqs: number[] }>() +); diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts index e253f0de..5b231591 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/reducers.ts @@ -17,7 +17,8 @@ import { createGroupSuccess, delBuddySuccess, delGroupSuccess, - updateBuddySuccess + updateBuddySuccess, + clearRoomUsers } from './actions'; import { RoomUserDetailData, @@ -101,6 +102,52 @@ export const reducer = createReducer( }; }), + on(clearRoomUsers, (state, action) => { + let roomUserList: RoomUserDetailData = { + ...state.roomUser.entities[action.roomSeq] + }; + if ( + !!roomUserList && + !!roomUserList.userInfos && + roomUserList.userInfos.length > 0 + ) { + const userInfos = roomUserList.userInfos.filter( + userInfo => action.userSeqs.indexOf(userInfo.seq) < 0 + ); + roomUserList = { + ...roomUserList, + userInfos + }; + } + + let roomUserShortList: RoomUserData = { + ...state.roomUserShort.entities[action.roomSeq] + }; + if ( + !!roomUserShortList && + !!roomUserShortList.userInfos && + roomUserShortList.userInfos.length > 0 + ) { + const userInfos = roomUserShortList.userInfos.filter( + userInfo => action.userSeqs.indexOf(userInfo.seq) < 0 + ); + roomUserShortList = { + ...roomUserShortList, + userInfos + }; + } + + return { + ...state, + roomUser: adapterRoomUser.upsertOne(roomUserList, { + ...state.roomUser + }), + roomUserShort: adapterRoomUserShort.upsertOne(roomUserShortList, { + ...state.roomUserShort + }) + }; + }), + on(updateRoomForNewEventMessage, (state, action) => { const finalEventMessage: | string diff --git a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts index 6c16307f..9e391fbe 100644 --- a/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts +++ b/projects/ucap-webmessenger-ui-chat/src/lib/components/messages.component.ts @@ -141,6 +141,7 @@ export class MessagesComponent implements OnInit, OnDestroy { moment = moment; readToHereEvent: Info; + existReadToHereEvent = true; swapped = false; hidden = false; @@ -168,27 +169,37 @@ export class MessagesComponent implements OnInit, OnDestroy { this.initEventMore(); this.roomInfo = roomInfo; + + /** [S] initializing by changed room */ + // reset :: roomLastEventSeq + if (!!roomInfo && !!roomInfo.finalEventSeq) { + this.initRoomLastEventSeq = roomInfo.finalEventSeq; + } + // clear :: readToHearEvent object + this.readToHereEvent = undefined; + this.existReadToHereEvent = true; + /** [E] initializing by changed room */ }); this.eventListSubscription = this.eventList$.subscribe(eventList => { - if (!!eventList && eventList.length > 0 && this.baseEventSeq === 0) { - this.initRoomLastEventSeq = eventList[eventList.length - 1].seq; - } - - if ( - !!eventList && - eventList.length > 0 && - this.baseEventSeq > 0 && - !!this.roomInfo && - !!this.roomInfo.lastReadEventSeq && - this.baseEventSeq <= this.roomInfo.lastReadEventSeq - ) { - // 기존 대화 내용이 있는 상태에서 추가로 조회된 내용중에 read here 가 있을 경우. - this.firstCheckReadHere = false; - } - this.eventList = eventList; - this.readToHereEvent = this.getReadHere(); + if (!!eventList && eventList.length > 0) { + if (!this.readToHereEvent && this.existReadToHereEvent) { + this.readToHereEvent = this.getReadHere(); + } + + if ( + this.baseEventSeq > 0 && + !!this.roomInfo && + !!this.roomInfo.lastReadEventSeq && + this.baseEventSeq <= this.roomInfo.lastReadEventSeq + ) { + // 기존 대화 내용이 있는 상태에서 추가로 조회된 내용중에 read here 가 있을 경우. + this.firstCheckReadHere = false; + } + } else { + this.readToHereEvent = undefined; + } this.changeDetectorRef.detectChanges(); @@ -298,13 +309,9 @@ export class MessagesComponent implements OnInit, OnDestroy { // if (!this.userInfos || 0 === this.userInfos.length) { // return ''; // } - const unreadCnt = this.userInfos.filter(user => { - if (message.senderSeq === user.seq) { - // 본인 글은 unreadCount 에 포함하지 않는다. - return false; - } - return user.lastReadEventSeq < message.seq; - }).length; + const unreadCnt = this.userInfos + .filter(user => user.isJoinRoom && user.seq !== message.senderSeq) + .filter(user => user.lastReadEventSeq < message.seq).length; return unreadCnt === 0 ? '' : unreadCnt; } @@ -363,6 +370,8 @@ export class MessagesComponent implements OnInit, OnDestroy { ); } } + } else { + this.existReadToHereEvent = false; } return undefined; } diff --git a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html index 5effde68..b462077e 100644 --- a/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html +++ b/projects/ucap-webmessenger-ui-profile/src/lib/components/profile.component.html @@ -73,7 +73,9 @@ $event.stopPropagation(); onApplyIntroMessage(introMessage.value) " (edit)="$event.stopPropagation()" - (cancel)="$event.stopPropagation()" + (cancel)=" + $event.stopPropagation(); introMessage.value = userInfo.intro + " class="form-eidt" > {{ userInfo.intro }} @@ -167,20 +169,6 @@
    -
  • {{ 'profile.fieldCompany' | translate }}
    {{ userInfo.companyName | ucapStringEmptycheck }}
    diff --git a/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.ts b/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.ts index b14ec23f..de72d7b2 100644 --- a/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.ts +++ b/projects/ucap-webmessenger-ui-room/src/lib/components/list-item.component.ts @@ -94,13 +94,20 @@ export class ListItemComponent implements OnInit { } get _roomUserInfos() { - return this.roomUserInfo - .filter(roomUserInfo => { - return ( - this.loginRes.userSeq !== roomUserInfo.seq && roomUserInfo.isJoinRoom - ); - }) - .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)); + if (this.roomInfo.roomType === RoomType.Single) { + return this.roomUserInfo.filter(roomUserInfo => { + return this.loginRes.userSeq !== roomUserInfo.seq; + }); + } else { + return this.roomUserInfo + .filter(roomUserInfo => { + return ( + this.loginRes.userSeq !== roomUserInfo.seq && + roomUserInfo.isJoinRoom + ); + }) + .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0)); + } } getRoomNameByRoomUser(roomUserInfos: (RoomUserInfo | UserInfoShort)[]) {