Browse Source

reply button

master
Julian Steinwachs 9 years ago
parent
commit
aa7e3bba10
  1. 699
      build/app-bundle.js
  2. 60
      build/twister-lib.js
  3. 21
      jsx/common/Post.js
  4. 5
      jsx/common/Postboard.js
  5. 84
      jsx/common/ReplyModalButton.js
  6. 2
      jsx/home/Home.js
  7. 6
      jsx/profile/Timeline.js

699
build/app-bundle.js

File diff suppressed because it is too large Load Diff

60
build/twister-lib.js

@ -29995,15 +29995,15 @@ TwisterAccount.prototype.post = function (msg,cbfunc) { @@ -29995,15 +29995,15 @@ TwisterAccount.prototype.post = function (msg,cbfunc) {
msg
],function(result){
var TwisterPost = require("../TwisterPost.js");
var data = {};
data.n = thisAccount._name;
data.k = newid;
data.time = Math.round(Date.now()/1000);
data.msg = msg;
var newpost = new TwisterPost(data,"",Twister);
cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(function(){},{outdatedLimit: 0});
// var TwisterPost = require("../TwisterPost.js");
// var data = {};
// data.n = thisAccount._name;
// data.k = newid;
// data.time = Math.round(Date.now()/1000);
// data.msg = msg;
// var newpost = new TwisterPost(data,"",Twister);
// cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(cbfunc,{outdatedLimit: 0});
},function(error){
thisAccount._handleError(error);
});
@ -30031,16 +30031,16 @@ TwisterAccount.prototype.reply = function (replyusername,replyid,msg,cbfunc) { @@ -30031,16 +30031,16 @@ TwisterAccount.prototype.reply = function (replyusername,replyid,msg,cbfunc) {
replyid
],function(result){
var TwisterPost = require("../TwisterPost.js");
var data = {};
data.n = thisAccount._name;
data.k = newid;
data.time = Math.round(Date.now()/1000);
data.msg = msg;
data.reply = { k: replyid, n: replyusername };
var newpost = new TwisterPost(data,"",Twister);
cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(function(){},{outdatedLimit: 0});
// var TwisterPost = require("../TwisterPost.js");
// var data = {};
// data.n = thisAccount._name;
// data.k = newid;
// data.time = Math.round(Date.now()/1000);
// data.msg = msg;
// data.reply = { k: replyid, n: replyusername };
// var newpost = new TwisterPost(data,"",Twister);
// cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(cbfunc,{outdatedLimit: 0});
},function(error){
thisAccount._handleError(error);
});
@ -30068,15 +30068,15 @@ TwisterAccount.prototype.retwist = function (rtusername,rtid,cbfunc) { @@ -30068,15 +30068,15 @@ TwisterAccount.prototype.retwist = function (rtusername,rtid,cbfunc) {
{ sig_userpost: post._signature, userpost: post._data }
],function(result){
var TwisterPost = require("../TwisterPost.js");
var data = {};
data.n = thisAccount._name;
data.k = newid;
data.time = Math.round(Date.now()/1000);
data.rt = post._data;
var newpost = new TwisterPost(data,"",Twister);
cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(function(){},{outdatedLimit: 0});
// var TwisterPost = require("../TwisterPost.js");
// var data = {};
// data.n = thisAccount._name;
// data.k = newid;
// data.time = Math.round(Date.now()/1000);
// data.rt = post._data;
// var newpost = new TwisterPost(data,"",Twister);
// cbfunc(newpost);
Twister.getUser(thisAccount._name).doStatus(cbfunc,{outdatedLimit: 0});
},function(error){
thisAccount._handleError(error);
@ -30128,7 +30128,7 @@ TwisterAccount.prototype.doLatestDirectMessagesUntil = function (username, cbfun @@ -30128,7 +30128,7 @@ TwisterAccount.prototype.doLatestDirectMessagesUntil = function (username, cbfun
this.getDirectMessages(username)._doUntil(cbfunc, querySettings);
}
},{"../TwisterAvatar.js":143,"../TwisterPost.js":147,"../TwisterProfile.js":148,"../TwisterResource.js":152,"./TwisterDirectMessages.js":140,"./TwisterTorrent.js":141,"inherits":52}],140:[function(require,module,exports){
},{"../TwisterAvatar.js":143,"../TwisterProfile.js":148,"../TwisterResource.js":152,"./TwisterDirectMessages.js":140,"./TwisterTorrent.js":141,"inherits":52}],140:[function(require,module,exports){
var inherits = require('inherits');
var TwisterResource = require('../TwisterResource.js');
@ -31463,8 +31463,6 @@ TwisterHashtag.prototype._queryAndDo = function (cbfunc, querySettings) { @@ -31463,8 +31463,6 @@ TwisterHashtag.prototype._queryAndDo = function (cbfunc, querySettings) {
thisHashtag.dhtget([thisHashtag._name, "hashtag", "m"],
function (result) {
console.log(result)
var TwisterPost = require("./TwisterPost.js");

21
jsx/common/Post.js

@ -13,6 +13,7 @@ var React = require('react'); @@ -13,6 +13,7 @@ var React = require('react');
var SetIntervalMixin = require("../common/SetIntervalMixin.js");
var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var PostContent = require('../common/PostContent.js');
var ReplyModalButton = require('../common/ReplyModalButton.js');
module.exports = Post = React.createClass({
mixins: [SetIntervalMixin,SafeStateChangeMixin],
@ -94,6 +95,19 @@ module.exports = Post = React.createClass({ @@ -94,6 +95,19 @@ module.exports = Post = React.createClass({
} else {
var conversationLink = (<span/>);
}
if (!post.isRetwist()) {
var replyLink = <OverlayTrigger placement='left' overlay={
<Tooltip>Reply</Tooltip>
}>
<small>
<ReplyModalButton replyUsername={post.getUsername()} replyPostId={post.getId()} activeAccount={this.props.activeAccount} originalMsg={post.getContent()} replyUserFullname={this.state.fullname}/>
</small>
</OverlayTrigger>
} else {
var replyLink = (<span/>);
}
return (
<ListGroupItem>
@ -114,7 +128,12 @@ module.exports = Post = React.createClass({ @@ -114,7 +128,12 @@ module.exports = Post = React.createClass({
{retwist && <small><em> &nbsp;retwisted by {this.state.retwistingUser}</em></small>
}
</Col>
<Col xs={6} md={6} className="fullytight text-align-right">{conversationLink}</Col>
<Col xs={5} md={5} className="fullytight text-align-right">
{replyLink}
</Col>
<Col xs={1} md={1} className="fullytight text-align-right">
{conversationLink}
</Col>
</Row>
</ListGroupItem>

5
jsx/common/Postboard.js

@ -16,9 +16,12 @@ var Post = require("../common/Post.js"); @@ -16,9 +16,12 @@ var Post = require("../common/Post.js");
module.exports = Postboard = React.createClass({
render: function() {
var activeAccount = this.props.activeAccount;
var posts = this.props.data.map(function(post, index) {
return (
<Post post={post} key={post.postid} />
<Post post={post} key={post.postid} activeAccount={activeAccount}/>
);
});

84
jsx/common/ReplyModalButton.js

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
var ReactBootstrap = require('react-bootstrap')
, OverlayMixin = ReactBootstrap.OverlayMixin
, Button = ReactBootstrap.Button
, ButtonGroup = ReactBootstrap.ButtonGroup
, Glyphicon = ReactBootstrap.Glyphicon
, Modal = ReactBootstrap.Modal
, Input = ReactBootstrap.Input
var React = require('react');
var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var SetIntervalMixin = require("../common/SetIntervalMixin.js");
var PostContent = require("../common/PostContent.js");
module.exports = ReplyModalButton = React.createClass({
mixins: [OverlayMixin],
getInitialState: function () {
return {
isModalOpen: false
};
},
handleToggle: function () {
this.setState({
isModalOpen: !this.state.isModalOpen
});
},
handleReply: function (e) {
e.preventDefault();
//console.log(e)
var msg = JSON.parse(JSON.stringify(e.target[0].value));
if (!msg) {
console.log("empty post was passed as new post")
return;
}
Twister.getAccount(this.props.activeAccount).reply(
this.props.replyUsername,
this.props.replyPostId,
msg,
function(post){
var event = new CustomEvent('newpostbyuser',{detail: post});
//alert("scrolled to bottom")
window.dispatchEvent(event);
});
e.target[0].value = "";
this.handleToggle();
//React.findDOMNode(this.refs.msg).value = '';
return;
},
render: function() {
return (
<a onClick={this.handleToggle} className="link-button-gray"><Glyphicon glyph='arrow-left' /></a>
);
},
renderOverlay: function() {
if (!this.state.isModalOpen) {
return <span/>;
}
return (
<Modal bsStyle='primary' title={
<Glyphicon glyph='arrow-left'/>
} onRequestHide={this.handleToggle}>
<div className='modal-body'>
<form onSubmit={this.handleReply}>
<strong>{this.props.replyUserFullname}</strong>&nbsp;
<PostContent content={this.props.originalMsg}/>
<Input type='textarea' label='' placeholder='textarea'/>
<Input type='submit' value='Reply' data-dismiss="modal" />
</form>
</div>
</Modal>
);
}
});

2
jsx/home/Home.js

@ -180,7 +180,7 @@ module.exports = Home = React.createClass({ @@ -180,7 +180,7 @@ module.exports = Home = React.createClass({
Home
<NewPostModalButton activeAccount={this.props.activeAccount}/>
</ListGroupItem>
} loading={this.state.loading}/>
} loading={this.state.loading} activeAccount={this.props.activeAccount}/>
);
}
});

6
jsx/profile/Timeline.js

@ -88,14 +88,14 @@ module.exports = Timeline = React.createClass({ @@ -88,14 +88,14 @@ module.exports = Timeline = React.createClass({
//alert("got event")
if(this.state.username==event.post.getUsername()) {
this.addPost(event.post);
if(this.state.username==event.detail.getUsername()) {
this.addPost(event.detail);
}
},
render: function() {
return (
<Postboard data={this.state.data} loading={this.state.loading}/>
<Postboard data={this.state.data} loading={this.state.loading} activeAccount={this.props.activeAccount}/>
);
}
});
Loading…
Cancel
Save