Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions browser/components/RealtimeNotification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 () {
const notificationsUrl = 'https://raw.githubusercontent.com/BoostIO/notification/master/notification.json'
fetch(notificationsUrl)
.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
? <a href={notifications[0].linkUrl}
onClick={(e) => this.handleLinkClick(e)}
>
{notifications[0].text}
</a>
: ''

return (
<div>{link}</div>
)
}
}

RealtimeNotification.propTypes = {}

export default CSSModules(RealtimeNotification, styles)
2 changes: 2 additions & 0 deletions browser/components/RealtimeNotification.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.realtime-notification
font-size 1em
5 changes: 4 additions & 1 deletion browser/main/StatusBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,7 +60,9 @@ class StatusBar extends React.Component {
{Math.floor(config.zoom * 100)}%
</button>

<div styleName='blank' />
<RealtimeNotification
styleName='realtime-notification'
/>

{status.updateReady
? <button onClick={this.updateApp} styleName='update'>
Expand Down