From 4f254ffb5b4a74482c6d70dc1858f20c13ee8c01 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 11 Dec 2011 20:32:43 -0800 Subject: [PATCH 01/12] system support for personal configurable ajax update interval --- boot.php | 7 ++++++- index.php | 16 ++++++++++------ js/main.js | 2 +- view/head.tpl | 2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/boot.php b/boot.php index 8452108ff1..60cdd326a4 100644 --- a/boot.php +++ b/boot.php @@ -422,6 +422,10 @@ class App { } function init_pagehead() { + $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 30000); + if($interval < 10000) + $interval = 30000; + $this->page['title'] = $this->config['sitename']; $tpl = file_get_contents('view/head.tpl'); $this->page['htmlhead'] = replace_macros($tpl,array( @@ -430,7 +434,8 @@ class App { '$delitem' => t('Delete this item?'), '$comment' => t('Comment'), '$showmore' => t('show more'), - '$showfewer' => t('show fewer') + '$showfewer' => t('show fewer'), + '$update_interval' => $interval )); } diff --git a/index.php b/index.php index e43d7332de..5f6d74adb9 100644 --- a/index.php +++ b/index.php @@ -93,12 +93,6 @@ if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) { load_translation_table($lang); } -/* - * Create the page head after setting the language - * - */ - -$a->init_pagehead(); /** * @@ -119,6 +113,16 @@ if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module == if(! x($_SESSION,'authenticated')) header('X-Account-Management-Status: none'); + +/* + * Create the page head after setting the language + * and getting any auth credentials + */ + +$a->init_pagehead(); + + + if(! x($_SESSION,'sysmsg')) $_SESSION['sysmsg'] = array(); diff --git a/js/main.js b/js/main.js index 829af2258f..3428886e70 100644 --- a/js/main.js +++ b/js/main.js @@ -204,7 +204,7 @@ }); }) ; } - timer = setTimeout(NavUpdate,30000); + timer = setTimeout(NavUpdate,updateInterval); } function liveUpdate() { diff --git a/view/head.tpl b/view/head.tpl index 055c3cef58..9fe5a63b3b 100644 --- a/view/head.tpl +++ b/view/head.tpl @@ -28,6 +28,8 @@ \r\n"; } - $o .= conversation($a,$r,'profile',$update); + + if($is_owner) { + $r = q("UPDATE `item` SET `unseen` = 0 + WHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", + intval(local_user()) + ); + } + + $o .= conversation($a,$items,'profile',$update); if(! $update) { $o .= paginate($a); From c45b903178f5dd0a6b98697db52de444c4a5d66a Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 16:11:03 -0800 Subject: [PATCH 07/12] live update improvements --- mod/network.php | 38 ++++++++++++++++++++++++-------------- mod/profile.php | 37 ++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/mod/network.php b/mod/network.php index 3a2d3cb8c3..e9e761c3ff 100644 --- a/mod/network.php +++ b/mod/network.php @@ -376,7 +376,6 @@ function network_content(&$a, $update = 0) { // only setup pagination on initial page view $pager_sql = ''; - $update_sql = " AND unseen = 1 "; } else { @@ -393,11 +392,11 @@ function network_content(&$a, $update = 0) { $a->set_pager_total($r[0]['total']); $a->set_pager_itemspage(40); } - $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) { // "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` FROM `item`, `contact` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - $update_sql + $simple_update AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra @@ -429,16 +428,27 @@ function network_content(&$a, $update = 0) { // Fetch a page full of parent items for this page - $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`.`parent` = `item`.`id` - $sql_extra - ORDER BY `item`.$ordering DESC $pager_sql ", - intval(local_user()) - ); + if($update) { + $r = q("SELECT distinct(`parent`) 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 `item`.`parent` in ( select parent from item where unseen = 1 ) + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 + $sql_extra ", + 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 diff --git a/mod/profile.php b/mod/profile.php index be608e3e90..b7f2c96624 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -158,9 +158,16 @@ function profile_content(&$a, $update = 0) { if($update) { - // only setup pagination on initial page view - $pager_sql = ''; - $update_sql = " AND unseen = 1 "; + $r = q("SELECT distinct(parent) 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 `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 { @@ -180,23 +187,19 @@ function profile_content(&$a, $update = 0) { } $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_str = ''; From 01cae9a50af5207f014c99f9a97b7b93d70eaaa2 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 16:28:33 -0800 Subject: [PATCH 08/12] remove all plugins from default config --- htconfig.php | 11 ----------- view/cs/htconfig.tpl | 7 +------ view/de/htconfig.tpl | 6 ------ view/en/htconfig.tpl | 6 ------ view/es/htconfig.tpl | 5 ----- view/fr/htconfig.tpl | 5 ----- view/it/htconfig.tpl | 5 ----- view/sv/htconfig.tpl | 6 ------ 8 files changed, 1 insertion(+), 50 deletions(-) diff --git a/htconfig.php b/htconfig.php index 0f9222ac59..89c226e9b4 100644 --- a/htconfig.php +++ b/htconfig.php @@ -69,14 +69,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; - - -// Disable oembed embedding -// This disable the conversion of [embed]$url[/embed] tag in html -// $a->config['system']['no_oembed'] = true; - diff --git a/view/cs/htconfig.tpl b/view/cs/htconfig.tpl index dca34f4824..87ded77fd8 100644 --- a/view/cs/htconfig.tpl +++ b/view/cs/htconfig.tpl @@ -1,4 +1,4 @@ -config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addony or pluginy se nastavují zde. -// Toto je list čárkou oddělených addonů, které jsou povoleny. Příklad: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; diff --git a/view/de/htconfig.tpl b/view/de/htconfig.tpl index 6eb9501309..c535cefa68 100644 --- a/view/de/htconfig.tpl +++ b/view/de/htconfig.tpl @@ -66,9 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; - diff --git a/view/en/htconfig.tpl b/view/en/htconfig.tpl index 6eb9501309..c535cefa68 100644 --- a/view/en/htconfig.tpl +++ b/view/en/htconfig.tpl @@ -66,9 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; - diff --git a/view/es/htconfig.tpl b/view/es/htconfig.tpl index ea8439ebb4..9f6e282aba 100644 --- a/view/es/htconfig.tpl +++ b/view/es/htconfig.tpl @@ -66,8 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; diff --git a/view/fr/htconfig.tpl b/view/fr/htconfig.tpl index 13ddab07ff..c535cefa68 100644 --- a/view/fr/htconfig.tpl +++ b/view/fr/htconfig.tpl @@ -66,8 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; diff --git a/view/it/htconfig.tpl b/view/it/htconfig.tpl index ea8439ebb4..9f6e282aba 100644 --- a/view/it/htconfig.tpl +++ b/view/it/htconfig.tpl @@ -66,8 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; diff --git a/view/sv/htconfig.tpl b/view/sv/htconfig.tpl index 6eb9501309..c535cefa68 100644 --- a/view/sv/htconfig.tpl +++ b/view/sv/htconfig.tpl @@ -66,9 +66,3 @@ $a->config['system']['rino_encrypt'] = true; $a->config['system']['theme'] = 'duepuntozero'; -// Addons or plugins are configured here. -// This is a comma seperated list of addons to enable. Example: -// $a->config['system']['addon'] = 'js_upload,randplace,oembed'; - -$a->config['system']['addon'] = 'js_upload'; - From e74a960327a0bf14ac3699fa9a28939ed22ae356 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 17:10:19 -0800 Subject: [PATCH 09/12] change default ajax interval to 40 seconds --- boot.php | 4 ++-- mod/settings.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index 2553642fcf..b02b0be982 100644 --- a/boot.php +++ b/boot.php @@ -422,9 +422,9 @@ class App { } function init_pagehead() { - $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 30000); + $interval = ((local_user()) ? get_pconfig(local_user(),'system','update_interval') : 40000); if($interval < 10000) - $interval = 30000; + $interval = 40000; $this->page['title'] = $this->config['sitename']; $tpl = file_get_contents('view/head.tpl'); diff --git a/mod/settings.php b/mod/settings.php index e88e50a05f..18e2d8ae6b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -227,7 +227,7 @@ function settings_post(&$a) { $browser_update = ((x($_POST,'browser_update')) ? intval($_POST['browser_update']) : 0); $browser_update = $browser_update * 1000; if($browser_update < 10000) - $browser_update = 30000; + $browser_update = 40000; $allow_location = (((x($_POST,'allow_location')) && (intval($_POST['allow_location']) == 1)) ? 1: 0); @@ -625,8 +625,8 @@ function settings_content(&$a) { $suggestme = get_pconfig(local_user(), 'system','suggestme'); $suggestme = (($suggestme===false)?0:$suggestme); // default if not set: 0 - $browser_update = get_pconfig(local_user(), 'system','update_interval'); - $browser_update = (($browser_update===false)? 30 : $browser_update / 1000); // default if not set: 30 seconds + $browser_update = intval(get_pconfig(local_user(), 'system','update_interval')); + $browser_update = (($browser_update===false)? 40 : $browser_update / 1000); // default if not set: 40 seconds if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); From e67f69df81eece3a829e62692420459778f05d5a Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 17:30:29 -0800 Subject: [PATCH 10/12] default ajax settings after conversion --- mod/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/settings.php b/mod/settings.php index 18e2d8ae6b..ad22ba1a60 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -626,7 +626,7 @@ function settings_content(&$a) { $suggestme = (($suggestme===false)?0:$suggestme); // default if not set: 0 $browser_update = intval(get_pconfig(local_user(), 'system','update_interval')); - $browser_update = (($browser_update===false)? 40 : $browser_update / 1000); // default if not set: 40 seconds + $browser_update = (($browser_update == 0) ? 40 : $browser_update / 1000); // default if not set: 40 seconds if(! strlen($a->user['timezone'])) $timezone = date_default_timezone_get(); From bda7ca2f36ba4b35a9094c08fda356d6f08e67f8 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 18:08:09 -0800 Subject: [PATCH 11/12] clearup update backlog after commenting --- js/main.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/js/main.js b/js/main.js index 2cbd985b26..3f84ae6c48 100644 --- a/js/main.js +++ b/js/main.js @@ -210,9 +210,15 @@ function liveUpdate() { if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').hide(); return; } if(($('.comment-edit-text-full').length) || (in_progress)) { + if(livetime) { + clearTimeout(livetime); + } livetime = setTimeout(liveUpdate, 10000); return; } + if(livetime != null) + livetime = null; + prev = 'live-' + src; in_progress = true; From ee4975f1cd9f205e2300f3e22e51079c5e26f155 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 12 Dec 2011 19:08:13 -0800 Subject: [PATCH 12/12] unnecessary slash in profile update path --- mod/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/profile.php b/mod/profile.php index b7f2c96624..642e198b79 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -236,7 +236,7 @@ function profile_content(&$a, $update = 0) { $o .= '
' . "\r\n"; $o .= "\r\n"; + . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; \r\n"; }