mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-01-10 12:24:20 +01:00
wip auto updater
This commit is contained in:
parent
9567b99a26
commit
14cbe3a00f
@ -816,4 +816,8 @@ BoardsAPI.prototype.getMyID = function () {
|
||||
return this.id
|
||||
}
|
||||
|
||||
BoardsAPI.prototype.getIPFS = function () {
|
||||
return this.ipfs
|
||||
}
|
||||
|
||||
module.exports = BoardsAPI
|
||||
|
@ -2,20 +2,38 @@ var React = require('react')
|
||||
var Icon = require('icon.jsx')
|
||||
var Link = require('react-router').Link
|
||||
|
||||
var Updater = React.createClass({
|
||||
componentDidMount () {
|
||||
if (this.props.api) this.checkForUpdates(this.props.api)
|
||||
},
|
||||
componentWillReceiveProps (props) {
|
||||
this.checkForUpdates(props.api)
|
||||
},
|
||||
checkForUpdates (boards) {
|
||||
var v = window.location.pathname
|
||||
if (/\/ip(f|n)s\/./.test(v)) {
|
||||
// Advise user to run from another URL
|
||||
}
|
||||
},
|
||||
render () {
|
||||
return <div></div>
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = function (boardsAPI) {
|
||||
return React.createClass({
|
||||
getInitialState: function () {
|
||||
return { api: false, loading: true }
|
||||
return { loading: true }
|
||||
},
|
||||
componentDidMount () {
|
||||
boardsAPI.use(boards => {
|
||||
if (boards.isInit) this.setState({ api: true, userid: boards.getMyID() })
|
||||
if (boards.isInit) this.setState({ api: boards, userid: boards.getMyID() })
|
||||
boards.getEventEmitter().on('init', (err, limited) => {
|
||||
if (!this.isMounted()) return
|
||||
if (err) {
|
||||
this.setState({ loading: false, api: false, limited })
|
||||
} else {
|
||||
this.setState({ api: true, userid: boards.getMyID(), limited })
|
||||
this.setState({ api: boards, userid: boards.getMyID(), limited })
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -25,6 +43,7 @@ module.exports = function (boardsAPI) {
|
||||
return <span>
|
||||
<Link className="nounderline" to={'/@' + this.state.userid}><Icon name="user" className="fa-2x light"/></Link>
|
||||
<Link className="nounderline" to="/users"><Icon name="globe" className="fa-2x light"/></Link>
|
||||
<Updater api={this.state.api} />
|
||||
</span>
|
||||
} else if (this.state.loading) {
|
||||
return <Link className="nounderline" to="/status"><Icon name="refresh" className="fa-2x fa-spin light"/></Link>
|
||||
@ -38,7 +57,7 @@ module.exports = function (boardsAPI) {
|
||||
return (
|
||||
<div className="navbar">
|
||||
<div className="container">
|
||||
{this.props.children || <h4><Link to="/"><Icon name="comments" className="light"/> Boards</Link></h4>}
|
||||
<h4><Link to="/"><Icon name="comments" className="light"/> Boards</Link></h4>
|
||||
<div className="u-pull-right iconbar">
|
||||
{this.extraButtons()}
|
||||
<Link className="nounderline" to="/settings"><Icon name="cog" className="fa-2x light"/></Link>
|
||||
|
Loading…
Reference in New Issue
Block a user