bugfix : duplication message unread count retrieve

This commit is contained in:
leejinho 2020-02-04 09:52:43 +09:00
parent 8629d1f321
commit f98acedbb2
3 changed files with 11 additions and 56 deletions

View File

@ -34,8 +34,8 @@
<ng-template mat-tab-label>
<div
class="icon-item"
[matBadgeHidden]="badgeChatUnReadCount <= 0"
[matBadge]="badgeChatUnReadCount"
[matBadgeHidden]="(badgeChatUnReadCount$ | async) <= 0"
[matBadge]="badgeChatUnReadCount$ | async"
matBadgeDescription="{{
'chat.badgeDescriptionForUnread' | translate
}}"

View File

@ -1,20 +1,14 @@
import {
Component,
OnInit,
OnDestroy,
} from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
import { ucapAnimations } from '@ucap-webmessenger/ui';
import { Subscription, Observable, } from 'rxjs';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
import * as MessageStore from '@app/store/messenger/message';
import * as SettingsStore from '@app/store/messenger/settings';
import { MatTabChangeEvent } from '@angular/material';
import {
MainMenu
} from '@app/types';
import { MainMenu } from '@app/types';
@Component({
selector: 'app-layout-messenger-left-nav',
@ -23,8 +17,7 @@ import {
animations: ucapAnimations
})
export class LeftNaviComponent implements OnInit, OnDestroy {
badgeChatUnReadCount: number;
badgeChatUnReadCountSubscription: Subscription;
badgeChatUnReadCount$: Observable<number>;
badgeMessageUnReadCount$: Observable<number>;
badgeMessageInterval: any;
@ -33,13 +26,10 @@ export class LeftNaviComponent implements OnInit, OnDestroy {
constructor(private store: Store<any>, private logger: NGXLogger) {}
ngOnInit() {
this.badgeChatUnReadCountSubscription = this.store
.pipe(
select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount)
)
.subscribe(count => {
this.badgeChatUnReadCount = count;
});
/** About Chat Badge */
this.badgeChatUnReadCount$ = this.store.pipe(
select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount)
);
/** About Message Badge */
this.badgeMessageUnReadCount$ = this.store.pipe(
@ -54,10 +44,6 @@ export class LeftNaviComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
if (!!this.badgeChatUnReadCountSubscription) {
this.badgeChatUnReadCountSubscription.unsubscribe();
}
if (!!this.badgeMessageInterval) {
clearInterval(this.badgeMessageInterval);
}

View File

@ -17,7 +17,7 @@ import {
CreateChatDialogData,
CreateChatDialogResult
} from '@app/layouts/messenger/dialogs/chat/create-chat.dialog.component';
import { Subscription, Observable, merge } from 'rxjs';
import { Subscription, merge } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
@ -76,11 +76,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
onLangChangeSubscription: Subscription;
badgeChatUnReadCount: number;
badgeChatUnReadCountSubscription: Subscription;
badgeMessageUnReadCount$: Observable<number>;
badgeMessageInterval: any;
/** 조직도에서 부서원 선택 */
selectedUserList: (UserInfo | UserInfoSS | UserInfoF | UserInfoDN)[] = [];
@ -113,14 +108,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.badgeChatUnReadCountSubscription = this.store
.pipe(
select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount)
)
.subscribe(count => {
this.badgeChatUnReadCount = count;
});
this.loginResSubscription = this.store
.pipe(
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
@ -130,17 +117,6 @@ export class LeftSideComponent implements OnInit, OnDestroy {
)
.subscribe();
/** About Message Badge */
this.badgeMessageUnReadCount$ = this.store.pipe(
select(AppStore.MessengerSelector.MessageSelector.unReadMessageCount)
);
this.getMessageUnreadCount();
this.badgeMessageInterval = setInterval(
() => this.getMessageUnreadCount(),
5 * 60 * 1000
);
this.setFabInitial(MainMenu.Group);
this.currentTabLable = MainMenu.Group;
@ -164,19 +140,12 @@ export class LeftSideComponent implements OnInit, OnDestroy {
}
ngOnDestroy(): void {
if (!!this.badgeChatUnReadCountSubscription) {
this.badgeChatUnReadCountSubscription.unsubscribe();
}
if (!!this.loginResSubscription) {
this.loginResSubscription.unsubscribe();
}
if (!!this.onLangChangeSubscription) {
this.onLangChangeSubscription.unsubscribe();
}
if (!!this.badgeMessageInterval) {
clearInterval(this.badgeMessageInterval);
}
}
async onClickNewChat(type: string = 'NORMAL') {