mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-01-11 15:38:00 +00:00
accounts page wip
This commit is contained in:
parent
63096c0ddf
commit
cf20ea26c0
@ -107,12 +107,14 @@ App = React.createClass({displayName: "App",
|
|||||||
|
|
||||||
checkAccounts: function() {
|
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){
|
thisComponent.setState(function(oldstate,props){
|
||||||
|
|
||||||
oldstate.accounts[acc].status = key.getStatus();
|
oldstate.accounts[acc.name].status = key.getStatus();
|
||||||
|
|
||||||
return oldstate;
|
return oldstate;
|
||||||
|
|
||||||
@ -139,9 +141,11 @@ App = React.createClass({displayName: "App",
|
|||||||
|
|
||||||
onnewaccountbyuser: function(event) {
|
onnewaccountbyuser: function(event) {
|
||||||
|
|
||||||
|
console.log("catched onnewaccountbyuser event !!!!! ",event,this.state)
|
||||||
|
|
||||||
this.saveCache();
|
this.saveCache();
|
||||||
|
|
||||||
if(!this.activeAccount){
|
if(!this.state.activeAccount){
|
||||||
|
|
||||||
this.switchAccount(event.detail.getUsername());
|
this.switchAccount(event.detail.getUsername());
|
||||||
|
|
||||||
@ -163,17 +167,41 @@ App = React.createClass({displayName: "App",
|
|||||||
|
|
||||||
//console.log(firstroute);
|
//console.log(firstroute);
|
||||||
|
|
||||||
var userbuttons = [];
|
var guestMode = true;
|
||||||
for (var i in this.state.accounts) {
|
|
||||||
userbuttons.push(
|
if(this.state.accounts.filter(function(acc){
|
||||||
React.createElement(MenuItem, {
|
return acc.status=="confirmed";
|
||||||
key: this.state.accounts[i].name,
|
}).length){
|
||||||
bsStyle: this.state.accounts[i].name==this.state.activeAccount ? 'primary' : 'default',
|
guestMode = false;
|
||||||
onClick: this.switchAccount.bind(this,this.state.accounts[i].name),
|
}
|
||||||
href: "javascript:void(0);"
|
|
||||||
}, this.state.accounts[i].name)
|
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 (
|
return (
|
||||||
React.createElement(Grid, null,
|
React.createElement(Grid, null,
|
||||||
@ -182,20 +210,19 @@ App = React.createClass({displayName: "App",
|
|||||||
React.createElement(ButtonGroup, {justified: true},
|
React.createElement(ButtonGroup, {justified: true},
|
||||||
React.createElement(Button, {
|
React.createElement(Button, {
|
||||||
href: "#",
|
href: "#",
|
||||||
bsStyle: firstroute=="home" ? 'primary' : 'default'
|
bsStyle: firstroute=="home" ? 'primary' : 'default',
|
||||||
|
disabled: guestMode
|
||||||
}, React.createElement(Glyphicon, {glyph: "home"})),
|
}, React.createElement(Glyphicon, {glyph: "home"})),
|
||||||
React.createElement(Button, {
|
React.createElement(Button, {
|
||||||
href: "#/profile",
|
href: "#/profile",
|
||||||
bsStyle: firstroute=="profile-active" ? 'primary' : 'default'
|
bsStyle: firstroute=="profile-active" ? 'primary' : 'default',
|
||||||
|
disabled: guestMode
|
||||||
}, React.createElement(Glyphicon, {glyph: "user"})),
|
}, React.createElement(Glyphicon, {glyph: "user"})),
|
||||||
React.createElement(Button, {href: "#/directmessages"}, React.createElement(Glyphicon, {glyph: "transfer"})),
|
React.createElement(Button, {href: "#/directmessages", disabled: true}, React.createElement(Glyphicon, {glyph: "transfer"})),
|
||||||
React.createElement(DropdownButton, {title: this.state.activeAccount},
|
accountSelector,
|
||||||
userbuttons
|
|
||||||
),
|
|
||||||
React.createElement(DropdownButton, {title: React.createElement(Glyphicon, {glyph: "menu-hamburger"})},
|
React.createElement(DropdownButton, {title: React.createElement(Glyphicon, {glyph: "menu-hamburger"})},
|
||||||
React.createElement(MenuItem, {
|
React.createElement(MenuItem, {
|
||||||
onClick: this.clearCache,
|
onClick: this.clearCache
|
||||||
href: "javascript:void(0);"
|
|
||||||
}, "Clear Cache"),
|
}, "Clear Cache"),
|
||||||
React.createElement(MenuItem, {href: "#/search"}, "Search"),
|
React.createElement(MenuItem, {href: "#/search"}, "Search"),
|
||||||
React.createElement(MenuItem, {href: "#/settings"}, "Settings"),
|
React.createElement(MenuItem, {href: "#/settings"}, "Settings"),
|
||||||
@ -1034,7 +1061,7 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
|
|||||||
|
|
||||||
var Post = require("../common/Post.js");
|
var Post = require("../common/Post.js");
|
||||||
|
|
||||||
module.exports = Postboard = React.createClass({displayName: "Postboard",
|
module.exports = ProfileBoard = React.createClass({displayName: "ProfileBoard",
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
var thisComponent = this;
|
var thisComponent = this;
|
||||||
@ -1748,19 +1775,24 @@ module.exports = Accounts = React.createClass({displayName: "Accounts",
|
|||||||
router: React.PropTypes.func
|
router: React.PropTypes.func
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
|
var thisComponent = this;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
React.createElement(ListGroup, null,
|
React.createElement(ListGroup, null,
|
||||||
React.createElement(ListGroupItem, null, "Settings"),
|
React.createElement(ListGroupItem, null, "Accounts"),
|
||||||
React.createElement(ListGroupItem, null,
|
React.createElement(ListGroupItem, null,
|
||||||
React.createElement("ul", null,
|
React.createElement(ImportAccountModalButton, null),
|
||||||
this.props.accounts.map(function(acc,index) {
|
React.createElement("hr", null),
|
||||||
//console.log(acc,index)
|
this.props.accounts.map(function(acc,index) {
|
||||||
return (
|
//console.log(acc,index)
|
||||||
React.createElement("li", null, acc.name, " - ", acc.status)
|
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)
|
||||||
React.createElement(ImportAccountModalButton, null)
|
)
|
||||||
|
);
|
||||||
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -1816,11 +1848,21 @@ module.exports = Conversation = React.createClass({displayName: "Conversation",
|
|||||||
|
|
||||||
var goUpConversation = function (post) {
|
var goUpConversation = function (post) {
|
||||||
|
|
||||||
|
if(!post) return;
|
||||||
|
|
||||||
if (post.isReply()) {
|
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 {
|
} else {
|
||||||
|
|
||||||
|
@ -29660,7 +29660,7 @@ TwisterAccount.prototype.verifyKey = function (cbfunc,querySettings) {
|
|||||||
|
|
||||||
TwisterAccount.prototype.getKeyStatus = function () {
|
TwisterAccount.prototype.getKeyStatus = function () {
|
||||||
|
|
||||||
this._privkey.getStatus();
|
return this._privkey.getStatus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,10 @@ body.modal-open {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-group-justified>.btn-group .dropdown-menu {
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
63
jsx/App.js
63
jsx/App.js
@ -106,12 +106,14 @@ App = React.createClass({
|
|||||||
|
|
||||||
checkAccounts: function() {
|
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){
|
thisComponent.setState(function(oldstate,props){
|
||||||
|
|
||||||
oldstate.accounts[acc].status = key.getStatus();
|
oldstate.accounts[acc.name].status = key.getStatus();
|
||||||
|
|
||||||
return oldstate;
|
return oldstate;
|
||||||
|
|
||||||
@ -138,9 +140,11 @@ App = React.createClass({
|
|||||||
|
|
||||||
onnewaccountbyuser: function(event) {
|
onnewaccountbyuser: function(event) {
|
||||||
|
|
||||||
|
console.log("catched onnewaccountbyuser event !!!!! ",event,this.state)
|
||||||
|
|
||||||
this.saveCache();
|
this.saveCache();
|
||||||
|
|
||||||
if(!this.activeAccount){
|
if(!this.state.activeAccount){
|
||||||
|
|
||||||
this.switchAccount(event.detail.getUsername());
|
this.switchAccount(event.detail.getUsername());
|
||||||
|
|
||||||
@ -162,17 +166,41 @@ App = React.createClass({
|
|||||||
|
|
||||||
//console.log(firstroute);
|
//console.log(firstroute);
|
||||||
|
|
||||||
var userbuttons = [];
|
var guestMode = true;
|
||||||
for (var i in this.state.accounts) {
|
|
||||||
userbuttons.push(
|
if(this.state.accounts.filter(function(acc){
|
||||||
<MenuItem
|
return acc.status=="confirmed";
|
||||||
key={this.state.accounts[i].name}
|
}).length){
|
||||||
bsStyle={this.state.accounts[i].name==this.state.activeAccount ? 'primary' : 'default'}
|
guestMode = false;
|
||||||
onClick={this.switchAccount.bind(this,this.state.accounts[i].name)}
|
}
|
||||||
href="javascript:void(0);"
|
|
||||||
>{this.state.accounts[i].name}</MenuItem>
|
if(guestMode){
|
||||||
|
var accountSelector = (
|
||||||
|
<Button href='#/accounts' disabled>guest</Button>
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
var userbuttons = [];
|
||||||
|
for (var i in this.state.accounts.filter(function(acc){
|
||||||
|
return acc.status=="confirmed";
|
||||||
|
})) {
|
||||||
|
userbuttons.push(
|
||||||
|
<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}</MenuItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
var accountSelector = (
|
||||||
|
|
||||||
|
<DropdownButton title={this.state.activeAccount}>
|
||||||
|
{userbuttons}
|
||||||
|
</DropdownButton>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -182,19 +210,18 @@ App = React.createClass({
|
|||||||
<Button
|
<Button
|
||||||
href='#'
|
href='#'
|
||||||
bsStyle={firstroute=="home" ? 'primary' : 'default'}
|
bsStyle={firstroute=="home" ? 'primary' : 'default'}
|
||||||
|
disabled = {guestMode}
|
||||||
><Glyphicon glyph="home"/></Button>
|
><Glyphicon glyph="home"/></Button>
|
||||||
<Button
|
<Button
|
||||||
href='#/profile'
|
href='#/profile'
|
||||||
bsStyle={firstroute=="profile-active" ? 'primary' : 'default'}
|
bsStyle={firstroute=="profile-active" ? 'primary' : 'default'}
|
||||||
|
disabled = {guestMode}
|
||||||
><Glyphicon glyph="user"/></Button>
|
><Glyphicon glyph="user"/></Button>
|
||||||
<Button href='#/directmessages'><Glyphicon glyph="transfer"/></Button>
|
<Button href='#/directmessages' disabled><Glyphicon glyph="transfer"/></Button>
|
||||||
<DropdownButton title={this.state.activeAccount}>
|
{accountSelector}
|
||||||
{userbuttons}
|
|
||||||
</DropdownButton>
|
|
||||||
<DropdownButton title={<Glyphicon glyph="menu-hamburger"/>}>
|
<DropdownButton title={<Glyphicon glyph="menu-hamburger"/>}>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onClick={this.clearCache}
|
onClick={this.clearCache}
|
||||||
href="javascript:void(0);"
|
|
||||||
>Clear Cache</MenuItem>
|
>Clear Cache</MenuItem>
|
||||||
<MenuItem href="#/search" >Search</MenuItem>
|
<MenuItem href="#/search" >Search</MenuItem>
|
||||||
<MenuItem href="#/settings" >Settings</MenuItem>
|
<MenuItem href="#/settings" >Settings</MenuItem>
|
||||||
|
@ -14,7 +14,7 @@ var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
|
|||||||
|
|
||||||
var Post = require("../common/Post.js");
|
var Post = require("../common/Post.js");
|
||||||
|
|
||||||
module.exports = Postboard = React.createClass({
|
module.exports = ProfileBoard = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
var thisComponent = this;
|
var thisComponent = this;
|
||||||
|
@ -27,19 +27,24 @@ module.exports = Accounts = React.createClass({
|
|||||||
router: React.PropTypes.func
|
router: React.PropTypes.func
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
|
var thisComponent = this;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListGroup>
|
<ListGroup>
|
||||||
<ListGroupItem>Settings</ListGroupItem>
|
<ListGroupItem>Accounts</ListGroupItem>
|
||||||
<ListGroupItem>
|
<ListGroupItem>
|
||||||
<ul>
|
|
||||||
{this.props.accounts.map(function(acc,index) {
|
|
||||||
//console.log(acc,index)
|
|
||||||
return (
|
|
||||||
<li>{acc.name} - {acc.status}</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
<ImportAccountModalButton/>
|
<ImportAccountModalButton/>
|
||||||
|
<hr/>
|
||||||
|
{this.props.accounts.map(function(acc,index) {
|
||||||
|
//console.log(acc,index)
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<MiniProfile username={acc.name} key={"miniprofile:"+acc.name} pollIntervalProfile={thisComponent.props.pollIntervalProfile}/>
|
||||||
|
<p>{acc.status}</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
</ListGroup>
|
</ListGroup>
|
||||||
);
|
);
|
||||||
|
@ -47,11 +47,21 @@ module.exports = Conversation = React.createClass({
|
|||||||
|
|
||||||
var goUpConversation = function (post) {
|
var goUpConversation = function (post) {
|
||||||
|
|
||||||
|
if(!post) return;
|
||||||
|
|
||||||
if (post.isReply()) {
|
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 {
|
} else {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user