mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-13 05:51:03 +00:00
implement loading more posts in modal profile (partial merge of calm implementation)
This commit is contained in:
parent
e4a8d751d2
commit
1efb49939f
@ -95,8 +95,19 @@ function requestRTs(postLi)
|
||||
}
|
||||
}
|
||||
|
||||
var profilePostsLoading = false;
|
||||
|
||||
function requestPostRecursively(containerToAppend,username,resource,count)
|
||||
{
|
||||
if( !resource ) {
|
||||
var streamItems = containerToAppend.children();
|
||||
if( streamItems.length != 0 ) {
|
||||
var lastItem = streamItems.eq(streamItems.length-1);
|
||||
resource = "post" + lastItem.find(".post-data").attr("data-lastk");
|
||||
}
|
||||
}
|
||||
|
||||
profilePostsLoading = true;
|
||||
dhtget( username, resource, "s",
|
||||
function(args, postFromJson) {
|
||||
if( postFromJson ) {
|
||||
@ -114,7 +125,11 @@ function requestPostRecursively(containerToAppend,username,resource,count)
|
||||
lastk = userpost["k"] - 1; // not true with directmsgs in stream
|
||||
|
||||
requestPostRecursively(args.containerToAppend, n, "post"+lastk, count-1);
|
||||
} else {
|
||||
profilePostsLoading = false;
|
||||
}
|
||||
} else {
|
||||
profilePostsLoading = false;
|
||||
}
|
||||
}, {containerToAppend:containerToAppend, count:count} );
|
||||
}
|
||||
@ -179,7 +194,17 @@ function updateProfileData(profileModalContent, username) {
|
||||
|
||||
profileModalContent.find(".following-count").parent().attr("href", $.MAL.followingUrl(username));
|
||||
|
||||
requestPostRecursively(profileModalContent.find(".postboard-posts"),username,"status",10);
|
||||
var postsView = profileModalContent.find(".postboard-posts");
|
||||
requestPostRecursively(postsView,username,"status",10);
|
||||
|
||||
postsView.scroll(function(){
|
||||
if (!profilePostsLoading) {
|
||||
var $this = $(this);
|
||||
if ($this.scrollTop() >= this.scrollHeight - $this.height() - 20) {
|
||||
requestPostRecursively($this,username,"",10);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateFollowingData(followingModalContent, username) {
|
||||
|
@ -63,6 +63,7 @@ function postToElem( post, kind ) {
|
||||
postData.attr('data-content_to_sigrt', content_to_sigrt);
|
||||
postData.attr('data-screen-name', n);
|
||||
postData.attr('data-id', k);
|
||||
postData.attr('data-lastk', userpost["lastk"]);
|
||||
postData.attr('data-text', msg);
|
||||
if( "reply" in userpost ) {
|
||||
postData.attr('data-replied-to-screen-name', userpost["reply"]["n"]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user