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 ( +
{link}
+ ) + } +} + +RealtimeNotification.propTypes = {} + +export default CSSModules(RealtimeNotification, styles) diff --git a/browser/components/RealtimeNotification.styl b/browser/components/RealtimeNotification.styl new file mode 100644 index 00000000..c6942f67 --- /dev/null +++ b/browser/components/RealtimeNotification.styl @@ -0,0 +1,2 @@ +.realtime-notification + font-size 1em diff --git a/browser/main/StatusBar/index.js b/browser/main/StatusBar/index.js index f3748548..fe074353 100644 --- a/browser/main/StatusBar/index.js +++ b/browser/main/StatusBar/index.js @@ -2,6 +2,7 @@ import React, { PropTypes } from 'react' import CSSModules from 'browser/lib/CSSModules' import styles from './StatusBar.styl' import ZoomManager from 'browser/main/lib/ZoomManager' +import RealtimeNotification from 'browser/components/RealtimeNotification' const electron = require('electron') const { remote, ipcRenderer } = electron @@ -59,7 +60,9 @@ class StatusBar extends React.Component { {Math.floor(config.zoom * 100)}% -
+ {status.updateReady ?