1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-31 22:54:11 +00:00

improve notification

This commit is contained in:
shanshuirenjia
2018-12-25 18:25:16 +08:00
parent 50c4a1edd6
commit 9e149ac2e1
3 changed files with 35 additions and 21 deletions

View File

@@ -7,10 +7,15 @@ class Notification extends React.Component {
super(props);
this.state = {
showNotice: false,
notice_html: ''
notice_html: '',
unseenCount: 0,
};
}
componentDidMount() {
this.loadUnseenCount();
}
onClick = () => {
this.setState({
showNotice: !this.state.showNotice
@@ -22,9 +27,16 @@ class Notification extends React.Component {
if (this.state.showNotice) {
seafileAPI.updateNotifications();
this.loadUnseenCount();
}
}
loadUnseenCount = () => {
seafileAPI.getUnseenCount().then(res => {
this.setState({unseenCount: res.data.unseen_count});
});
}
loadNotices = () => {
seafileAPI.listPopupNotices().then(res => {
this.setState({
@@ -40,7 +52,7 @@ class Notification extends React.Component {
<div id="notifications">
<a href="#" onClick={this.onClick} className="no-deco" id="notice-icon" title="Notifications" aria-label="Notifications">
<span className="sf2-icon-bell"></span>
<span className="num hide">0</span>
<span className={`num ${this.state.unseenCount ? '' : 'hide'}`}>{this.state.unseenCount}</span>
</a>
<div id="notice-popover" className={`sf-popover ${this.state.showNotice ? '': 'hide'}`}>
<div className="outer-caret up-outer-caret"><div className="inner-caret"></div></div>