mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-01-27 07:04:20 +00:00
edit profile and avatar
This commit is contained in:
parent
ce025b1b47
commit
4aecef468f
@ -247,6 +247,7 @@ if (accounts.length==0) {
|
||||
host: appSettings.host,
|
||||
logfunc: function(log){console.log(log)},
|
||||
outdatedLimit: appSettings.pollInterval,
|
||||
signatureVerification: "none",
|
||||
walletType: "client",
|
||||
querySettingsByType: {
|
||||
|
||||
@ -263,31 +264,6 @@ if (accounts.length==0) {
|
||||
|
||||
initializeApp();
|
||||
|
||||
/*Twister.importClientSideAccount("pampalulu","L12kz6tabDN6VmPes1rfEpiznztPF6vgkHp8UZVBgZadxzebHhAp",function(){
|
||||
|
||||
var activeAccount = localStorage.getItem("twister-react-activeAccount");
|
||||
|
||||
var accounts = Twister.getAccounts();
|
||||
|
||||
if (!activeAccount) {
|
||||
|
||||
activeAccount = accounts[0];
|
||||
localStorage.setItem("twister-react-activeAccount",activeAccount);
|
||||
|
||||
}
|
||||
|
||||
console.log("active account defaulted to "+activeAccount)
|
||||
|
||||
console.log(Twister.getAccount(activeAccount))
|
||||
|
||||
Twister.getAccount(activeAccount).activateTorrents(function(){
|
||||
|
||||
initializeApp();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
} else {
|
||||
|
||||
var activeAccount = localStorage.getItem("twister-react-activeAccount");
|
||||
@ -566,7 +542,9 @@ module.exports = Post = React.createClass({displayName: "Post",
|
||||
avatar: "img/genericPerson.png",
|
||||
fullname: "",
|
||||
timeAgo: "",
|
||||
retwistingUser: this.props.post.username
|
||||
retwistingUsername: this.props.post.username,
|
||||
retwistingUserFullname: "",
|
||||
retwistingUserAvatar: "img/genericPerson.png",
|
||||
};
|
||||
},
|
||||
updateTimeAgo: function() {
|
||||
@ -599,6 +577,12 @@ module.exports = Post = React.createClass({displayName: "Post",
|
||||
});
|
||||
});
|
||||
|
||||
post.getUser().doAvatar(function(avatar){
|
||||
thisComponent.setStateSafe({
|
||||
retwistingUserAvatar: avatar.getUrl()
|
||||
});
|
||||
});
|
||||
|
||||
post=post.getRetwistedPost();
|
||||
|
||||
}
|
||||
@ -623,11 +607,16 @@ module.exports = Post = React.createClass({displayName: "Post",
|
||||
|
||||
var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id);
|
||||
var retwist = false;
|
||||
var retwistWithComment = false;
|
||||
var comment = "";
|
||||
|
||||
if (post.isRetwist()) {
|
||||
retwist = true;
|
||||
if(post.isRetwistWithComment()){
|
||||
retwistWithComment=true;
|
||||
comment = post.getContent();
|
||||
}
|
||||
post=post.getRetwistedPost();
|
||||
|
||||
}
|
||||
|
||||
if (post.isReply()) {
|
||||
@ -667,24 +656,32 @@ module.exports = Post = React.createClass({displayName: "Post",
|
||||
|
||||
return (
|
||||
React.createElement(ListGroupItem, null,
|
||||
React.createElement(Row, {className: "nomargin"},
|
||||
React.createElement(Col, {xs: 2, md: 2, className: "fullytight"},
|
||||
React.createElement(Row, {className: "nomargin post-main"},
|
||||
React.createElement(Col, {xs: 1, md: 1, className: "fullytight"},
|
||||
React.createElement("a", {href: "#/profile/"+post.getUsername()},
|
||||
React.createElement("img", {className: "img-responsive", src: this.state.avatar})
|
||||
)
|
||||
),
|
||||
React.createElement(Col, {xs: 9, md: 9},
|
||||
React.createElement("strong", null, this.state.fullname),
|
||||
React.createElement(Col, {xs: 11, md: 11},
|
||||
React.createElement(Row, null,
|
||||
React.createElement(Col, {xs: 11, md: 11},
|
||||
React.createElement("strong", null, this.state.fullname)
|
||||
),
|
||||
React.createElement(Col, {xs: 1, md: 1, className: "fullytight"},
|
||||
React.createElement("small", null, this.state.timeAgo)
|
||||
)
|
||||
),
|
||||
React.createElement(PostContent, {content: post.getContent()})
|
||||
),
|
||||
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"}, this.state.timeAgo)
|
||||
)
|
||||
),
|
||||
React.createElement(Row, {className: "nomargin"},
|
||||
React.createElement(Col, {xs: 6, md: 6, className: "fullytight"},
|
||||
retwist && React.createElement("small", null, React.createElement("em", null, "retwisted by ", this.state.retwistingUserFullname))
|
||||
|
||||
React.createElement(Col, {xs: 8, md: 8, className: "fullytight"},
|
||||
retwist && React.createElement("small", null, React.createElement("em", null,
|
||||
"retwisted by ", React.createElement("img", {className: "micro-avatar", src: this.state.retwistingUserAvatar}), this.state.retwistingUserFullname, retwistWithComment && ":"
|
||||
))
|
||||
|
||||
),
|
||||
React.createElement(Col, {xs: 4, md: 4, className: "fullytight text-align-right"},
|
||||
React.createElement(Col, {xs: 2, md: 2, className: "fullytight text-align-right"},
|
||||
conversationLink
|
||||
),
|
||||
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"},
|
||||
@ -693,8 +690,13 @@ module.exports = Post = React.createClass({displayName: "Post",
|
||||
React.createElement(Col, {xs: 1, md: 1, className: "fullytight text-align-right"},
|
||||
retwistLink
|
||||
)
|
||||
),
|
||||
retwistWithComment && React.createElement(Row, null,
|
||||
React.createElement(Col, {xs: 12, md: 12},
|
||||
React.createElement("small", null, React.createElement(PostContent, {content: comment}))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -30001,8 +30001,8 @@ TwisterAccount.prototype.reply = function (replyusername,replyid,msg,cbfunc) {
|
||||
this._signAndPublish(post,function(newpost){
|
||||
|
||||
var v = {
|
||||
rt: newpost._data,
|
||||
sig_rt: newpost._signature
|
||||
sig_userpost: newpost._signature,
|
||||
userpost: newpost._data
|
||||
}
|
||||
|
||||
thisAccount._dhtput(
|
||||
@ -30193,27 +30193,31 @@ TwisterAccount.prototype._dhtput = function(username,resource,sorm,value,seq,cbf
|
||||
thisAccount.RPC("getinfo",[],function(info){
|
||||
|
||||
var p = {
|
||||
height: info.blocks-1,
|
||||
v:value,
|
||||
seq: seq,
|
||||
target:{
|
||||
"n" : username,
|
||||
"r" : resource,
|
||||
"t" : sorm
|
||||
},
|
||||
time: Math.round(Date.now()/1000),
|
||||
v: value
|
||||
};
|
||||
height: info.blocks-1,
|
||||
target:{
|
||||
"n" : username,
|
||||
"r" : resource,
|
||||
"t" : sorm
|
||||
},
|
||||
time: Math.round(Date.now()/1000),
|
||||
v: value
|
||||
};
|
||||
|
||||
console.log("dhtputraw",p)
|
||||
if(sorm=="s"){
|
||||
p.seq=seq;
|
||||
}
|
||||
|
||||
thisAccount._privkey.sign(p,function(sig){
|
||||
console.log("dhtputraw",username,resource,sorm,p)
|
||||
|
||||
thisAccount._privkey.sign(p,function(sig,pWithBuffers){
|
||||
|
||||
var dhtentry = {
|
||||
p: p,
|
||||
p: pWithBuffers,
|
||||
sig_user:thisAccount._name,
|
||||
sig_p: sig
|
||||
}
|
||||
|
||||
//console.log("p",dhtentry)
|
||||
|
||||
var message = bencode.encode(dhtentry);
|
||||
|
||||
@ -30275,10 +30279,14 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){
|
||||
}
|
||||
);
|
||||
|
||||
console.log(v)
|
||||
|
||||
if(v.userpost && v.userpost.msg){
|
||||
|
||||
var parsedContent = TwisterContentParser.parseContent(v.userpost.msg);
|
||||
|
||||
|
||||
console.log("parsed content",parsedContent)
|
||||
|
||||
parsedContent.map(function(item){
|
||||
|
||||
if(item.type=="hashtag"){
|
||||
@ -30863,6 +30871,20 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
|
||||
|
||||
var message = JSON.parse(JSON.stringify(message_ori));
|
||||
|
||||
if ("p" in message && (typeof message.p)=="object"){
|
||||
if ("v" in message.p && (typeof message.p.v)=="object"){
|
||||
if("sig_userpost" in message.p.v && !Buffer.isBuffer(message.p.v.sig_userpost)) {
|
||||
message.p.v.sig_userpost = new Buffer(message.p.v.sig_userpost, 'hex');
|
||||
}
|
||||
if ("userpost" in message.p.v) {
|
||||
if ("sig_rt" in message.p.v.userpost && !Buffer.isBuffer(message.p.v.userpost.sig_rt)) {
|
||||
message.p.v.userpost.sig_rt = new Buffer(message.p.v.userpost.sig_rt, 'hex');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ("v" in message && (typeof message.v)=="object"){
|
||||
if("sig_userpost" in message.v && !Buffer.isBuffer(message.v.sig_userpost)) {
|
||||
message.v.sig_userpost = new Buffer(message.v.sig_userpost, 'hex');
|
||||
@ -30876,6 +30898,9 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
|
||||
|
||||
if ("sig_rt" in message && !Buffer.isBuffer(message.sig_rt)) {
|
||||
message.sig_rt = new Buffer(message.sig_rt, 'hex');
|
||||
}
|
||||
if("sig_userpost" in message && !Buffer.isBuffer(message.sig_userpost)) {
|
||||
message.sig_userpost = new Buffer(message.sig_userpost, 'hex');
|
||||
}
|
||||
|
||||
var Twister = this._scope;
|
||||
@ -30886,11 +30911,13 @@ TwisterPrivKey.prototype.sign = function (message_ori, cbfunc) {
|
||||
|
||||
var startTime = Date.now();
|
||||
|
||||
message = bencode.encode(message);
|
||||
//console.log("signing",message);
|
||||
|
||||
bmessage = bencode.encode(message);
|
||||
|
||||
try {
|
||||
var retVal = Bitcoin.message.sign(keyPair,message ,twister_network);
|
||||
cbfunc(retVal)
|
||||
var retVal = Bitcoin.message.sign(keyPair,bmessage ,twister_network);
|
||||
cbfunc(retVal,message)
|
||||
} catch(e) {
|
||||
//console.log(e)
|
||||
thisResource._handleError({
|
||||
@ -33363,6 +33390,14 @@ TwisterPost.prototype.isRetwist = function () {
|
||||
return ("rt" in this._data);
|
||||
}
|
||||
|
||||
/** @function
|
||||
* @name isRetwist
|
||||
* @description returns true if the postis an rewtist.
|
||||
*/
|
||||
TwisterPost.prototype.isRetwistWithComment = function () {
|
||||
return ("rt" in this._data && "msg" in this._data);
|
||||
}
|
||||
|
||||
|
||||
/** @function
|
||||
* @name getRetwistedId
|
||||
@ -33903,6 +33938,10 @@ TwisterPubKey.prototype.getKey = function () {
|
||||
|
||||
TwisterPubKey.prototype.verifySignature = function (message_ori, signature_ori, cbfunc) {
|
||||
|
||||
var verifySignatures = (this.getQuerySetting("signatureVerification")!="none");
|
||||
|
||||
if(verifySignatures){
|
||||
|
||||
var thisResource = this;
|
||||
|
||||
var signature = JSON.parse(JSON.stringify(signature_ori));
|
||||
@ -33967,7 +34006,9 @@ TwisterPubKey.prototype.verifySignature = function (message_ori, signature_ori,
|
||||
|
||||
},timeout);
|
||||
|
||||
|
||||
}else{
|
||||
cbfunc(true);
|
||||
}
|
||||
|
||||
}
|
||||
}).call(this,require("buffer").Buffer)
|
||||
|
16
css/main.css
16
css/main.css
@ -7,6 +7,10 @@ body.modal-open {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.modal {
|
||||
overflow: auto;
|
||||
}
|
||||
@ -45,6 +49,7 @@ body.modal-open {
|
||||
|
||||
.img-responsive {
|
||||
width: 100%;
|
||||
border-radius: 0.25em;
|
||||
}
|
||||
|
||||
.item-enter {
|
||||
@ -65,6 +70,10 @@ body.modal-open {
|
||||
opacity: 0.01;
|
||||
}
|
||||
|
||||
.post-main{
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.mention {
|
||||
color: red;
|
||||
}
|
||||
@ -81,3 +90,10 @@ body.modal-open {
|
||||
color: coral;
|
||||
}
|
||||
|
||||
.micro-avatar {
|
||||
height: 1em;
|
||||
border-radius: 0.25em;
|
||||
vertical-align: text-top;
|
||||
margin-left: 0.25em;
|
||||
margin-right: 0.125em;
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/paper-theme.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/main.css">
|
||||
<meta name="viewport" content="width=548" />
|
||||
<meta name="viewport" content="width=360, user-scalable=no" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
26
jsx/App.js
26
jsx/App.js
@ -246,6 +246,7 @@ if (accounts.length==0) {
|
||||
host: appSettings.host,
|
||||
logfunc: function(log){console.log(log)},
|
||||
outdatedLimit: appSettings.pollInterval,
|
||||
signatureVerification: "none",
|
||||
walletType: "client",
|
||||
querySettingsByType: {
|
||||
|
||||
@ -262,31 +263,6 @@ if (accounts.length==0) {
|
||||
|
||||
initializeApp();
|
||||
|
||||
/*Twister.importClientSideAccount("pampalulu","L12kz6tabDN6VmPes1rfEpiznztPF6vgkHp8UZVBgZadxzebHhAp",function(){
|
||||
|
||||
var activeAccount = localStorage.getItem("twister-react-activeAccount");
|
||||
|
||||
var accounts = Twister.getAccounts();
|
||||
|
||||
if (!activeAccount) {
|
||||
|
||||
activeAccount = accounts[0];
|
||||
localStorage.setItem("twister-react-activeAccount",activeAccount);
|
||||
|
||||
}
|
||||
|
||||
console.log("active account defaulted to "+activeAccount)
|
||||
|
||||
console.log(Twister.getAccount(activeAccount))
|
||||
|
||||
Twister.getAccount(activeAccount).activateTorrents(function(){
|
||||
|
||||
initializeApp();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
*/
|
||||
} else {
|
||||
|
||||
var activeAccount = localStorage.getItem("twister-react-activeAccount");
|
||||
|
@ -57,7 +57,9 @@ module.exports = Post = React.createClass({
|
||||
avatar: "img/genericPerson.png",
|
||||
fullname: "",
|
||||
timeAgo: "",
|
||||
retwistingUser: this.props.post.username
|
||||
retwistingUsername: this.props.post.username,
|
||||
retwistingUserFullname: "",
|
||||
retwistingUserAvatar: "img/genericPerson.png",
|
||||
};
|
||||
},
|
||||
updateTimeAgo: function() {
|
||||
@ -90,6 +92,12 @@ module.exports = Post = React.createClass({
|
||||
});
|
||||
});
|
||||
|
||||
post.getUser().doAvatar(function(avatar){
|
||||
thisComponent.setStateSafe({
|
||||
retwistingUserAvatar: avatar.getUrl()
|
||||
});
|
||||
});
|
||||
|
||||
post=post.getRetwistedPost();
|
||||
|
||||
}
|
||||
@ -114,11 +122,16 @@ module.exports = Post = React.createClass({
|
||||
|
||||
var post = Twister.getUser(this.props.post.username).getPost(this.props.post.id);
|
||||
var retwist = false;
|
||||
var retwistWithComment = false;
|
||||
var comment = "";
|
||||
|
||||
if (post.isRetwist()) {
|
||||
retwist = true;
|
||||
if(post.isRetwistWithComment()){
|
||||
retwistWithComment=true;
|
||||
comment = post.getContent();
|
||||
}
|
||||
post=post.getRetwistedPost();
|
||||
|
||||
}
|
||||
|
||||
if (post.isReply()) {
|
||||
@ -158,24 +171,32 @@ module.exports = Post = React.createClass({
|
||||
|
||||
return (
|
||||
<ListGroupItem>
|
||||
<Row className="nomargin">
|
||||
<Col xs={2} md={2} className="fullytight">
|
||||
<Row className="nomargin post-main">
|
||||
<Col xs={1} md={1} className="fullytight">
|
||||
<a href={"#/profile/"+post.getUsername()}>
|
||||
<img className="img-responsive" src={this.state.avatar}/>
|
||||
</a>
|
||||
</Col>
|
||||
<Col xs={9} md={9}>
|
||||
<strong>{this.state.fullname}</strong>
|
||||
<Col xs={11} md={11}>
|
||||
<Row>
|
||||
<Col xs={11} md={11}>
|
||||
<strong>{this.state.fullname}</strong>
|
||||
</Col>
|
||||
<Col xs={1} md={1} className="fullytight">
|
||||
<small>{this.state.timeAgo}</small>
|
||||
</Col>
|
||||
</Row>
|
||||
<PostContent content={post.getContent()}/>
|
||||
</Col>
|
||||
<Col xs={1} md={1} className="fullytight text-align-right">{this.state.timeAgo}</Col>
|
||||
</Row>
|
||||
<Row className="nomargin">
|
||||
<Col xs={6} md={6} className="fullytight">
|
||||
{retwist && <small><em>retwisted by {this.state.retwistingUserFullname}</em></small>
|
||||
}
|
||||
<Col xs={8} md={8} className="fullytight">
|
||||
{retwist && <small><em>
|
||||
retwisted by <img className="micro-avatar" src={this.state.retwistingUserAvatar} />{this.state.retwistingUserFullname}{retwistWithComment && ":"}
|
||||
</em></small>
|
||||
}
|
||||
</Col>
|
||||
<Col xs={4} md={4} className="fullytight text-align-right">
|
||||
<Col xs={2} md={2} className="fullytight text-align-right">
|
||||
{conversationLink}
|
||||
</Col>
|
||||
<Col xs={1} md={1} className="fullytight text-align-right">
|
||||
@ -185,7 +206,12 @@ module.exports = Post = React.createClass({
|
||||
{retwistLink}
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{retwistWithComment && <Row>
|
||||
<Col xs={12} md={12}>
|
||||
<small><PostContent content={comment}/></small>
|
||||
</Col>
|
||||
</Row>
|
||||
}
|
||||
</ListGroupItem>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user