From bf333785b9fd1728745f7781bf25d17119348981 Mon Sep 17 00:00:00 2001 From: Richard Park Date: Fri, 29 Nov 2019 18:32:30 +0900 Subject: [PATCH] bug fixed --- .../components/left-side.component.ts | 23 +++++++++++++------ .../src/lib/directives/image.directive.ts | 1 - 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts index 3736dde9..467165be 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts @@ -16,7 +16,7 @@ import { CreateChatDialogData, CreateChatDialogResult } from '@app/layouts/messenger/dialogs/chat/create-chat.dialog.component'; -import { Observable, Subscription, of } from 'rxjs'; +import { Subscription, of } from 'rxjs'; import { Store, select } from '@ngrx/store'; import * as AppStore from '@app/store'; @@ -28,8 +28,7 @@ import { UserInfoF, UserInfoDN } from '@ucap-webmessenger/protocol-query'; -import { MatTabChangeEvent, MatTabGroup } from '@angular/material'; -import { RightDrawer } from '@app/types'; +import { MatTabChangeEvent } from '@angular/material'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type'; @@ -38,7 +37,7 @@ import { KEY_VER_INFO } from '@app/types/ver-info.type'; import { MessageApiService } from '@ucap-webmessenger/api-message'; import { DeviceType } from '@ucap-webmessenger/core'; import { UnreadCountRequest } from 'projects/ucap-webmessenger-api-message/src/lib/apis/unread-count'; -import { map, catchError } from 'rxjs/operators'; +import { map, catchError, tap } from 'rxjs/operators'; import { MessageStatusCode } from '@ucap-webmessenger/api'; export enum MainMenu { @@ -82,6 +81,7 @@ export class LeftSideComponent implements OnInit, OnDestroy { sessionVerinfo: VersionInfo2Response; loginRes: LoginResponse; + loginResSubscription: Subscription; constructor( private store: Store, @@ -90,9 +90,6 @@ export class LeftSideComponent implements OnInit, OnDestroy { private messageApiService: MessageApiService, private logger: NGXLogger ) { - this.loginRes = this.sessionStorageService.get( - KEY_LOGIN_RES_INFO - ); this.sessionVerinfo = this.sessionStorageService.get( KEY_VER_INFO ); @@ -107,6 +104,15 @@ export class LeftSideComponent implements OnInit, OnDestroy { this.badgeChatUnReadCount = count; }); + this.loginResSubscription = this.store + .pipe( + select(AppStore.AccountSelector.AuthenticationSelector.loginRes), + tap(loginRes => { + this.loginRes = loginRes; + }) + ) + .subscribe(); + this.getMessageUnreadCount(); this.badgeMessageInterval = setInterval( () => this.getMessageUnreadCount(), @@ -124,6 +130,9 @@ export class LeftSideComponent implements OnInit, OnDestroy { if (!!this.badgeMessageUnReadCountSubscription) { this.badgeMessageUnReadCountSubscription.unsubscribe(); } + if (!!this.loginResSubscription) { + this.loginResSubscription.unsubscribe(); + } if (!!this.badgeMessageInterval) { clearInterval(this.badgeMessageInterval); diff --git a/projects/ucap-webmessenger-ui/src/lib/directives/image.directive.ts b/projects/ucap-webmessenger-ui/src/lib/directives/image.directive.ts index 64d91329..0ce4bdfa 100644 --- a/projects/ucap-webmessenger-ui/src/lib/directives/image.directive.ts +++ b/projects/ucap-webmessenger-ui/src/lib/directives/image.directive.ts @@ -62,7 +62,6 @@ export class ImageDirective implements OnInit, AfterViewInit, OnChanges { if (!!pathChanges && !pathChanges.firstChange) { this.loadImage(); - this.logger.debug('ucapImage.ngOnChanges', changes); } }