diff --git a/include/conversation.php b/include/conversation.php index e58df19f16..bd6e714654 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -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`, diff --git a/js/main.js b/js/main.js index 5df33ed590..fff4078ae8 100644 --- a/js/main.js +++ b/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 { diff --git a/mod/network.php b/mod/network.php index 61db199d55..aad56bfd67 100644 --- a/mod/network.php +++ b/mod/network.php @@ -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 diff --git a/object/Item.php b/object/Item.php index 95c01a073e..e8110f5ffa 100644 --- a/object/Item.php +++ b/object/Item.php @@ -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); diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index f020d68df1..37f034586a 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -5,6 +5,12 @@