Merge pull request #3605 from annando/better-endless-scroll
Endless scroll now avoids showing the same items
This commit is contained in:
commit
390e34d587
|
@ -424,7 +424,6 @@ function item_fieldlists() {
|
|||
These Fields are not added below (yet). They are here to for bug search.
|
||||
`item`.`type`,
|
||||
`item`.`extid`,
|
||||
`item`.`received`,
|
||||
`item`.`changed`,
|
||||
`item`.`moderated`,
|
||||
`item`.`target-type`,
|
||||
|
@ -451,7 +450,7 @@ These Fields are not added below (yet). They are here to for bug search.
|
|||
`item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
|
||||
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
|
||||
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`,
|
||||
`item`.`commented`, `item`.`created`, `item`.`edited`,
|
||||
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
|
||||
`item`.`verb`, `item`.`object-type`, `item`.`postopts`, `item`.`plink`,
|
||||
`item`.`guid`, `item`.`wall`, `item`.`private`, `item`.`starred`,
|
||||
`item`.`title`, `item`.`body`, `item`.`file`, `item`.`event-id`,
|
||||
|
|
32
js/main.js
32
js/main.js
|
@ -720,11 +720,41 @@
|
|||
// page number
|
||||
infinite_scroll.pageno+=1;
|
||||
|
||||
match = $("span.received").last();
|
||||
if (match.length > 0) {
|
||||
received = match[0].innerHTML;
|
||||
} else {
|
||||
received = "0000-00-00 00:00:00";
|
||||
}
|
||||
|
||||
match = $("span.created").last();
|
||||
if (match.length > 0) {
|
||||
created = match[0].innerHTML;
|
||||
} else {
|
||||
created = "0000-00-00 00:00:00";
|
||||
}
|
||||
|
||||
match = $("span.commented").last();
|
||||
if (match.length > 0) {
|
||||
commented = match[0].innerHTML;
|
||||
} else {
|
||||
commented = "0000-00-00 00:00:00";
|
||||
}
|
||||
|
||||
match = $("span.id").last();
|
||||
if (match.length > 0) {
|
||||
id = match[0].innerHTML;
|
||||
} else {
|
||||
id = "0";
|
||||
}
|
||||
// console.log("Received: " + received + " - Commented: " + commented+ " - Created: " + created + " - ID: " + id);
|
||||
|
||||
// get the raw content from the next page and insert this content
|
||||
// right before "#conversation-end"
|
||||
$.get('network?mode=raw' + infinite_scroll.reload_uri + '&page=' + infinite_scroll.pageno, function(data) {
|
||||
$.get('network?mode=raw' + infinite_scroll.reload_uri + '&last_received=' + received + '&last_commented=' + commented + '&last_created=' + created + '&last_id=' + id + '&page=' + infinite_scroll.pageno, function(data) {
|
||||
$("#scroll-loader").hide();
|
||||
if ($(data).length > 0) {
|
||||
|
||||
$(data).insertBefore('#conversation-end');
|
||||
lockLoadContent = false;
|
||||
} else {
|
||||
|
|
|
@ -325,6 +325,18 @@ function network_content(App $a, $update = 0) {
|
|||
// Rawmode is used for fetching new content at the end of the page
|
||||
$rawmode = (isset($_GET["mode"]) AND ($_GET["mode"] == "raw"));
|
||||
|
||||
if (isset($_GET["last_received"]) && isset($_GET["last_commented"]) && isset($_GET["last_created"]) && isset($_GET["last_id"])) {
|
||||
$last_received = dbm::date($_GET["last_received"]);
|
||||
$last_commented = dbm::date($_GET["last_commented"]);
|
||||
$last_created = dbm::date($_GET["last_created"]);
|
||||
$last_id = intval($_GET["last_id"]);
|
||||
} else {
|
||||
$last_received = '';
|
||||
$last_commented = '';
|
||||
$last_created = '';
|
||||
$last_id = 0;
|
||||
}
|
||||
|
||||
/// @TODO Is this really necessary? $a is already available to hooks
|
||||
$arr = array('query' => $a->query_string);
|
||||
call_hooks('network_content_init', $arr);
|
||||
|
@ -596,14 +608,12 @@ function network_content(App $a, $update = 0) {
|
|||
$order_mode = "id";
|
||||
}
|
||||
|
||||
if($conv)
|
||||
if ($conv) {
|
||||
$sql_extra3 .= " AND $sql_table.`mention`";
|
||||
|
||||
if($update) {
|
||||
|
||||
}
|
||||
if ($update) {
|
||||
// only setup pagination on initial page view
|
||||
$pager_sql = '';
|
||||
|
||||
} else {
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
|
@ -624,7 +634,7 @@ function network_content(App $a, $update = 0) {
|
|||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
|
||||
if($nouveau) {
|
||||
if ($nouveau) {
|
||||
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
|
||||
|
||||
if ($sql_order == "")
|
||||
|
@ -644,8 +654,6 @@ function network_content(App $a, $update = 0) {
|
|||
} else {
|
||||
|
||||
// Normal conversation view
|
||||
|
||||
|
||||
if($order === 'post') {
|
||||
$ordering = "`created`";
|
||||
if ($sql_order == "")
|
||||
|
@ -662,8 +670,39 @@ function network_content(App $a, $update = 0) {
|
|||
if (($_GET["offset"] != ""))
|
||||
$sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
|
||||
|
||||
switch ($order_mode) {
|
||||
case 'received':
|
||||
if ($last_received != '') {
|
||||
$sql_extra3 .= sprintf(" AND $sql_table.`received` < '%s'", dbesc($last_received));
|
||||
$a->set_pager_page(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
case 'commented':
|
||||
if ($last_commented != '') {
|
||||
$sql_extra3 .= sprintf(" AND $sql_table.`commented` < '%s'", dbesc($last_commented));
|
||||
$a->set_pager_page(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
case 'created':
|
||||
if ($last_created != '') {
|
||||
$sql_extra3 .= sprintf(" AND $sql_table.`created` < '%s'", dbesc($last_created));
|
||||
$a->set_pager_page(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
if (($last_id > 0) && ($sql_table == "`thread`")) {
|
||||
$sql_extra3 .= sprintf(" AND $sql_table.`iid` < '%s'", dbesc($last_id));
|
||||
$a->set_pager_page(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Fetch a page full of parent items for this page
|
||||
if($update) {
|
||||
if ($update) {
|
||||
if (get_config("system", "like_no_comment"))
|
||||
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
|
||||
else
|
||||
|
|
|
@ -394,6 +394,9 @@ class Item extends BaseObject {
|
|||
'edited' => $edited,
|
||||
'network' => $item["item_network"],
|
||||
'network_name' => network_to_name($item['item_network'], $profile_link),
|
||||
'received' => $item['received'],
|
||||
'commented' => $item['commented'],
|
||||
'created_date' => $item['created'],
|
||||
);
|
||||
|
||||
$arr = array('item' => $item, 'output' => $tmp_item);
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
</div>
|
||||
<div id="collapsed-comments-{{$item.id}}" class="collapsed-comments" style="display: none;">
|
||||
{{/if}}
|
||||
{{if $item.thread_level==1}}
|
||||
<span class="commented" style="display: none;">{{$item.commented}}</span>
|
||||
<span class="received" style="display: none;">{{$item.received}}</span>
|
||||
<span class="created" style="display: none;">{{$item.created_date}}</span>
|
||||
<span class="id" style="display: none;">{{$item.id}}</span>
|
||||
{{/if}}
|
||||
<div id="tread-wrapper-{{$item.id}}" class="tread-wrapper {{$item.toplevel}} {{if $item.toplevel}} h-entry {{else}} u-comment h-cite {{/if}}">
|
||||
<a name="{{$item.id}}" ></a>
|
||||
<div class="wall-item-outside-wrapper {{$item.indent}}{{$item.previewing}}{{if $item.owner_url}} wallwall{{/if}}" id="wall-item-outside-wrapper-{{$item.id}}" >
|
||||
|
|
|
@ -71,7 +71,13 @@ as the value of $top_child_total (this is done at the end of this file)
|
|||
<div class="item-{{$item.id}} wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_{{$item.thread_level}} {{if $item.thread_level==1}}panel-body h-entry{{else}}u-comment h-cite{{/if}}" id="item-{{$item.guid}}"><!-- wall-item-container -->
|
||||
{{else}}
|
||||
<div class="item-{{$item.id}} wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_7 u-comment h-cite" id="item-{{$item.guid}}">
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{if $item.thread_level==1}}
|
||||
<span class="commented" style="display: none;">{{$item.commented}}</span>
|
||||
<span class="received" style="display: none;">{{$item.received}}</span>
|
||||
<span class="created" style="display: none;">{{$item.created_date}}</span>
|
||||
<span class="id" style="display: none;">{{$item.id}}</span>
|
||||
{{/if}}
|
||||
<div class="media">
|
||||
{{* Put addional actions in a top-right dropdown menu *}}
|
||||
|
||||
|
|
|
@ -19,7 +19,14 @@
|
|||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if $item.thread_level!=1}}<div class="children u-comment h-cite">{{/if}}
|
||||
{{if $item.thread_level!=1}}
|
||||
<div class="children u-comment h-cite">
|
||||
{{else}}
|
||||
<span class="commented" style="display: none;">{{$item.commented}}</span>
|
||||
<span class="received" style="display: none;">{{$item.received}}</span>
|
||||
<span class="created" style="display: none;">{{$item.created_date}}</span>
|
||||
<span class="id" style="display: none;">{{$item.id}}</span>
|
||||
{{/if}}
|
||||
|
||||
<div class="wall-item-decor">
|
||||
{{if $item.star}}<span class="icon s22 star {{$item.isstarred}}" id="starred-{{$item.id}}" title="{{$item.star.starred}}">{{$item.star.starred}}</span>{{/if}}
|
||||
|
|
|
@ -27,6 +27,12 @@
|
|||
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_{{$item.thread_level}}" id="item-{{$item.guid}}">
|
||||
{{else}}
|
||||
<div class="wall-item-container {{$item.indent}} {{$item.shiny}} {{$item.network}} thread_level_7" id="item-{{$item.guid}}">
|
||||
{{/if}}
|
||||
{{if $item.thread_level==1}}
|
||||
<span class="commented" style="display: none;">{{$item.commented}}</span>
|
||||
<span class="received" style="display: none;">{{$item.received}}</span>
|
||||
<span class="created" style="display: none;">{{$item.created_date}}</span>
|
||||
<span class="id" style="display: none;">{{$item.id}}</span>
|
||||
{{/if}}
|
||||
<div class="wall-item-item">
|
||||
<div class="wall-item-info">
|
||||
|
|
Loading…
Reference in a new issue