fixed problems with scroll to load more
This commit is contained in:
parent
624dd9a1b9
commit
be8a0c63e3
10 changed files with 101 additions and 45 deletions
|
@ -8,9 +8,11 @@ define([
|
|||
function(HostApp, Core, Paths, URI) {
|
||||
|
||||
|
||||
function Conversation() {
|
||||
function Conversation(standalone) {
|
||||
|
||||
Core.call(this);
|
||||
|
||||
this.standalone = standalone;
|
||||
|
||||
this.action = "conversation";
|
||||
|
||||
|
@ -20,7 +22,7 @@ function(HostApp, Core, Paths, URI) {
|
|||
this.container.appendChild(this.body)
|
||||
|
||||
document.getElementById("content").appendChild(this.container);
|
||||
this.hide();
|
||||
if(!this.standalone) this.hide();
|
||||
}
|
||||
|
||||
Conversation.prototype = Object.create(Core.prototype);
|
||||
|
@ -43,6 +45,8 @@ function(HostApp, Core, Paths, URI) {
|
|||
Conversation.prototype.showStatus = function(id, entity) {
|
||||
|
||||
this.body.innerHTML = "";
|
||||
this.current_post_id = id;
|
||||
this.current_entity = entity;
|
||||
this.append(id, entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -417,11 +417,10 @@ function(HostApp, Core, Paths, URI) {
|
|||
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
|
||||
var last_status = statuses[statuses.length -1];
|
||||
this.before.id = last_status.id
|
||||
this.before.entity = last_status.entity;
|
||||
this.before.loading = false;
|
||||
|
||||
if (append) statuses = statuses.reverse();
|
||||
|
||||
for(var i = statuses.length-1, c=0; i>=c; --i) {
|
||||
|
||||
var status = statuses[i];
|
||||
|
@ -460,11 +459,11 @@ function(HostApp, Core, Paths, URI) {
|
|||
}
|
||||
|
||||
Profile.prototype.getMoreStatusPosts = function() {
|
||||
if (!this.before.loading && this.before.id) {
|
||||
if (!this.before.loading) {
|
||||
this.before.loading = true;
|
||||
var add_search = {
|
||||
"before_id": this.before.id,
|
||||
"before_id_entity": this.before.entity
|
||||
"before_id": this.body.lastChild.status.id,
|
||||
"before_id_entity": this.body.lastChild.status.entity
|
||||
}
|
||||
this.getStatuses(this.server, add_search, true);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,7 @@ function(HostApp, Paths, Cache) {
|
|||
|
||||
this.menu.user = this.createItem("User", function() { _this.onEntity(); return false; }, "img/sidebar/user.png", "img/sidebar/user.png");
|
||||
this.menu.timeline = this.createItem("Timeline", function() { _this.onTimeline(); return false; }, "img/sidebar/timeline.png", "img/sidebar/timeline_active.png", true);
|
||||
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions(); return false; }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
|
||||
|
||||
this.menu.mentions = this.createItem("Mentions", function() { _this.onMentions(); return false; }, "img/sidebar/mentions.png", "img/sidebar/mentions_active.png");
|
||||
this.menu.conversation = this.createItem("Conversation", function() { _this.onConversation(); return false; }, "img/sidebar/conversation.png", "img/sidebar/conversation_active.png");
|
||||
this.menu.entityProfile = this.createItem("Profile", function() { _this.onEntityProfile(); return false; }, "img/sidebar/profile.png", "img/sidebar/profile_active.png");
|
||||
this.menu.search = this.createItem("Search", function() { _this.onSearch(); return false; }, "img/sidebar/search.png", "img/sidebar/search_active.png")
|
||||
|
@ -35,13 +34,22 @@ function(HostApp, Paths, Cache) {
|
|||
|
||||
this.unreadMentionsSpan = document.createElement("span");
|
||||
this.unreadMentionsSpan.className = "unread_mentions";
|
||||
this.menu.mentions.appendChild(this.unreadMentionsSpan);
|
||||
this.menu.mentions.getElementsByTagName("a")[0].appendChild(this.unreadMentionsSpan);
|
||||
this.setUnreadMentions(0);
|
||||
|
||||
this.menu.conversation.getElementsByTagName("a")[0].ondblclick = function() {
|
||||
var postId = bungloo.conversation.current_post_id;
|
||||
var entity = bungloo.conversation.current_entity;
|
||||
if (postId && entity) {
|
||||
HostApp.showConversationViewForPostIdandEntity(postId, entity);
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("sidebar").appendChild(this.body);
|
||||
|
||||
// initial seting of the <body> class
|
||||
document.body.className = "body-timeline";
|
||||
document.body.id = "with-sidebar";
|
||||
|
||||
this.setEntityAvatar();
|
||||
this.setOnScroll();
|
||||
|
|
|
@ -14,7 +14,7 @@ function(Core, Paths, HostApp, URI) {
|
|||
this.action = "timeline";
|
||||
this.reload_blocked = false;
|
||||
|
||||
this.max_length = 20;
|
||||
this.max_length = 25;
|
||||
this.timeout = 10 * 1000; // every 10 seconds
|
||||
this.since_id = null;
|
||||
this.since_id_entity = null;
|
||||
|
@ -49,11 +49,10 @@ function(Core, Paths, HostApp, URI) {
|
|||
|
||||
if(statuses != null && statuses.length > 0) {
|
||||
|
||||
var last_status = statuses[statuses.length -1];
|
||||
this.before.id = last_status.id
|
||||
this.before.entity = last_status.entity;
|
||||
this.before.loading = false;
|
||||
|
||||
if (append) statuses = statuses.reverse();
|
||||
|
||||
for(var i = statuses.length-1, c=0; i>=c; --i) {
|
||||
|
||||
var status = statuses[i];
|
||||
|
@ -66,18 +65,20 @@ function(Core, Paths, HostApp, URI) {
|
|||
|
||||
var new_node = this.getStatusDOMElement(status);
|
||||
|
||||
if(!append && this.body.childNodes.length > 0) {
|
||||
if (!document.getElementById(new_node.id)) {
|
||||
if(!append && this.body.childNodes.length > 0) {
|
||||
|
||||
if(this.body.childNodes.length > this.max_length) {
|
||||
if(this.body.childNodes.length > this.max_length) {
|
||||
|
||||
this.body.removeChild(this.body.lastChild);
|
||||
this.body.removeChild(this.body.lastChild);
|
||||
}
|
||||
|
||||
this.body.insertBefore(new_node, this.body.firstChild);
|
||||
|
||||
} else {
|
||||
|
||||
this.body.appendChild(new_node);
|
||||
}
|
||||
|
||||
this.body.insertBefore(new_node, this.body.firstChild);
|
||||
|
||||
} else {
|
||||
|
||||
this.body.appendChild(new_node);
|
||||
}
|
||||
|
||||
} else if (status.type == "https://tent.io/types/post/delete/v0.1.0") {
|
||||
|
@ -107,7 +108,7 @@ function(Core, Paths, HostApp, URI) {
|
|||
"https://tent.io/types/post/photo/v0.1.0"
|
||||
];
|
||||
url.addSearch("post_types", post_types.join(","));
|
||||
|
||||
//url.addSearch("sort_by", "published_at");
|
||||
url.addSearch("limit", this.max_length);
|
||||
|
||||
if(this.since_id && !append) {
|
||||
|
@ -147,12 +148,13 @@ function(Core, Paths, HostApp, URI) {
|
|||
}
|
||||
|
||||
Timeline.prototype.getMoreStatusPosts = function() {
|
||||
if (!this.before.loading && this.before.id) {
|
||||
if (!this.before.loading) {
|
||||
this.before.loading = true;
|
||||
var add_search = {
|
||||
"before_id": this.before.id,
|
||||
"before_id_entity": this.before.entity
|
||||
"before_id": this.body.lastChild.status.id,
|
||||
"before_id_entity": this.body.lastChild.status.entity
|
||||
}
|
||||
|
||||
this.getNewData(add_search, true);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue