diff --git a/browser/components/RealtimeNotification.js b/browser/components/RealtimeNotification.js new file mode 100644 index 00000000..3d748046 --- /dev/null +++ b/browser/components/RealtimeNotification.js @@ -0,0 +1,54 @@ +import React, { PropTypes } from 'react' +import CSSModules from 'browser/lib/CSSModules' +import styles from './RealtimeNotification.styl' + +const electron = require('electron') +const { shell } = electron + +class RealtimeNotification extends React.Component { + constructor (props) { + super(props) + + this.state = { + notifications: [] + } + } + + componentDidMount () { + this.fetchNotifications() + } + + fetchNotifications () { + fetch('https://raw.githubusercontent.com/asmsuechan/notification/master/notification.json') + .then(response => { + return response.json() + }) + .then(json => { + this.setState({notifications: json.notifications}) + }) + } + + handleLinkClick (e) { + shell.openExternal(e.currentTarget.href) + e.preventDefault() + } + + render () { + const { notifications } = this.state + const link = notifications.length > 0 + ? this.handleLinkClick(e)} + > + {notifications[0].text} + + : '' + + return ( +