From 14cbe3a00f4469646595a7de31930f5b4a86c0c3 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Tue, 15 Dec 2015 17:15:12 +0100 Subject: [PATCH] wip auto updater --- lib/boards-api.js | 4 ++++ webapp/components/navbar.jsx | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index 4e3e97a..1fa9dfd 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -816,4 +816,8 @@ BoardsAPI.prototype.getMyID = function () { return this.id } +BoardsAPI.prototype.getIPFS = function () { + return this.ipfs +} + module.exports = BoardsAPI diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx index 19881c7..9fad3f8 100644 --- a/webapp/components/navbar.jsx +++ b/webapp/components/navbar.jsx @@ -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
+ } +}) + 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 + } else if (this.state.loading) { return @@ -38,7 +57,7 @@ module.exports = function (boardsAPI) { return (
- {this.props.children ||

Boards

} +

Boards

{this.extraButtons()}