diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html index 69385770..e15a22b6 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.html @@ -1,3 +1,9 @@ - + diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts index 15b0020d..a40630eb 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/chat.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { ucapAnimations } from '@ucap-webmessenger/ui'; import { NGXLogger } from 'ngx-logger'; import { Store, select } from '@ngrx/store'; -import { Subscription, combineLatest } from 'rxjs'; +import { Subscription, combineLatest, Observable } from 'rxjs'; import { RoomInfo, UserInfoShort, @@ -18,6 +18,7 @@ import { import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { KEY_VER_INFO } from '@app/types/ver-info.type'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; @Component({ selector: 'app-layout-chat-left-sidenav-chat', @@ -30,6 +31,7 @@ export class ChatComponent implements OnInit, OnDestroy { roomUserList: RoomUserDetailData[]; roomUserShortList: RoomUserData[]; sessionVerinfo: VersionInfo2Response; + loginRes$: Observable; roomSubscription: Subscription; @@ -60,6 +62,10 @@ export class ChatComponent implements OnInit, OnDestroy { ) .subscribe(); + this.loginRes$ = this.store.pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes) + ); + this.sessionVerinfo = this.sessionStorageService.get( KEY_VER_INFO ); diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts index 01e4f721..4dd59dec 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-sidenav/group.component.ts @@ -238,6 +238,23 @@ export class GroupComponent implements OnInit, OnDestroy { 'group', group ); + switch (menuType) { + case 'CHAT': + this.store.dispatch( + ChatStore.openRoom({ userSeqList: group.userSeqs }) + ); + break; + case 'SEND_NOTE': + break; + case 'RENAME': + break; + case 'EDIT_MEMBER': + break; + case 'REMOVE': + break; + default: + break; + } } onMoreGroup(params: { event: MouseEvent; group: GroupDetailData }) { diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts index 7ca32baa..d55509ee 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/chat/actions.ts @@ -34,3 +34,8 @@ export const massTalkDownloadFailure = createAction( '[Messenger::Chat] massTalkDownload Failure', props<{ error: any }>() ); + +export const openRoom = createAction( + '[Messenger::Chat] Open Room', + props<{ userSeqList: number[] }>() +); 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 39e0df30..c1121182 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 @@ -9,7 +9,9 @@ import { ExitForcingNotification, UpdateFontNotification, UpdateResponse, - UpdateRequest + UpdateRequest, + OpenRequest, + OpenResponse } from '@ucap-webmessenger/protocol-room'; export const info = createAction( @@ -72,3 +74,20 @@ export const updateFailure = createAction( '[Messenger::Room] Update Failure', props<{ error: any }>() ); + +export const open = createAction( + '[Messenger::Room] Open', + props<{ req: OpenRequest }>() +); + +export const openSuccess = createAction( + '[Messenger::Room] Open Success', + props<{ + res: OpenResponse; + }>() +); + +export const openFailure = createAction( + '[Messenger::Room] Open Failure', + props<{ error: any }>() +); 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 8b91b6ea..ea6cca3c 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 @@ -27,7 +27,8 @@ import { SSVC_TYPE_ROOM_INFO_RES, UserShortData, UserData, - UpdateResponse + UpdateResponse, + OpenResponse } from '@ucap-webmessenger/protocol-room'; import * as ChatStore from '@app/store/messenger/chat'; @@ -43,7 +44,10 @@ import { updateOnlyAlarm, update, updateSuccess, - updateFailure + updateFailure, + open, + openSuccess, + openFailure } from './actions'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; @@ -143,6 +147,30 @@ export class Effects { ) ); + open$ = createEffect(() => + this.actions$.pipe( + ofType(open), + map(action => action.req), + exhaustMap(req => { + return this.roomProtocolService.open(req).pipe( + map((res: OpenResponse) => { + return openSuccess({ res }); + }), + catchError(error => of(openFailure({ error }))) + ); + }) + ) + ); + + openSuccess$ = createEffect(() => + this.actions$.pipe( + ofType(openSuccess), + map(action => { + return ChatStore.selectedRoom({ roomSeq: action.res.roomSeq }); + }) + ) + ); + inviteNotification$ = createEffect( () => { return this.actions$.pipe( diff --git a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts index e437a975..7cd4fab0 100644 --- a/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts +++ b/projects/ucap-webmessenger-app/src/app/store/messenger/sync/effects.ts @@ -59,6 +59,9 @@ import { import { LoginInfo, KEY_LOGIN_INFO } from '@app/types'; import * as ChatStore from '@app/store/messenger/chat'; +import * as RoomStore from '@app/store/messenger/room'; +import { Dictionary } from '@ngrx/entity'; +import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; @Injectable() export class Effects { @@ -241,6 +244,90 @@ export class Effects { { dispatch: false } ); + openRoom$ = createEffect( + () => + this.actions$.pipe( + ofType(ChatStore.openRoom), + withLatestFrom( + this.store.pipe( + select( + (state: any) => + state.account.authentication.loginRes as LoginResponse + ) + ), + this.store.pipe( + select( + (state: any) => + state.messenger.sync.roomUser.entities as Dictionary< + RoomUserDetailData + > + ) + ), + this.store.pipe( + select( + (state: any) => + state.messenger.sync.roomUserShort.entities as Dictionary< + RoomUserData + > + ) + ) + ), + tap(([action, loginRes, roomUsers, roomUserShorts]) => { + const userSeqList = [...action.userSeqList, loginRes.userSeq]; + let roomSeq = null; + + for (const key in roomUsers) { + if (roomUsers.hasOwnProperty(key)) { + const element = roomUsers[key]; + if (userSeqList.length === element.userInfos.length) { + roomSeq = key; + for (const roomUserInfo of element.userInfos) { + if (-1 === userSeqList.indexOf(roomUserInfo.seq)) { + roomSeq = null; + break; + } + } + } + } + } + + for (const key in roomUserShorts) { + if (roomUserShorts.hasOwnProperty(key)) { + const element = roomUserShorts[key]; + if (userSeqList.length === element.userInfos.length) { + roomSeq = key; + for (const roomUserDetailData of element.userInfos) { + if (-1 === userSeqList.indexOf(roomUserDetailData.seq)) { + roomSeq = null; + break; + } + } + } + } + } + + this.logger.debug( + 'openRoom', + 'userSeqList', + userSeqList, + 'roomSeq', + roomSeq + ); + if (!!roomSeq) { + this.store.dispatch(ChatStore.selectedRoom({ roomSeq })); + return; + } + + this.store.dispatch( + RoomStore.open({ + req: { divCd: 'DivCode', userSeqs: userSeqList } + }) + ); + }) + ), + { dispatch: false } + ); + constructor( private actions$: Actions, private store: Store, diff --git a/projects/ucap-webmessenger-ui-group/src/lib/ucap-ui-group.module.ts b/projects/ucap-webmessenger-ui-group/src/lib/ucap-ui-group.module.ts index 23da00ab..de1174fa 100644 --- a/projects/ucap-webmessenger-ui-group/src/lib/ucap-ui-group.module.ts +++ b/projects/ucap-webmessenger-ui-group/src/lib/ucap-ui-group.module.ts @@ -10,16 +10,15 @@ import { MatIconModule } from '@angular/material/icon'; import { ExpansionPanelComponent } from './components/expansion-panel.component'; import { ExpansionPanelItemDirective } from './directives/expansion-panel-item.directive'; -import { UCapUiProfileModule } from '@ucap-webmessenger/ui-profile'; const COMPONENTS = [ExpansionPanelComponent]; +const DIALOGS = []; const DIRECTIVES = [ExpansionPanelItemDirective]; const SERVICES = []; @NgModule({ imports: [ CommonModule, - UCapUiProfileModule, ReactiveFormsModule, FlexLayoutModule, MatButtonModule, @@ -27,7 +26,8 @@ const SERVICES = []; MatIconModule ], exports: [...COMPONENTS, ...DIRECTIVES], - declarations: [...COMPONENTS, ...DIRECTIVES] + declarations: [...COMPONENTS, ...DIRECTIVES], + entryComponents: [] }) export class UCapUiGroupModule { public static forRoot(): ModuleWithProviders { diff --git a/projects/ucap-webmessenger-ui-group/src/public-api.ts b/projects/ucap-webmessenger-ui-group/src/public-api.ts index af7c2271..a61631d7 100644 --- a/projects/ucap-webmessenger-ui-group/src/public-api.ts +++ b/projects/ucap-webmessenger-ui-group/src/public-api.ts @@ -4,4 +4,6 @@ export * from './lib/components/expansion-panel.component'; +export * from './lib/directives/expansion-panel-item.directive'; + export * from './lib/ucap-ui-group.module'; 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 c98acf73..5975c2c3 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 @@ -14,6 +14,10 @@ import { MassTextInfo } from '@ucap-webmessenger/ui-chat'; import { FileType } from '@ucap-webmessenger/protocol-file'; +import { + LoginResponse, + UserInfo +} from '@ucap-webmessenger/protocol-authentication'; @Component({ selector: 'ucap-room-list-item', @@ -21,6 +25,9 @@ import { FileType } from '@ucap-webmessenger/protocol-file'; styleUrls: ['./list-item.component.scss'] }) export class ListItemComponent implements OnInit { + @Input() + loginRes: LoginResponse; + @Input() roomInfo: RoomInfo; @Input() @@ -95,13 +102,18 @@ export class ListItemComponent implements OnInit { if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) { let roomName = ''; - this.roomUserInfo.forEach((roomUserInfo, index) => { - if (0 === index) { - roomName = roomName.concat('', roomUserInfo.name); - } else { - roomName = roomName.concat(',', roomUserInfo.name); + this.roomUserInfo.forEach( + (roomUserInfo: RoomUserInfo | UserInfoShort, index: number) => { + if (this.loginRes.userSeq === roomUserInfo.seq) { + return; + } + if ('' === roomName.trim()) { + roomName = roomName.concat('', roomUserInfo.name); + } else { + roomName = roomName.concat(',', roomUserInfo.name); + } } - }); + ); return roomName; } }