diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.html index 1be8d256..6a8b84aa 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.html @@ -3,6 +3,7 @@ mat-stretch-tabs animationDuration="0ms" [backgroundColor]="'transparent'" + [selectedIndex]="gnbMenuIndex" (selectedTabChange)="onSelectedTabChange($event)" class="global-menu" > diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts index 093061a9..5b05675c 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-nav.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, OnDestroy } from '@angular/core'; import { NGXLogger } from 'ngx-logger'; import { ucapAnimations } from '@ucap-webmessenger/ui'; -import { Observable } from 'rxjs'; +import { Observable, Subscribable, Subscription } from 'rxjs'; import { Store, select } from '@ngrx/store'; import * as AppStore from '@app/store'; @@ -9,6 +9,7 @@ import * as MessageStore from '@app/store/messenger/message'; import * as SettingsStore from '@app/store/messenger/settings'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { MainMenu } from '@app/types'; +import { tap, map } from 'rxjs/operators'; @Component({ selector: 'app-layout-messenger-left-nav', @@ -22,6 +23,8 @@ export class LeftNaviComponent implements OnInit, OnDestroy { badgeMessageInterval: any; MainMenu = MainMenu; + gnbMenuIndexSubscription: Subscription; + gnbMenuIndex: number; constructor(private store: Store, private logger: NGXLogger) {} @@ -41,12 +44,34 @@ export class LeftNaviComponent implements OnInit, OnDestroy { () => this.getMessageUnreadCount(), 5 * 60 * 1000 ); + + this.gnbMenuIndexSubscription = this.store + .pipe(select(AppStore.MessengerSelector.SettingsSelector.gnbMenuIndex)) + .subscribe(index => { + switch (index) { + case MainMenu.Group: + this.gnbMenuIndex = 0; + break; + case MainMenu.Chat: + this.gnbMenuIndex = 1; + break; + case MainMenu.Organization: + this.gnbMenuIndex = 2; + break; + case MainMenu.Message: + this.gnbMenuIndex = 3; + break; + } + }); } ngOnDestroy(): void { if (!!this.badgeMessageInterval) { clearInterval(this.badgeMessageInterval); } + if (!!this.gnbMenuIndexSubscription) { + this.gnbMenuIndexSubscription.unsubscribe(); + } this.logger.debug('-----------------------LeftNaviComponent ngOnDestroy'); } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.ts index 9af053a3..31378861 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents.component.ts @@ -5,6 +5,7 @@ import * as AppStore from '@app/store'; import { select, Store } from '@ngrx/store'; import { MainMenu } from '@app/types'; +import { tap } from 'rxjs/operators'; @Component({ selector: 'app-layout-messenger-main-contents', @@ -33,7 +34,12 @@ export class MainContentsComponent implements OnInit { ngOnInit() { this.gnbMenuIndex$ = this.store.pipe( - select(AppStore.MessengerSelector.SettingsSelector.gnbMenuIndex) + select(AppStore.MessengerSelector.SettingsSelector.gnbMenuIndex), + tap(index => { + if (index === MainMenu.Organization) { + this.closeRightDrawer.emit(); + } + }) ); } diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents/organization.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents/organization.component.ts index 18b3f814..f117151a 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents/organization.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/main-contents/organization.component.ts @@ -18,19 +18,16 @@ import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { Store, select } from '@ngrx/store'; import * as AppStore from '@app/store'; -import * as QueryStore from '@app/store/messenger/query'; +import * as SettingsStore from '@app/store/messenger/settings'; import * as SyncStore from '@app/store/messenger/sync'; import * as ChatStore from '@app/store/messenger/chat'; -import * as StatusStore from '@app/store/messenger/status'; -import { Observable, Subscription, combineLatest } from 'rxjs'; -import { PresenceType, StatusCode } from '@ucap-webmessenger/core'; -import { - StatusBulkInfo, - WorkStatusType -} from '@ucap-webmessenger/protocol-status'; + +import { Observable, Subscription } from 'rxjs'; +import { PresenceType } from '@ucap-webmessenger/core'; +import { StatusBulkInfo } from '@ucap-webmessenger/protocol-status'; import { VersionInfo2Response } from '@ucap-webmessenger/api-public'; -import { KEY_VER_INFO, KEY_AUTH_INFO } from '@app/types'; -import { Sort } from '@angular/material/sort'; +import { KEY_VER_INFO, KEY_AUTH_INFO, MainMenu } from '@app/types'; + import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { tap } from 'rxjs/operators'; import { @@ -237,9 +234,17 @@ export class OrganizationComponent implements OnInit, OnDestroy { } onClickChatOpen() { if (!!this.selectedUserList && this.selectedUserList.length > 0) { + // Open Room. const seq: number[] = []; this.selectedUserList.map(user => seq.push(user.seq)); this.store.dispatch(ChatStore.openRoom({ userSeqList: seq })); + + // GNB Change to Chat + this.store.dispatch( + SettingsStore.selectedGnbMenuIndex({ + menuIndex: MainMenu.Chat + }) + ); } } onClickConference() { diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts index 5807d352..ef6bf2f5 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/dialogs/profile/profile.dialog.component.ts @@ -1,11 +1,17 @@ import { Component, OnInit, Inject, OnDestroy } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { KEY_LOGIN_RES_INFO, KEY_VER_INFO, KEY_AUTH_INFO } from '@app/types'; +import { + KEY_LOGIN_RES_INFO, + KEY_VER_INFO, + KEY_AUTH_INFO, + MainMenu +} from '@app/types'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { Store, select } from '@ngrx/store'; import * as AppStore from '@app/store'; import * as ChatStore from '@app/store/messenger/chat'; +import * as SettingsStore from '@app/store/messenger/settings'; import * as SyncStore from '@app/store/messenger/sync'; import * as AuthenticationStore from '@app/store/account/authentication'; @@ -194,6 +200,13 @@ export class ProfileDialogComponent implements OnInit, OnDestroy { this.store.dispatch(ChatStore.openRoom({ userSeqList: [userInfo.seq] })); } + // GNB Change to Chat + this.store.dispatch( + SettingsStore.selectedGnbMenuIndex({ + menuIndex: MainMenu.Chat + }) + ); + this.dialogRef.close({ closeEvent: 'CHAT' }); }