From 0bf9dcca1f13364e4ab59d64eb8570449ed0cd44 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Thu, 17 Dec 2015 19:51:54 +0100 Subject: [PATCH] improvements to post editor and board viewer --- webapp/pages/board.jsx | 21 +++++++++++++-------- webapp/pages/post-editor.jsx | 6 +++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/webapp/pages/board.jsx b/webapp/pages/board.jsx index b91d2b9..2dc9c44 100644 --- a/webapp/pages/board.jsx +++ b/webapp/pages/board.jsx @@ -46,13 +46,14 @@ module.exports = function (boardsAPI) { } }) }, - init (boards) { - if (!this.state.init) { - if (this.props.params.userid) { - boards.getBoardSettings(this.props.params.userid, this.props.params.boardname) - } - this.setState({ init: true, api: true, boards: boards }) - } + componentWillReceiveProps (props) { + boardsAPI.use(b => this.init(b, props)) + }, + init (boards, newProps) { + var props = newProps || this.props + if (!props.params.userid) return + boards.getBoardSettings(props.params.userid, props.params.boardname) + this.setState({ loading: true, init: true, api: true, userid: boards.getMyID(), boards: boards }) }, toolbox () { return
@@ -63,7 +64,11 @@ module.exports = function (boardsAPI) { render () { if (this.state.api) { if (this.state.loading) { - return + return + { this.props.params.userid === 'me' || this.props.params.userid === this.state.userid + ? Edit Board + : } + } else { return (

{this.state.name}

diff --git a/webapp/pages/post-editor.jsx b/webapp/pages/post-editor.jsx index 08e21e5..78f4e6f 100644 --- a/webapp/pages/post-editor.jsx +++ b/webapp/pages/post-editor.jsx @@ -24,7 +24,7 @@ module.exports = function (boardsAPI) { }, init (boards) { if (this.state.init) return - this.setState({ api: boards, init: true }) + this.setState({ api: boards, userid: boards.getMyID(), init: true }) if (this.props.params.posthash) this.downloadPost(boards) }, downloadPost (boards) { @@ -88,6 +88,9 @@ module.exports = function (boardsAPI) { } else { + if (this.state.userid && this.props.params.boardname) { + var boardurl = '/@' + this.state.userid + '/' + this.props.params.boardname + } return (

@@ -109,6 +112,7 @@ module.exports = function (boardsAPI) {

+ {boardurl ? View Board : } {this.additionalButtons()}