import React from 'react'; import { seafileAPI } from '../../utils/seafile-api'; import { gettext } from '../../utils/constants'; class Notification extends React.Component { constructor(props) { super(props); this.state = { showNotice: false, notice_html: '', unseenCount: 0, }; } componentDidMount() { this.loadUnseenCount(); } onClick = () => { this.setState({ showNotice: !this.state.showNotice }); if (!this.state.showNotice) { this.loadNotices(); } 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({ notice_html: res.data.notice_html }); }); } render() { const { notice_html } = this.state; return (
); } } export default Notification;