Browse Source

follow button

master
Julian Steinwachs 9 years ago
parent
commit
b253c68411
  1. 669
      build/app-bundle.js
  2. 165
      build/twister-lib.js
  3. 4
      jsx/profile/Profile.js

669
build/app-bundle.js

File diff suppressed because it is too large Load Diff

165
build/twister-lib.js

@ -29667,9 +29667,7 @@ TwisterAccount.prototype.activateTorrents = function (cbfunc,querySettings) {
}) })
usernames.push(thisAccount._name); usernames.push(thisAccount._name);
console.log(usernames)
thisAccount.RPC("follow", [ "guest", usernames ], function(res) { thisAccount.RPC("follow", [ "guest", usernames ], function(res) {
for (var k in usernames) { for (var k in usernames) {
@ -29696,46 +29694,152 @@ TwisterAccount.prototype.activateTorrents = function (cbfunc,querySettings) {
} }
TwisterAccount.prototype.activateTorrent = function (username,cbfunc,querySettings) {
var Twister = this._scope;
var thisAccount = this;
thisAccount.RPC("follow", [ "guest", [username] ], function(res) {
var resTorrent = thisAccount.getTorrent(username);
resTorrent.activate();
thisAccount._log("torrent for "+username+" activated");
if(cbfunc) cbfunc();
}, function(ret) {
thisAccount._handleError(ret);
})
}
TwisterAccount.prototype.unfollow = function (username,cbfunc) { TwisterAccount.prototype.unfollow = function (username,cbfunc) {
/*var thisAccount = this; var thisAccount = this;
var Twister = this._scope; var Twister = this._scope;
thisAccount.RPC("unfollow",[ Twister.getUser(this._name).doFollowings(function(fols){
thisAccount._name, var newfollowings = fols.map(function(fol){
[username] return fol.getUsername();
}).filter(function(name){
return name!=username;
})
],function(result){ var oldRevisionNumers = Twister.getUser(thisAccount._name)._followings._revisionNumber;
Twister.getUser(thisAccount._name).doFollowings(cbfunc,{outdatedLimit: 0});
},function(error){ thisAccount.updateFollowing(newfollowings,oldRevisionNumers,cbfunc)
TwisterAccount._handleError(error);
});*/ },{outdatedLimit: 0})
} }
TwisterAccount.prototype.follow = function (username,cbfunc) { TwisterAccount.prototype.follow = function (username,cbfunc) {
/*var thisAccount = this; var thisAccount = this;
var Twister = this._scope; var Twister = this._scope;
thisAccount.RPC("follow",[ Twister.getUser(this._name).doFollowings(function(fols){
thisAccount._name, var newfollowings = fols.map(function(fol){
[username] return fol.getUsername();
});
if(newfollowings.indexOf(username)<0){
newfollowings.push(username);
}
],function(result){ //console.log(newfollowings);
Twister.getUser(thisAccount._name).doFollowings(cbfunc,{outdatedLimit: 0}); var oldRevisionNumers = Twister.getUser(thisAccount._name)._followings._revisionNumber;
},function(error){ console.log("oldrev:",oldRevisionNumers)
thisAccount._handleError(error);
});*/ thisAccount.updateFollowing(newfollowings,oldRevisionNumers,cbfunc)
},{outdatedLimit: 0})
}
TwisterAccount.prototype.updateFollowing = function (newfollowings,oldRevsionNumbers,cbfunc) {
var newfollowings = JSON.parse(JSON.stringify(newfollowings));
var newfollowings_ori = JSON.parse(JSON.stringify(newfollowings));
var oldRevsionNumbers = JSON.parse(JSON.stringify(oldRevsionNumbers));
var thisAccount = this;
var Twister = this._scope;
var currentCounter = 1;
var newRevNumbers = {};
var putTilEmpty = function (cbfunc) {
thisAccount.dhtget([thisAccount._name, "following"+currentCounter, "s"],
function (result) {
if ((result[0] && result[0].p.v[0])||newfollowings.length) {
var charcount = 0;
var folsforthisresource = [];
while(newfollowings.length && charcount<4000){
var nextfol = newfollowings.shift();
charcount += nextfol.length + 3;
folsforthisresource.push(nextfol);
}
var seq = oldRevsionNumbers[currentCounter] ? oldRevsionNumbers[currentCounter]+1 : 1 ;
thisAccount._dhtput(
thisAccount._name,
"following"+currentCounter,
"s",
folsforthisresource,
seq,
function(result){
newRevNumbers[currentCounter]=seq;
currentCounter++;
putTilEmpty(cbfunc)
},function(error){
thisAccount._handleError(error);
});
} else {
Twister.getUser(thisAccount._name)._followings._data = newfollowings_ori;
Twister.getUser(thisAccount._name)._followings._revisionNumber = newRevNumbers;
Twister.getUser(thisAccount._name)._followings._do(cbfunc);
}
}
);
};
putTilEmpty(cbfunc);
} }
TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) { TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
@ -29759,7 +29863,7 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
var newprofile = new TwisterProfile(thisAccount._name,Twister); var newprofile = new TwisterProfile(thisAccount._name,Twister);
newprofile._data = newdata; newprofile._data = newdata;
cbfunc(newprofile); if(cbfunc) cbfunc(newprofile);
},function(error){ },function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
@ -29810,7 +29914,7 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) {
var newprofile = new TwisterProfile(thisAccount._name,Twister); var newprofile = new TwisterProfile(thisAccount._name,Twister);
newprofile._data = olddata; newprofile._data = olddata;
cbfunc(newprofile); if(cbfunc) cbfunc(newprofile);
},function(error){ },function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
@ -29852,7 +29956,7 @@ TwisterAccount.prototype.updateAvatar = function (newdata,cbfunc) {
var newprofile = new TwisterAvatar(thisAccount._name,Twister); var newprofile = new TwisterAvatar(thisAccount._name,Twister);
newprofile._data = newdata; newprofile._data = newdata;
cbfunc(newprofile); if(cbfunc) cbfunc(newprofile);
},function(error){ },function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
@ -29909,7 +30013,7 @@ TwisterAccount.prototype.reply = function (replyusername,replyid,msg,cbfunc) {
0, 0,
function(result){ function(result){
Twister.getUser(replyusername)._stream._posts[replyid]._replies._data[newpost.getUsername()+":post"+newpost.getId()]=true; Twister.getUser(replyusername)._stream._posts[replyid]._replies._data[newpost.getUsername()+":post"+newpost.getId()]=true;
cbfunc(newpost); if(cbfunc) cbfunc(newpost);
}, },
function(error){ function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
@ -29949,7 +30053,7 @@ TwisterAccount.prototype.retwist = function (rtusername,rtid,cbfunc) {
0, 0,
function(result){ function(result){
Twister.getUser(rtusername)._stream._posts[rtid]._retwists._data[newpost.getUsername()+":post"+newpost.getId()]=true; Twister.getUser(rtusername)._stream._posts[rtid]._retwists._data[newpost.getUsername()+":post"+newpost.getId()]=true;
cbfunc(newpost); if(cbfunc) cbfunc(newpost);
}, },
function(error){ function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
@ -30114,7 +30218,7 @@ TwisterAccount.prototype._dhtput = function(username,resource,sorm,value,seq,cbf
var message = bencode.encode(dhtentry); var message = bencode.encode(dhtentry);
thisAccount.RPC("dhtputraw",[message.toString("hex")],function(){ thisAccount.RPC("dhtputraw",[message.toString("hex")],function(){
cbfunc(); if(cbfunc) cbfunc();
},function(error){ },function(error){
thisAccount._handleError(error); thisAccount._handleError(error);
}); });
@ -30136,7 +30240,7 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){
var querId = v.sig_userpost.toString("hex"); var querId = v.sig_userpost.toString("hex");
Twister.onQueryComplete(querId,function(){ Twister.onQueryComplete(querId,function(){
cbfunc(v); if(cbfunc) cbfunc(v);
}); });
Twister.raiseQueryId(querId); Twister.raiseQueryId(querId);
@ -32689,6 +32793,7 @@ var TwisterFollowings = function (name,scope) {
TwisterResource.call(this,name,scope); TwisterResource.call(this,name,scope);
this._type = "followings"; this._type = "followings";
this._revisionNumber = {};
} }
@ -32760,6 +32865,8 @@ TwisterFollowings.prototype._queryAndDo = function (cbfunc) {
} }
thisResource._revisionNumber[currentCounter]=result[0].p.seq;
currentCounter++; currentCounter++;
requestTilEmpty(cbfunc) requestTilEmpty(cbfunc)

4
jsx/profile/Profile.js

@ -19,6 +19,8 @@ var SetIntervalMixin = require("../common/SetIntervalMixin.js");
var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js'); var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var ProfileMixin = require('../common/ProfileMixin.js'); var ProfileMixin = require('../common/ProfileMixin.js');
var FollowButton = require('../common/FollowButton.js');
module.exports = Post = React.createClass({ module.exports = Post = React.createClass({
mixins: [SetIntervalMixin,SafeStateChangeMixin,ProfileMixin], mixins: [SetIntervalMixin,SafeStateChangeMixin,ProfileMixin],
contextTypes: { contextTypes: {
@ -51,6 +53,8 @@ module.exports = Post = React.createClass({
<Row className="nomargin"> <Row className="nomargin">
<Col xs={3} md={3} className="fullytight"> <Col xs={3} md={3} className="fullytight">
<img className="img-responsive" src={this.state.avatar}/> <img className="img-responsive" src={this.state.avatar}/>
<br/>
<FollowButton activeAccount={this.props.activeAccount} username={this.state.username}/>
</Col> </Col>
<Col xs={8} md={8}> <Col xs={8} md={8}>
<h4 className="nomargin-top">{this.state.fullname}<small> &nbsp; {'@'+this.state.username}</small></h4> <h4 className="nomargin-top">{this.state.fullname}<small> &nbsp; {'@'+this.state.username}</small></h4>

Loading…
Cancel
Save