mirror of
https://github.com/zoriya/flood.git
synced 2026-06-05 03:39:24 +00:00
NotificationsButton: re-fetch notification only when count > 0
This commit is contained in:
@@ -71,7 +71,12 @@ class NotificationsButton extends Component<WrappedComponentProps, Notifications
|
|||||||
constructor(props: WrappedComponentProps) {
|
constructor(props: WrappedComponentProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
reaction(() => NotificationStore.notificationCount, this.handleNotificationCountChange);
|
reaction(
|
||||||
|
() => NotificationStore.notificationCount,
|
||||||
|
(count) => {
|
||||||
|
if (count.total > 0 && this.tooltipRef?.isOpen()) this.fetchNotifications();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@@ -225,12 +230,6 @@ class NotificationsButton extends Component<WrappedComponentProps, Notifications
|
|||||||
FloodActions.clearNotifications();
|
FloodActions.clearNotifications();
|
||||||
};
|
};
|
||||||
|
|
||||||
handleNotificationCountChange = () => {
|
|
||||||
if (this.tooltipRef != null && this.tooltipRef.isOpen()) {
|
|
||||||
this.fetchNotifications();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
handleNewerNotificationsClick = () => {
|
handleNewerNotificationsClick = () => {
|
||||||
if (this.state.paginationStart - NOTIFICATIONS_PER_PAGE >= 0) {
|
if (this.state.paginationStart - NOTIFICATIONS_PER_PAGE >= 0) {
|
||||||
this.setState((state) => {
|
this.setState((state) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user