From f72f3b079ed0db8350d5f2f035e95edbed3a0907 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Wed, 16 Dec 2015 19:15:06 +0100 Subject: [PATCH] more wip --- lib/boards-api.js | 4 +++- webapp/pages/board-editor.jsx | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index ca1b074..d908936 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -271,7 +271,7 @@ BoardsAPI.prototype.getProfile = function (userID, done) { return this.ee } -BoardsAPI.prototype.getBoardSettings = function (userID, board) { +BoardsAPI.prototype.getBoardSettings = function (userID, board, done) { if (!userID) { return console.log('Invalid USERID', userID) } @@ -288,9 +288,11 @@ BoardsAPI.prototype.getBoardSettings = function (userID, board) { var settings = JSON.parse(resp.toString()) if (err) { this.ee.emit('error', err) + if (done && done.apply) done(err) } else { // SETTINGS file is here, need to parse it a little bit this.ee.emit('settings for ' + board + '@' + userID, settings, r) + if (done && done.apply) done(null, settings) if (settings.whitelist === true) { // Get the whitelist var url = r + this.baseurl + 'boards/' + board + '/whitelist' diff --git a/webapp/pages/board-editor.jsx b/webapp/pages/board-editor.jsx index 876dd10..07608a4 100644 --- a/webapp/pages/board-editor.jsx +++ b/webapp/pages/board-editor.jsx @@ -28,7 +28,19 @@ module.exports = function (boardsAPI) { }, getBoardSettings (boards) { if (!this.props.params.board) return - boards.getBoardSettings(boards.getMyID(), this.props.params.board) + this.setState({ loading: true }) + boards.getBoardSettings(boards.getMyID(), this.props.params.board, (err, s) => { + if (err) { + this.setState({ error: err, loading: false }) + } else { + this.setState({ + id: this.props.params.board, + name: s.fullname, + desc: s.description, + loading: false + }) + } + }) }, handleChange (event) { var obj = {} @@ -51,6 +63,7 @@ module.exports = function (boardsAPI) { } this.setState({ updating: true }) boards.createBoard(board, (err) => { + this.setState({ updating: false }) console.log('CREATE:', err) }) },