import React from 'react'; import { seafileAPI } from '../../utils/seafile-api'; import { gettext, siteRoot } from '../../utils/constants'; class Notification extends React.Component { constructor(props) { super(props); this.state = { showNotice: false, notice_html: '', unseenCount: 0, }; } componentDidMount() { seafileAPI.getUnseenNotificationCount().then(res => { this.setState({unseenCount: res.data.unseen_count}); }); } onClick = () => { if (this.state.showNotice) { seafileAPI.updateNotifications(); this.setState({ showNotice: false, unseenCount: 0 }) } else { this.loadNotices(); this.setState({showNotice: true}); } } loadNotices = () => { seafileAPI.listPopupNotices().then(res => { this.setState({ notice_html: res.data.notice_html }); }); } render() { const { notice_html } = this.state; return (
); } } export default Notification;