Browse Source

edit profile and avatar

master
Julian Steinwachs 8 years ago
parent
commit
be6eb038b0
  1. 950
      build/app-bundle.js
  2. 64
      build/twister-lib.js
  3. 1
      css/main.css
  4. 42
      jsx/common/Post.js
  5. 30
      jsx/common/ProfileMixin.js
  6. 21
      jsx/profile/Profile.js

950
build/app-bundle.js

File diff suppressed because it is too large Load Diff

64
build/twister-lib.js

@ -29859,15 +29859,14 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) { @@ -29859,15 +29859,14 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
profile._revisionNumber+1,
function(result){
var TwisterProfile = require("../TwisterProfile.js");
var newprofile = new TwisterProfile(thisAccount._name,Twister);
newprofile._data = newdata;
if(cbfunc) cbfunc(newprofile);
var newprofile = Twister.getUser(thisAccount._name)._profile;
newprofile._data = newdata;
if(cbfunc) cbfunc(newprofile);
},function(error){
thisAccount._handleError(error);
});
},function(error){
thisAccount._handleError(error);
}
);
},{errorfunc:function(error){
@ -29879,6 +29878,8 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) { @@ -29879,6 +29878,8 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
thisAccount.updateProfileFields(newdata,cbfunc);
}else{
thisAccount._handleError(error);
}
}})
@ -29903,22 +29904,21 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) { @@ -29903,22 +29904,21 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) {
}
thisAccount._dhtput(
thisAccount._name,
"profile",
"s",
olddata,
profile._revisionNumber+1,
function(result){
var TwisterProfile = require("../TwisterProfile.js");
var newprofile = new TwisterProfile(thisAccount._name,Twister);
thisAccount._name,
"profile",
"s",
olddata,
profile._revisionNumber+1,
function(result){
var newprofile = Twister.getUser(thisAccount._name)._profile;
newprofile._data = olddata;
if(cbfunc) cbfunc(newprofile);
},function(error){
thisAccount._handleError(error);
});
}
);
},{errorfunc:function(error){
@ -29930,6 +29930,8 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) { @@ -29930,6 +29930,8 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) {
thisAccount.updateProfileFields(newdata,cbfunc);
}else{
thisAccount._handleError(error);
}
}})
@ -29952,12 +29954,10 @@ TwisterAccount.prototype.updateAvatar = function (newdata,cbfunc) { @@ -29952,12 +29954,10 @@ TwisterAccount.prototype.updateAvatar = function (newdata,cbfunc) {
avatar._revisionNumber+1,
function(result){
var TwisterAvatar = require("../TwisterAvatar.js");
var newprofile = new TwisterAvatar(thisAccount._name,Twister);
newprofile._data = newdata;
if(cbfunc) cbfunc(newprofile);
var newavatar = Twister.getUser(thisAccount._name)._avatar;
newavatar._data = newdata;
if(cbfunc) cbfunc(newavatar);
},function(error){
thisAccount._handleError(error);
});
@ -30342,7 +30342,7 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){ @@ -30342,7 +30342,7 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){
}).call(this,require("buffer").Buffer)
},{"../TwisterAvatar.js":148,"../TwisterProfile.js":153,"../TwisterResource.js":157,"./TwisterContentParser.js":140,"./TwisterDirectMessages.js":141,"./TwisterPrivKey.js":142,"./TwisterTorrent.js":143,"bencode":1,"buffer":177,"inherits":52}],140:[function(require,module,exports){
},{"../TwisterResource.js":157,"./TwisterContentParser.js":140,"./TwisterDirectMessages.js":141,"./TwisterPrivKey.js":142,"./TwisterTorrent.js":143,"bencode":1,"buffer":177,"inherits":52}],140:[function(require,module,exports){
module.exports = {
extractUsername: function(s) {
var username = "";
@ -32779,6 +32779,16 @@ TwisterAvatar.prototype.getUrl = function () { @@ -32779,6 +32779,16 @@ TwisterAvatar.prototype.getUrl = function () {
return this._data;
}
/** @function
* @name getUsername
* @description return the username of the owner of the avatar
*/
TwisterAvatar.prototype.getUsername = function () {
return this._name;
}
},{"./TwisterAvatar.js":148,"./TwisterResource.js":157,"inherits":52}],149:[function(require,module,exports){
var inherits = require('inherits');

1
css/main.css

@ -13,6 +13,7 @@ body.modal-open { @@ -13,6 +13,7 @@ body.modal-open {
.link-button-gray {
color: #666;
cursor: pointer;
}
.tight {

42
jsx/common/Post.js

@ -15,12 +15,45 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js'); @@ -15,12 +15,45 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var PostContent = require('../common/PostContent.js');
var ReplyModalButton = require('../common/ReplyModalButton.js');
var RetwistModalButton = require('../common/RetwistModalButton.js');
var EventListenerMixin = require('../common/EventListenerMixin.js');
module.exports = Post = React.createClass({
mixins: [SetIntervalMixin,SafeStateChangeMixin],
mixins: [
SetIntervalMixin,
SafeStateChangeMixin,
EventListenerMixin('profileupdatebyuser'),
EventListenerMixin('avatarupdatebyuser')
],
onprofileupdatebyuser: function(event){
//console.log("catched event",this.state.username,event.detail)
var profile =event.detail;
if(profile.getUsername()==this.props.post.username){
this.setState(function(state){
state.fullname = profile.getField("fullname");
return state;
})
}
if(profile.getUsername()==this.state.retwistingUsername){
this.setState(function(state){
state.retwistingUserFullname = profile.getField("fullname");
return state;
})
}
},
onavatarupdatebyuser: function(event){
//console.log("catched event",this.state.username,event.detail)
var avatar =event.detail;
if(avatar.getUsername()==this.state.username){
this.setState(function(state){
state.avatar = avatar.getUrl();
return state;
})
}
},
getInitialState: function() {
return {
username: this.props.post.username,
avatar: "img/genericPerson.png",
fullname: "",
timeAgo: "",
@ -51,7 +84,10 @@ module.exports = Post = React.createClass({ @@ -51,7 +84,10 @@ module.exports = Post = React.createClass({
if (post.isRetwist()) {
post.getUser().doProfile(function(profile){
thisComponent.setStateSafe({retwistingUser: profile.getField("fullname")});
thisComponent.setStateSafe({
retwistingUsername: profile.getUsername(),
retwistingUserFullname: profile.getField("fullname")
});
});
post=post.getRetwistedPost();
@ -136,7 +172,7 @@ module.exports = Post = React.createClass({ @@ -136,7 +172,7 @@ module.exports = Post = React.createClass({
</Row>
<Row className="nomargin">
<Col xs={6} md={6} className="fullytight">
{retwist && <small><em> &nbsp;retwisted by {this.state.retwistingUser}</em></small>
{retwist && <small><em> &nbsp;retwisted by {this.state.retwistingUserFullname}</em></small>
}
</Col>
<Col xs={4} md={4} className="fullytight text-align-right">

30
jsx/common/ProfileMixin.js

@ -1,8 +1,36 @@ @@ -1,8 +1,36 @@
var AppSettingsMixin = require('../common/AppSettingsMixin.js');
var EventListenerMixin = require('../common/EventListenerMixin.js');
module.exports = ProfileMixin = {
mixins: [AppSettingsMixin],
mixins: [
AppSettingsMixin,
EventListenerMixin('profileupdatebyuser'),
EventListenerMixin('avatarupdatebyuser'),
],
onprofileupdatebyuser: function(event){
//console.log("catched event",this.state.username,event.detail)
var profile =event.detail;
if(profile.getUsername()==this.state.username){
this.setState(function(state){
state.fullname = profile.getField("fullname");
state.bio = profile.getField("bio");
state.location = profile.getField("location");
state.url = profile.getField("url");
return state;
})
}
},
onavatarupdatebyuser: function(event){
//console.log("catched event",this.state.username,event.detail)
var avatar =event.detail;
if(avatar.getUsername()==this.state.username){
this.setState(function(state){
state.avatar = avatar.getUrl();
return state;
})
}
},
getInitialState: function() {
var username = this.props.username;

21
jsx/profile/Profile.js

@ -20,9 +20,15 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js'); @@ -20,9 +20,15 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var ProfileMixin = require('../common/ProfileMixin.js');
var FollowButton = require('../common/FollowButton.js');
var EditProfileModalButton = require('../profile/EditProfileModalButton.js');
var EditAvatarModalButton = require('../profile/EditAvatarModalButton.js');
module.exports = Post = React.createClass({
mixins: [SetIntervalMixin,SafeStateChangeMixin,ProfileMixin],
mixins: [
SetIntervalMixin,
SafeStateChangeMixin,
ProfileMixin
],
contextTypes: {
router: React.PropTypes.func
},
@ -54,6 +60,11 @@ module.exports = Post = React.createClass({ @@ -54,6 +60,11 @@ module.exports = Post = React.createClass({
<Col xs={3} md={3} className="fullytight">
<img className="img-responsive" src={this.state.avatar}/>
<br/>
<EditAvatarModalButton
activeAccount={this.props.activeAccount}
username={this.state.username}
avatar={this.state.avatar}
/>
<FollowButton activeAccount={this.props.activeAccount} username={this.state.username}/>
</Col>
<Col xs={8} md={8}>
@ -61,6 +72,14 @@ module.exports = Post = React.createClass({ @@ -61,6 +72,14 @@ module.exports = Post = React.createClass({
<p className="text-center">{this.state.location}</p>
<p className="text-center">{this.state.bio}</p>
<p className="text-center"><a href={this.state.url}>{this.state.url}</a></p>
<EditProfileModalButton
activeAccount={this.props.activeAccount}
username={this.state.username}
fullname={this.state.fullname}
location={this.state.location}
bio={this.state.bio}
url={this.state.url}
/>
</Col>
<Col xs={1} md={1} className="fullytight text-align-right"></Col>
</Row>

Loading…
Cancel
Save