mirror of
https://github.com/twisterarmy/twister-react.git
synced 2025-09-03 01:32:28 +00:00
edit profile and avatar
This commit is contained in:
parent
b253c68411
commit
be6eb038b0
File diff suppressed because it is too large
Load Diff
@ -29859,15 +29859,14 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
|
|||||||
profile._revisionNumber+1,
|
profile._revisionNumber+1,
|
||||||
function(result){
|
function(result){
|
||||||
|
|
||||||
var TwisterProfile = require("../TwisterProfile.js");
|
var newprofile = Twister.getUser(thisAccount._name)._profile;
|
||||||
|
newprofile._data = newdata;
|
||||||
|
if(cbfunc) cbfunc(newprofile);
|
||||||
|
|
||||||
var newprofile = new TwisterProfile(thisAccount._name,Twister);
|
},function(error){
|
||||||
newprofile._data = newdata;
|
thisAccount._handleError(error);
|
||||||
if(cbfunc) cbfunc(newprofile);
|
}
|
||||||
|
);
|
||||||
},function(error){
|
|
||||||
thisAccount._handleError(error);
|
|
||||||
});
|
|
||||||
|
|
||||||
},{errorfunc:function(error){
|
},{errorfunc:function(error){
|
||||||
|
|
||||||
@ -29879,6 +29878,8 @@ TwisterAccount.prototype.updateProfile = function (newdata,cbfunc) {
|
|||||||
|
|
||||||
thisAccount.updateProfileFields(newdata,cbfunc);
|
thisAccount.updateProfileFields(newdata,cbfunc);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
thisAccount._handleError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}})
|
}})
|
||||||
@ -29903,22 +29904,21 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
thisAccount._dhtput(
|
thisAccount._dhtput(
|
||||||
thisAccount._name,
|
thisAccount._name,
|
||||||
"profile",
|
"profile",
|
||||||
"s",
|
"s",
|
||||||
olddata,
|
olddata,
|
||||||
profile._revisionNumber+1,
|
profile._revisionNumber+1,
|
||||||
function(result){
|
function(result){
|
||||||
|
|
||||||
var TwisterProfile = require("../TwisterProfile.js");
|
var newprofile = Twister.getUser(thisAccount._name)._profile;
|
||||||
|
|
||||||
var newprofile = new TwisterProfile(thisAccount._name,Twister);
|
|
||||||
newprofile._data = olddata;
|
newprofile._data = olddata;
|
||||||
if(cbfunc) cbfunc(newprofile);
|
if(cbfunc) cbfunc(newprofile);
|
||||||
|
|
||||||
},function(error){
|
},function(error){
|
||||||
thisAccount._handleError(error);
|
thisAccount._handleError(error);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
},{errorfunc:function(error){
|
},{errorfunc:function(error){
|
||||||
|
|
||||||
@ -29930,6 +29930,8 @@ TwisterAccount.prototype.updateProfileFields = function (newdata,cbfunc) {
|
|||||||
|
|
||||||
thisAccount.updateProfileFields(newdata,cbfunc);
|
thisAccount.updateProfileFields(newdata,cbfunc);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
thisAccount._handleError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}})
|
}})
|
||||||
@ -29952,12 +29954,10 @@ TwisterAccount.prototype.updateAvatar = function (newdata,cbfunc) {
|
|||||||
avatar._revisionNumber+1,
|
avatar._revisionNumber+1,
|
||||||
function(result){
|
function(result){
|
||||||
|
|
||||||
var TwisterAvatar = require("../TwisterAvatar.js");
|
var newavatar = Twister.getUser(thisAccount._name)._avatar;
|
||||||
|
newavatar._data = newdata;
|
||||||
var newprofile = new TwisterAvatar(thisAccount._name,Twister);
|
if(cbfunc) cbfunc(newavatar);
|
||||||
newprofile._data = newdata;
|
|
||||||
if(cbfunc) cbfunc(newprofile);
|
|
||||||
|
|
||||||
},function(error){
|
},function(error){
|
||||||
thisAccount._handleError(error);
|
thisAccount._handleError(error);
|
||||||
});
|
});
|
||||||
@ -30342,7 +30342,7 @@ TwisterAccount.prototype._publishPostOnDht = function(v,cbfunc){
|
|||||||
|
|
||||||
|
|
||||||
}).call(this,require("buffer").Buffer)
|
}).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 = {
|
module.exports = {
|
||||||
extractUsername: function(s) {
|
extractUsername: function(s) {
|
||||||
var username = "";
|
var username = "";
|
||||||
@ -32779,6 +32779,16 @@ TwisterAvatar.prototype.getUrl = function () {
|
|||||||
|
|
||||||
return this._data;
|
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){
|
},{"./TwisterAvatar.js":148,"./TwisterResource.js":157,"inherits":52}],149:[function(require,module,exports){
|
||||||
var inherits = require('inherits');
|
var inherits = require('inherits');
|
||||||
|
@ -13,6 +13,7 @@ body.modal-open {
|
|||||||
|
|
||||||
.link-button-gray {
|
.link-button-gray {
|
||||||
color: #666;
|
color: #666;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tight {
|
.tight {
|
||||||
|
@ -15,12 +15,45 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
|
|||||||
var PostContent = require('../common/PostContent.js');
|
var PostContent = require('../common/PostContent.js');
|
||||||
var ReplyModalButton = require('../common/ReplyModalButton.js');
|
var ReplyModalButton = require('../common/ReplyModalButton.js');
|
||||||
var RetwistModalButton = require('../common/RetwistModalButton.js');
|
var RetwistModalButton = require('../common/RetwistModalButton.js');
|
||||||
|
var EventListenerMixin = require('../common/EventListenerMixin.js');
|
||||||
|
|
||||||
module.exports = Post = React.createClass({
|
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() {
|
getInitialState: function() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
username: this.props.post.username,
|
||||||
avatar: "img/genericPerson.png",
|
avatar: "img/genericPerson.png",
|
||||||
fullname: "",
|
fullname: "",
|
||||||
timeAgo: "",
|
timeAgo: "",
|
||||||
@ -51,7 +84,10 @@ module.exports = Post = React.createClass({
|
|||||||
if (post.isRetwist()) {
|
if (post.isRetwist()) {
|
||||||
|
|
||||||
post.getUser().doProfile(function(profile){
|
post.getUser().doProfile(function(profile){
|
||||||
thisComponent.setStateSafe({retwistingUser: profile.getField("fullname")});
|
thisComponent.setStateSafe({
|
||||||
|
retwistingUsername: profile.getUsername(),
|
||||||
|
retwistingUserFullname: profile.getField("fullname")
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
post=post.getRetwistedPost();
|
post=post.getRetwistedPost();
|
||||||
@ -136,7 +172,7 @@ module.exports = Post = React.createClass({
|
|||||||
</Row>
|
</Row>
|
||||||
<Row className="nomargin">
|
<Row className="nomargin">
|
||||||
<Col xs={6} md={6} className="fullytight">
|
<Col xs={6} md={6} className="fullytight">
|
||||||
{retwist && <small><em> retwisted by {this.state.retwistingUser}</em></small>
|
{retwist && <small><em> retwisted by {this.state.retwistingUserFullname}</em></small>
|
||||||
}
|
}
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={4} md={4} className="fullytight text-align-right">
|
<Col xs={4} md={4} className="fullytight text-align-right">
|
||||||
|
@ -1,8 +1,36 @@
|
|||||||
|
|
||||||
var AppSettingsMixin = require('../common/AppSettingsMixin.js');
|
var AppSettingsMixin = require('../common/AppSettingsMixin.js');
|
||||||
|
var EventListenerMixin = require('../common/EventListenerMixin.js');
|
||||||
|
|
||||||
module.exports = ProfileMixin = {
|
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() {
|
getInitialState: function() {
|
||||||
|
|
||||||
var username = this.props.username;
|
var username = this.props.username;
|
||||||
|
@ -20,9 +20,15 @@ var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
|
|||||||
var ProfileMixin = require('../common/ProfileMixin.js');
|
var ProfileMixin = require('../common/ProfileMixin.js');
|
||||||
|
|
||||||
var FollowButton = require('../common/FollowButton.js');
|
var FollowButton = require('../common/FollowButton.js');
|
||||||
|
var EditProfileModalButton = require('../profile/EditProfileModalButton.js');
|
||||||
|
var EditAvatarModalButton = require('../profile/EditAvatarModalButton.js');
|
||||||
|
|
||||||
module.exports = Post = React.createClass({
|
module.exports = Post = React.createClass({
|
||||||
mixins: [SetIntervalMixin,SafeStateChangeMixin,ProfileMixin],
|
mixins: [
|
||||||
|
SetIntervalMixin,
|
||||||
|
SafeStateChangeMixin,
|
||||||
|
ProfileMixin
|
||||||
|
],
|
||||||
contextTypes: {
|
contextTypes: {
|
||||||
router: React.PropTypes.func
|
router: React.PropTypes.func
|
||||||
},
|
},
|
||||||
@ -54,6 +60,11 @@ module.exports = Post = React.createClass({
|
|||||||
<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/>
|
<br/>
|
||||||
|
<EditAvatarModalButton
|
||||||
|
activeAccount={this.props.activeAccount}
|
||||||
|
username={this.state.username}
|
||||||
|
avatar={this.state.avatar}
|
||||||
|
/>
|
||||||
<FollowButton activeAccount={this.props.activeAccount} username={this.state.username}/>
|
<FollowButton activeAccount={this.props.activeAccount} username={this.state.username}/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={8} md={8}>
|
<Col xs={8} md={8}>
|
||||||
@ -61,6 +72,14 @@ module.exports = Post = React.createClass({
|
|||||||
<p className="text-center">{this.state.location}</p>
|
<p className="text-center">{this.state.location}</p>
|
||||||
<p className="text-center">{this.state.bio}</p>
|
<p className="text-center">{this.state.bio}</p>
|
||||||
<p className="text-center"><a href={this.state.url}>{this.state.url}</a></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>
|
||||||
<Col xs={1} md={1} className="fullytight text-align-right"></Col>
|
<Col xs={1} md={1} className="fullytight text-align-right"></Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user