mirror of
https://github.com/zoriya/flood.git
synced 2026-05-30 18:10:09 +00:00
NotificationStore: make hasNotification a computed property
This commit is contained in:
@@ -264,15 +264,13 @@ class NotificationsButton extends Component<WrappedComponentProps, Notifications
|
||||
render() {
|
||||
const {intl} = this.props;
|
||||
const {isLoading, prevHeight} = this.state;
|
||||
const {notifications, notificationCount} = NotificationStore;
|
||||
|
||||
const hasNotifications = notificationCount.total !== 0;
|
||||
const {hasNotification, notifications, notificationCount} = NotificationStore;
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
contentClassName="tooltip__content tooltip__content--no-padding"
|
||||
content={
|
||||
hasNotifications ? (
|
||||
hasNotification ? (
|
||||
<div
|
||||
className={classnames('notifications', {
|
||||
'notifications--is-loading': isLoading,
|
||||
@@ -303,7 +301,7 @@ class NotificationsButton extends Component<WrappedComponentProps, Notifications
|
||||
wrapperClassName="sidebar__action sidebar__icon-button
|
||||
tooltip__wrapper">
|
||||
<NotificationIcon />
|
||||
{hasNotifications ? <span className="notifications__badge">{notificationCount.total}</span> : null}
|
||||
{hasNotification ? <span className="notifications__badge">{notificationCount.total}</span> : null}
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {makeAutoObservable} from 'mobx';
|
||||
import {computed, makeAutoObservable} from 'mobx';
|
||||
|
||||
import type {Notification, NotificationCount, NotificationState} from '@shared/types/Notification';
|
||||
|
||||
@@ -8,6 +8,10 @@ class NotificationStore {
|
||||
notifications: Array<Notification> = [];
|
||||
notificationCount: NotificationCount = INITIAL_COUNT_STATE;
|
||||
|
||||
@computed get hasNotification() {
|
||||
return this.notificationCount.total !== 0;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user