diff --git a/frontend/src/components/common/notification.js b/frontend/src/components/common/notification.js index a93af31c79..8fcdb50206 100644 --- a/frontend/src/components/common/notification.js +++ b/frontend/src/components/common/notification.js @@ -7,21 +7,27 @@ class Notification extends React.Component { super(props); this.state = { showNotice: false, - notice_html: '' + notice_html: '', + unseenCount: 0, }; } - onClick = () => { - this.setState({ - showNotice: !this.state.showNotice + componentDidMount() { + seafileAPI.getUnseenNotificationCount().then(res => { + this.setState({unseenCount: res.data.unseen_count}); }); + } - if (!this.state.showNotice) { - this.loadNotices(); - } - + onClick = () => { if (this.state.showNotice) { seafileAPI.updateNotifications(); + this.setState({ + showNotice: false, + unseenCount: 0 + }) + } else { + this.loadNotices(); + this.setState({showNotice: true}); } } @@ -40,7 +46,7 @@ class Notification extends React.Component {