fixed avatar in sidebar
This commit is contained in:
parent
06fd235bec
commit
0eeffcf7f6
4 changed files with 31 additions and 10 deletions
|
@ -60,7 +60,6 @@ function(APICalls, HostApp) {
|
|||
|
||||
NewPost.prototype.setStatus = function(status_string) {
|
||||
if (status_string && status_string.length > 0) {
|
||||
debug(status_string)
|
||||
this.status = JSON.parse(status_string);
|
||||
this.setIsPrivate(this.status.permissions && !this.status.permissions.public);
|
||||
this.setMentions(this.status);
|
||||
|
|
|
@ -231,8 +231,7 @@ function(HostApp, Core, APICalls, URI) {
|
|||
this.profile_template.following_button.style.display = "none";
|
||||
}
|
||||
|
||||
var url = HostApp.serverUrl("posts_feed") + "?types=" + encodeURIComponent("https://tent.io/types/meta/v0") + "&entities=" + encodeURIComponent(this.entity)
|
||||
//var url = HostApp.serverUrl("discover").replace(/{entity}/, encodeURIComponent(this.entity));
|
||||
var url = HostApp.serverUrl("posts_feed") + "?types=" + encodeURIComponent("https://tent.io/types/meta/v0") + "&entities=" + encodeURIComponent(this.entity);
|
||||
APICalls.get(url, {
|
||||
callback: function(resp) {
|
||||
var profile = JSON.parse(resp.responseText);
|
||||
|
@ -274,7 +273,7 @@ function(HostApp, Core, APICalls, URI) {
|
|||
|
||||
if(profiles.posts.length < 1) return;
|
||||
var profile = profiles.posts[0];
|
||||
bungloo.cache.profiles[profile.entity] = profile;
|
||||
bungloo.cache.profiles[profile.entity] = profile.content.profile;
|
||||
|
||||
var basic = profile.content.profile;
|
||||
|
||||
|
|
|
@ -81,15 +81,38 @@ function(HostApp, APICalls) {
|
|||
var entity = HostApp.stringForKey("entity");
|
||||
this.menu.user.title = entity;
|
||||
|
||||
var img = this.menu.user.getElementsByTagName("img")[0];
|
||||
|
||||
var avatar = this.menu.user.getElementsByTagName("img")[0];
|
||||
var _this = this;
|
||||
|
||||
var url = HostApp.serverUrl("discover");
|
||||
debug(url)
|
||||
|
||||
var url = HostApp.serverUrl("posts_feed") + "?types=" + encodeURIComponent("https://tent.io/types/meta/v0") + "&entities=" + encodeURIComponent(entity);
|
||||
APICalls.get(url, { callback: function(resp) {
|
||||
var profiles = JSON.parse(resp.responseText);
|
||||
|
||||
if(profiles.posts.length < 1) return;
|
||||
var profile = profiles.posts[0];
|
||||
bungloo.cache.profiles[entity] = profile;
|
||||
|
||||
// Find and apply avatar
|
||||
if(profile.attachments) {
|
||||
|
||||
var digest = null;
|
||||
for (var i = 0; i < profile.attachments.length; i++) {
|
||||
var attachment = profile.attachments[i];
|
||||
if(attachment.category == "avatar") {
|
||||
digest = attachment.digest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(digest) {
|
||||
var _this = this;
|
||||
avatar.onerror = function() { avatar.src = 'img/default-avatar.png' };
|
||||
var avatar_url = profile.content.servers[0].urls.attachment.replace(/\{entity\}/, encodeURIComponent(profile.entity));
|
||||
avatar.src = avatar_url.replace(/\{digest\}/, digest);
|
||||
avatar.src_inactive = avatar.src;
|
||||
avatar.src_active = avatar.src;
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ function(Core, APICalls, HostApp, URI) {
|
|||
document.getElementById("content").appendChild(this.container);
|
||||
|
||||
var _this = this;
|
||||
//this.reloadIntervall = setInterval(function() { _this.getNewData() }, this.timeout); //FIXME back
|
||||
this.reloadIntervall = setInterval(function() { _this.getNewData() }, this.timeout);
|
||||
|
||||
this.getNewData();
|
||||
}
|
||||
|
|
Reference in a new issue