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