Browse Source

auto load old posts in profile view

master
Denis Ryabov 11 years ago
parent
commit
ded234bed7
  1. 21
      js/twister_actions.js

21
js/twister_actions.js

@ -95,8 +95,12 @@ function requestRTs(postLi) @@ -95,8 +95,12 @@ function requestRTs(postLi)
}
}
var lastk,
profilePostsLoading = false;
function requestPostRecursively(containerToAppend,username,resource,count)
{
profilePostsLoading = true;
dhtget( username, resource, "s",
function(args, postFromJson) {
if( postFromJson ) {
@ -106,14 +110,16 @@ function requestPostRecursively(containerToAppend,username,resource,count) @@ -106,14 +110,16 @@ function requestPostRecursively(containerToAppend,username,resource,count)
newStreamPost.slideDown("fast");
$.MAL.postboardLoaded();
if( args.count > 1 ) {
var userpost = postFromJson["userpost"];
var n = userpost["n"];
var lastk = userpost["lastk"];
lastk = userpost["lastk"];
if( lastk == undefined )
lastk = userpost["k"] - 1; // not true with directmsgs in stream
if( args.count > 1 ) {
requestPostRecursively(args.containerToAppend, n, "post"+lastk, count-1);
} else {
profilePostsLoading = false;
}
}
}, {containerToAppend:containerToAppend, count:count} );
@ -179,7 +185,16 @@ function updateProfileData(profileModalContent, username) { @@ -179,7 +185,16 @@ function updateProfileData(profileModalContent, username) {
profileModalContent.find(".following-count").parent().attr("href", $.MAL.followingUrl(username));
requestPostRecursively(profileModalContent.find(".postboard-posts"),username,"status",20);
var postsView = profileModalContent.find(".postboard-posts");
requestPostRecursively(postsView,username,"status",20);
postsView.scroll(function(){
if (!profilePostsLoading) {
var $this = $(this);
if ($this.scrollTop() >= this.scrollHeight - $this.height() - 20) {
requestPostRecursively($this,username,"post"+lastk,20);
}
}
});
}
function updateFollowingData(followingModalContent, username) {

Loading…
Cancel
Save