From cf20ea26c0f642cc6e463f97ad1a67c12090d108 Mon Sep 17 00:00:00 2001 From: Julian Steinwachs Date: Fri, 22 Jan 2016 21:01:50 +0100 Subject: [PATCH] accounts page wip --- build/app-bundle.js | 110 +++++++++++++++++++++++++------------ build/twister-lib.js | 2 +- css/main.css | 4 ++ jsx/App.js | 63 +++++++++++++++------ jsx/common/ProfileBoard.js | 2 +- jsx/other/Accounts.js | 23 +++++--- jsx/other/Conversation.js | 14 ++++- 7 files changed, 153 insertions(+), 65 deletions(-) diff --git a/build/app-bundle.js b/build/app-bundle.js index 8d79103..fe850c3 100644 --- a/build/app-bundle.js +++ b/build/app-bundle.js @@ -107,12 +107,14 @@ App = React.createClass({displayName: "App", checkAccounts: function() { - this.state.accounts.map(function(acc){ + var thisComponent = this; + + thisComponent.state.accounts.map(function(acc){ - Twister.getAccount(newaccoutname).verifyKey(function(key){ + Twister.getAccount(acc.name).verifyKey(function(key){ thisComponent.setState(function(oldstate,props){ - oldstate.accounts[acc].status = key.getStatus(); + oldstate.accounts[acc.name].status = key.getStatus(); return oldstate; @@ -139,9 +141,11 @@ App = React.createClass({displayName: "App", onnewaccountbyuser: function(event) { + console.log("catched onnewaccountbyuser event !!!!! ",event,this.state) + this.saveCache(); - if(!this.activeAccount){ + if(!this.state.activeAccount){ this.switchAccount(event.detail.getUsername()); @@ -163,17 +167,41 @@ App = React.createClass({displayName: "App", //console.log(firstroute); - var userbuttons = []; - for (var i in this.state.accounts) { - userbuttons.push( - React.createElement(MenuItem, { - key: this.state.accounts[i].name, - bsStyle: this.state.accounts[i].name==this.state.activeAccount ? 'primary' : 'default', - onClick: this.switchAccount.bind(this,this.state.accounts[i].name), - href: "javascript:void(0);" - }, this.state.accounts[i].name) + var guestMode = true; + + if(this.state.accounts.filter(function(acc){ + return acc.status=="confirmed"; + }).length){ + guestMode = false; + } + + if(guestMode){ + var accountSelector = ( + React.createElement(Button, {href: "#/accounts", disabled: true}, "guest") + ); + }else{ + var userbuttons = []; + for (var i in this.state.accounts.filter(function(acc){ + return acc.status=="confirmed"; + })) { + userbuttons.push( + React.createElement(MenuItem, { + key: this.state.accounts[i].name, + bsStyle: this.state.accounts[i].name==this.state.activeAccount ? 'primary' : 'default', + onClick: this.switchAccount.bind(this,this.state.accounts[i].name), + href: "javascript:void(0);" + }, this.state.accounts[i].name) + ); + } + var accountSelector = ( + + React.createElement(DropdownButton, {title: this.state.activeAccount}, + userbuttons + ) + ); } + return ( React.createElement(Grid, null, @@ -182,20 +210,19 @@ App = React.createClass({displayName: "App", React.createElement(ButtonGroup, {justified: true}, React.createElement(Button, { href: "#", - bsStyle: firstroute=="home" ? 'primary' : 'default' + bsStyle: firstroute=="home" ? 'primary' : 'default', + disabled: guestMode }, React.createElement(Glyphicon, {glyph: "home"})), React.createElement(Button, { href: "#/profile", - bsStyle: firstroute=="profile-active" ? 'primary' : 'default' + bsStyle: firstroute=="profile-active" ? 'primary' : 'default', + disabled: guestMode }, React.createElement(Glyphicon, {glyph: "user"})), - React.createElement(Button, {href: "#/directmessages"}, React.createElement(Glyphicon, {glyph: "transfer"})), - React.createElement(DropdownButton, {title: this.state.activeAccount}, - userbuttons - ), + React.createElement(Button, {href: "#/directmessages", disabled: true}, React.createElement(Glyphicon, {glyph: "transfer"})), + accountSelector, React.createElement(DropdownButton, {title: React.createElement(Glyphicon, {glyph: "menu-hamburger"})}, React.createElement(MenuItem, { - onClick: this.clearCache, - href: "javascript:void(0);" + onClick: this.clearCache }, "Clear Cache"), React.createElement(MenuItem, {href: "#/search"}, "Search"), React.createElement(MenuItem, {href: "#/settings"}, "Settings"), @@ -1034,7 +1061,7 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup; var Post = require("../common/Post.js"); -module.exports = Postboard = React.createClass({displayName: "Postboard", +module.exports = ProfileBoard = React.createClass({displayName: "ProfileBoard", render: function() { var thisComponent = this; @@ -1748,19 +1775,24 @@ module.exports = Accounts = React.createClass({displayName: "Accounts", router: React.PropTypes.func }, render: function() { + + var thisComponent = this; + return ( React.createElement(ListGroup, null, - React.createElement(ListGroupItem, null, "Settings"), + React.createElement(ListGroupItem, null, "Accounts"), React.createElement(ListGroupItem, null, - React.createElement("ul", null, - this.props.accounts.map(function(acc,index) { - //console.log(acc,index) - return ( - React.createElement("li", null, acc.name, " - ", acc.status) - ); - }) - ), - React.createElement(ImportAccountModalButton, null) + React.createElement(ImportAccountModalButton, null), + React.createElement("hr", null), + this.props.accounts.map(function(acc,index) { + //console.log(acc,index) + return ( + React.createElement("div", null, + React.createElement(MiniProfile, {username: acc.name, key: "miniprofile:"+acc.name, pollIntervalProfile: thisComponent.props.pollIntervalProfile}), + React.createElement("p", null, acc.status) + ) + ); + }) ) ) ); @@ -1816,11 +1848,21 @@ module.exports = Conversation = React.createClass({displayName: "Conversation", var goUpConversation = function (post) { - + if(!post) return; if (post.isReply()) { - post.doPostRepliedTo(goUpConversation); + post.doPostRepliedTo(function(otherpost){ + if(otherpost){ + goUpConversation(otherpost); + }else{ + thisComponent.addPost(post); + + thisComponent.setStateSafe({loading: false}); + + post.doReplies(doRepliesRecursive); + } + }); } else { diff --git a/build/twister-lib.js b/build/twister-lib.js index 4303e70..27a537e 100755 --- a/build/twister-lib.js +++ b/build/twister-lib.js @@ -29660,7 +29660,7 @@ TwisterAccount.prototype.verifyKey = function (cbfunc,querySettings) { TwisterAccount.prototype.getKeyStatus = function () { - this._privkey.getStatus(); + return this._privkey.getStatus(); } diff --git a/css/main.css b/css/main.css index 1ba36b8..799319d 100755 --- a/css/main.css +++ b/css/main.css @@ -7,6 +7,10 @@ body.modal-open { margin: 0; } +.btn-group-justified>.btn-group .dropdown-menu { + right: 0; +} + .container { padding: 0; } diff --git a/jsx/App.js b/jsx/App.js index 4d7122d..295270c 100755 --- a/jsx/App.js +++ b/jsx/App.js @@ -106,12 +106,14 @@ App = React.createClass({ checkAccounts: function() { - this.state.accounts.map(function(acc){ + var thisComponent = this; + + thisComponent.state.accounts.map(function(acc){ - Twister.getAccount(newaccoutname).verifyKey(function(key){ + Twister.getAccount(acc.name).verifyKey(function(key){ thisComponent.setState(function(oldstate,props){ - oldstate.accounts[acc].status = key.getStatus(); + oldstate.accounts[acc.name].status = key.getStatus(); return oldstate; @@ -138,9 +140,11 @@ App = React.createClass({ onnewaccountbyuser: function(event) { + console.log("catched onnewaccountbyuser event !!!!! ",event,this.state) + this.saveCache(); - if(!this.activeAccount){ + if(!this.state.activeAccount){ this.switchAccount(event.detail.getUsername()); @@ -162,17 +166,41 @@ App = React.createClass({ //console.log(firstroute); - var userbuttons = []; - for (var i in this.state.accounts) { - userbuttons.push( - {this.state.accounts[i].name} + var guestMode = true; + + if(this.state.accounts.filter(function(acc){ + return acc.status=="confirmed"; + }).length){ + guestMode = false; + } + + if(guestMode){ + var accountSelector = ( + + ); + }else{ + var userbuttons = []; + for (var i in this.state.accounts.filter(function(acc){ + return acc.status=="confirmed"; + })) { + userbuttons.push( + {this.state.accounts[i].name} + ); + } + var accountSelector = ( + + + {userbuttons} + + ); } + return ( @@ -182,19 +210,18 @@ App = React.createClass({ - - - {userbuttons} - + + {accountSelector} }> Clear Cache Search Settings diff --git a/jsx/common/ProfileBoard.js b/jsx/common/ProfileBoard.js index 69446f1..95c88cd 100755 --- a/jsx/common/ProfileBoard.js +++ b/jsx/common/ProfileBoard.js @@ -14,7 +14,7 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup; var Post = require("../common/Post.js"); -module.exports = Postboard = React.createClass({ +module.exports = ProfileBoard = React.createClass({ render: function() { var thisComponent = this; diff --git a/jsx/other/Accounts.js b/jsx/other/Accounts.js index 927ff95..c335d34 100644 --- a/jsx/other/Accounts.js +++ b/jsx/other/Accounts.js @@ -27,19 +27,24 @@ module.exports = Accounts = React.createClass({ router: React.PropTypes.func }, render: function() { + + var thisComponent = this; + return ( - Settings + Accounts -
    - {this.props.accounts.map(function(acc,index) { - //console.log(acc,index) - return ( -
  • {acc.name} - {acc.status}
  • - ); - })} -
+
+ {this.props.accounts.map(function(acc,index) { + //console.log(acc,index) + return ( +
+ +

{acc.status}

+
+ ); + })}
); diff --git a/jsx/other/Conversation.js b/jsx/other/Conversation.js index 15f2ffb..42c6661 100755 --- a/jsx/other/Conversation.js +++ b/jsx/other/Conversation.js @@ -47,11 +47,21 @@ module.exports = Conversation = React.createClass({ var goUpConversation = function (post) { - + if(!post) return; if (post.isReply()) { - post.doPostRepliedTo(goUpConversation); + post.doPostRepliedTo(function(otherpost){ + if(otherpost){ + goUpConversation(otherpost); + }else{ + thisComponent.addPost(post); + + thisComponent.setStateSafe({loading: false}); + + post.doReplies(doRepliesRecursive); + } + }); } else {