aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ItemObject.php24
-rw-r--r--mod/channel.php34
-rw-r--r--mod/network.php29
-rw-r--r--mod/ping.php30
-rw-r--r--version.inc2
-rw-r--r--view/js/main.js7
-rwxr-xr-xview/tpl/conv_list.tpl3
7 files changed, 102 insertions, 27 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 4aa6857c1..6f1c76fa1 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -79,6 +79,7 @@ class Item extends BaseObject {
$indent = '';
$osparkle = '';
$total_children = $this->count_descendants();
+ $unseen_comments = (($item->real_uid) ? 0 : $this->count_unseen_descendants());
$conv = $this->get_conversation();
$observer = $conv->get_observer();
@@ -233,6 +234,8 @@ class Item extends BaseObject {
$comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
+ $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : '');
+
$children = $this->get_children();
$tmp_item = array(
@@ -290,8 +293,12 @@ class Item extends BaseObject {
'drop' => $drop,
'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''),
// end toolbar buttons
+
+ 'unseen_comments' => $unseen_comments,
'comment_count' => $total_children,
'comment_count_txt' => $comment_count_txt,
+ 'list_unseen_txt' => $list_unseen_txt,
+ 'markseen' => t('Mark all seen'),
'like_count' => $like_count,
'like_list' => $like_list,
'like_list_part' => $like_list_part,
@@ -545,6 +552,23 @@ class Item extends BaseObject {
return $total;
}
+ private function count_unseen_descendants() {
+ $children = $this->get_children();
+ $total = count($children);
+ if($total > 0) {
+ $total = 0;
+ foreach($children as $child) {
+ if((! visible_activity($child->data)) || array_key_exists('author_blocked',$child->data)) {
+ continue;
+ }
+ if($child->data['item_flags'] & ITEM_UNSEEN)
+ $total ++;
+ }
+ }
+ return $total;
+ }
+
+
/**
* Get the template for the comment box
*/
diff --git a/mod/channel.php b/mod/channel.php
index 1cc2dc02c..b91b6bcef 100644
--- a/mod/channel.php
+++ b/mod/channel.php
@@ -137,6 +137,11 @@ function channel_content(&$a, $update = 0, $load = false) {
$sql_extra = item_permissions_sql($a->profile['profile_uid'],$remote_contact,$groups);
+ if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode'))
+ $page_mode = 'list';
+ else
+ $page_mode = 'client';
+
if(($update) && (! $load)) {
if ($mid) {
@@ -279,12 +284,31 @@ function channel_content(&$a, $update = 0, $load = false) {
}
+ $update_unseen = '';
+ if($page_mode === 'list') {
- if($is_owner) {
+ /**
+ * in "list mode", only mark the parent item and any like activities as "seen".
+ * We won't distinguish between comment likes and post likes. The important thing
+ * is that the number of unseen comments will be accurate. The SQL to separate the
+ * comment likes could also get somewhat hairy.
+ */
+ if($parents_str) {
+ $update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )";
+ $update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) ";
+ }
+ }
+ else {
+ if($parents_str) {
+ $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )";
+ }
+ }
+
+ if($is_owner && $update_unseen) {
$r = q("UPDATE item SET item_flags = (item_flags & ~%d)
- WHERE (item_flags & %d)>0 AND (item_flags & %d)>0 AND uid = %d ",
+ WHERE (item_flags & %d) > 0 AND (item_flags & %d) > 0 AND uid = %d $update_unseen",
intval(ITEM_UNSEEN),
intval(ITEM_UNSEEN),
intval(ITEM_WALL),
@@ -293,12 +317,6 @@ function channel_content(&$a, $update = 0, $load = false) {
}
- if(get_pconfig($a->profile['profile_uid'],'system','channel_list_mode'))
- $page_mode = 'list';
- else
- $page_mode = 'client';
-
-
if($_COOKIE['jsAvailable'] == 1) {
$o .= conversation($a,$items,'channel',$update,$page_mode);
} else {
diff --git a/mod/network.php b/mod/network.php
index d6c19eca7..c79ff8d6a 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -317,6 +317,11 @@ function network_content(&$a, $update = 0, $load = false) {
$uids = " and item.uid = " . local_user() . " ";
}
+ if(get_pconfig(local_user(),'system','network_list_mode'))
+ $page_mode = 'list';
+ else
+ $page_mode = 'client';
+
$simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : '');
// This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day
@@ -414,9 +419,25 @@ function network_content(&$a, $update = 0, $load = false) {
$items = array();
}
- if($parents_str)
- $update_unseen = ' AND parent IN ( ' . dbesc($parents_str) . ' )';
+ if($page_mode === 'list') {
+
+ /**
+ * in "list mode", only mark the parent item and any like activities as "seen".
+ * We won't distinguish between comment likes and post likes. The important thing
+ * is that the number of unseen comments will be accurate. The SQL to separate the
+ * comment likes could also get somewhat hairy.
+ */
+ if($parents_str) {
+ $update_unseen = " AND ( id IN ( " . dbesc($parents_str) . " )";
+ $update_unseen .= " OR ( parent IN ( " . dbesc($parents_str) . " ) AND verb in ( '" . dbesc(ACTIVITY_LIKE) . "','" . dbesc(ACTIVITY_DISLIKE) . "' ))) ";
+ }
+ }
+ else {
+ if($parents_str) {
+ $update_unseen = " AND parent IN ( " . dbesc($parents_str) . " )";
+ }
+ }
}
if(($update_unseen) && (! $firehose))
@@ -429,10 +450,6 @@ function network_content(&$a, $update = 0, $load = false) {
$mode = (($nouveau) ? 'network-new' : 'network');
- if(get_pconfig(local_user(),'system','network_list_mode'))
- $page_mode = 'list';
- else
- $page_mode = 'client';
$o .= conversation($a,$items,$mode,$update,$page_mode);
diff --git a/mod/ping.php b/mod/ping.php
index d7b9e3d2e..451370779 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -150,14 +150,14 @@ function ping_init(&$a) {
if(x($_REQUEST, 'markRead') && local_user()) {
switch($_REQUEST['markRead']) {
case 'network':
- $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d)>0 and uid = %d",
+ $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and uid = %d",
intval(ITEM_UNSEEN),
intval(ITEM_UNSEEN),
intval(local_user())
);
break;
case 'home':
- $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d)>0 and (item_flags & %d) and uid = %d",
+ $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and (item_flags & %d) > 0 and uid = %d",
intval(ITEM_UNSEEN),
intval(ITEM_UNSEEN),
intval(ITEM_WALL),
@@ -165,14 +165,14 @@ function ping_init(&$a) {
);
break;
case 'messages':
- $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d)>0",
+ $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d) > 0",
intval(MAIL_SEEN),
intval(local_user()),
intval(MAIL_SEEN)
);
break;
case 'all_events':
- $r = q("update event set `ignore` = 1 where `ignore` = 0 and uid = %d",
+ $r = q("update event set ignore = 1 where ignore = 0 and uid = %d",
intval(local_user())
);
break;
@@ -186,6 +186,14 @@ function ping_init(&$a) {
}
}
+ if(x($_REQUEST, 'markItemRead') && local_user()) {
+ $r = q("update item set item_flags = ( item_flags & ~%d ) where parent = %d and uid = %d",
+ intval(ITEM_UNSEEN),
+ intval($_REQUEST['markItemRead']),
+ intval(local_user())
+ );
+ }
+
/**
@@ -237,7 +245,7 @@ function ping_init(&$a) {
if(argc() > 1 && argv(1) === 'messages') {
$channel = $a->get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
- where channel_id = %d and not ( mail_flags & %d )>0 and not (mail_flags & %d )>0
+ where channel_id = %d and not ( mail_flags & %d ) > 0 and not (mail_flags & %d ) > 0
and from_xchan != '%s' order by created desc limit 50",
intval(local_user()),
intval(MAIL_SEEN),
@@ -267,7 +275,7 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = %d and ( item_flags & %d )>0 and uid = %d",
+ WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
@@ -289,7 +297,7 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0)",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -373,7 +381,7 @@ function ping_init(&$a) {
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
$r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE (item_restrict = %d) and ( item_flags & %d )>0 and uid = %d",
+ WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
@@ -400,7 +408,7 @@ function ping_init(&$a) {
$t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) {
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) > 0 and not ((abook_flags & %d) > 0 or (xchan_flags & %d) > 0)",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -418,7 +426,7 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d)>0 and from_xchan != '%s' ",
+ WHERE channel_id = %d AND not (mail_flags & %d) > 0 and from_xchan != '%s' ",
intval(local_user()),
intval(MAIL_SEEN),
dbesc($channel['channel_hash'])
@@ -429,7 +437,7 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_REGISTER) {
if ($a->config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
- $regs = q("SELECT count(account_id) as total from account where (account_flags & %d)>0",
+ $regs = q("SELECT count(account_id) as total from account where (account_flags & %d) > 0",
intval(ACCOUNT_PENDING)
);
if($regs)
diff --git a/version.inc b/version.inc
index 664554361..d1f09608f 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2014-11-16.861
+2014-11-17.862
diff --git a/view/js/main.js b/view/js/main.js
index bec35ba72..9b5c1b1b2 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -180,6 +180,13 @@
timer = setTimeout(NavUpdate,2000);
}
+ function markItemRead(itemId) {
+ $.get('ping?f=&markItemRead='+itemId);
+ $('.unseen-wall-indicator-'+itemId).hide();
+ }
+
+
+
var src = null;
var prev = null;
var livetime = null;
diff --git a/view/tpl/conv_list.tpl b/view/tpl/conv_list.tpl
index 71554a9b3..b9a966e93 100755
--- a/view/tpl/conv_list.tpl
+++ b/view/tpl/conv_list.tpl
@@ -164,7 +164,8 @@
{{/if}}
</div>
<div class="clear"></div>
- <div class="wall-item-list-comments"><a href="{{$item.llink}}">{{$item.comment_count_txt}}</a></div>
+ <div class="wall-item-list-comments"><a href="{{$item.llink}}">{{$item.comment_count_txt}}{{if $item.unseen_comments}}
+<span class="unseen-wall-indicator-{{$item.id}}">, {{$item.list_unseen_txt}}{{/if}}</span></a>{{if $item.unseen_comments}}<span class="unseen-wall-indicator-{{$item.id}}">&nbsp;&nbsp;&nbsp;<button class="btn btn-default" title="{{$item.markseen}}" onclick="markItemRead({{$item.id}}); return false;"><i class="icon-check"></i></span>{{/if}}</div>
</div>
<div class="wall-item-wrapper-end"></div>
<div class="wall-item-outside-wrapper-end {{$item.indent}}" ></div>