live update improvements

This commit is contained in:
friendica 2011-12-12 16:11:03 -08:00
parent 80428a33d5
commit c45b903178
2 changed files with 44 additions and 31 deletions

View file

@ -376,7 +376,6 @@ function network_content(&$a, $update = 0) {
// only setup pagination on initial page view // only setup pagination on initial page view
$pager_sql = ''; $pager_sql = '';
$update_sql = " AND unseen = 1 ";
} }
else { else {
@ -393,11 +392,11 @@ function network_content(&$a, $update = 0) {
$a->set_pager_total($r[0]['total']); $a->set_pager_total($r[0]['total']);
$a->set_pager_itemspage(40); $a->set_pager_itemspage(40);
} }
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
$update_sql = '';
} }
$simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
if($nouveau) { if($nouveau) {
// "New Item View" - show all items unthreaded in reverse created date order // "New Item View" - show all items unthreaded in reverse created date order
@ -408,7 +407,7 @@ function network_content(&$a, $update = 0) {
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item`, `contact` FROM `item`, `contact`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
$update_sql $simple_update
AND `contact`.`id` = `item`.`contact-id` AND `contact`.`id` = `item`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_extra
@ -429,16 +428,27 @@ function network_content(&$a, $update = 0) {
// Fetch a page full of parent items for this page // Fetch a page full of parent items for this page
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` if($update) {
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` $r = q("SELECT distinct(`parent`) AS `item_id`, `contact`.`uid` AS `contact_uid`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
$update_sql WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 and `item`.`parent` in ( select parent from item where unseen = 1 )
AND `item`.`parent` = `item`.`id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_extra ",
ORDER BY `item`.$ordering DESC $pager_sql ", intval(local_user())
intval(local_user()) );
); }
else {
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`parent` = `item`.`id`
$sql_extra
ORDER BY `item`.$ordering DESC $pager_sql ",
intval(local_user())
);
}
// Then fetch all the children of the parents that are on this page // Then fetch all the children of the parents that are on this page

View file

@ -158,9 +158,16 @@ function profile_content(&$a, $update = 0) {
if($update) { if($update) {
// only setup pagination on initial page view $r = q("SELECT distinct(parent) AS `item_id`, `contact`.`uid` AS `contact-uid`
$pager_sql = ''; FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
$update_sql = " AND unseen = 1 "; WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
and `item`.`parent` in (select parent from item where unseen = 1 )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`wall` = 1
$sql_extra
ORDER BY `item`.`created` DESC",
intval($a->profile['profile_uid'])
);
} }
else { else {
@ -180,23 +187,19 @@ function profile_content(&$a, $update = 0) {
} }
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
$update_sql = '';
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra
ORDER BY `item`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid'])
);
} }
$r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
$update_sql
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1
$sql_extra
ORDER BY `item`.`created` DESC $pager_sql ",
intval($a->profile['profile_uid'])
);
$parents_arr = array(); $parents_arr = array();
$parents_str = ''; $parents_str = '';