do not show seen notifys in notifications - show them in mod notifications instead. Update notifications count also on notifications updates
This commit is contained in:
parent
c80f4feb62
commit
0061ac8584
@ -12,25 +12,44 @@ class Notifications extends \Zotlabs\Web\Controller {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav_set_selected('notifications');
|
nav_set_selected('Notifications');
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
$r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc",
|
$r = q("select count(*) as total from notify where uid = %d and seen = 0",
|
||||||
intval(local_channel())
|
intval(local_channel())
|
||||||
);
|
);
|
||||||
|
if($r && intval($t[0]['total']) > 49) {
|
||||||
|
$r = q("select * from notify where uid = %d
|
||||||
|
and seen = 0 order by created desc limit 50",
|
||||||
|
intval(local_channel())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$r1 = q("select * from notify where uid = %d
|
||||||
|
and seen = 0 order by created desc limit 50",
|
||||||
|
intval(local_channel())
|
||||||
|
);
|
||||||
|
$r2 = q("select * from notify where uid = %d
|
||||||
|
and seen = 1 order by created desc limit %d",
|
||||||
|
intval(local_channel()),
|
||||||
|
intval(50 - intval($t[0]['total']))
|
||||||
|
);
|
||||||
|
$r = array_merge($r1,$r2);
|
||||||
|
}
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
$notifications_available = 1;
|
$notifications_available = 1;
|
||||||
foreach ($r as $it) {
|
foreach ($r as $rr) {
|
||||||
$x = strip_tags(bbcode($it['msg']));
|
$x = strip_tags(bbcode($rr['msg']));
|
||||||
if(strpos($x,','))
|
if(strpos($x,','))
|
||||||
$x = substr($x,strpos($x,',')+1);
|
$x = substr($x,strpos($x,',')+1);
|
||||||
$notif_content .= replace_macros(get_markup_template('notify.tpl'),array(
|
$notif_content .= replace_macros(get_markup_template('notify.tpl'),array(
|
||||||
'$item_link' => z_root().'/notify/view/'. $it['id'],
|
'$item_link' => z_root().'/notify/view/'. $rr['id'],
|
||||||
'$item_image' => $it['photo'],
|
'$item_image' => $rr['photo'],
|
||||||
'$item_text' => $x,
|
'$item_text' => $x,
|
||||||
'$item_when' => relative_date($it['created'])
|
'$item_when' => relative_date($rr['created']),
|
||||||
|
'$item_seen' => (($rr['seen']) ? true : false),
|
||||||
|
'$new' => t('New')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,37 +258,20 @@ class Ping extends \Zotlabs\Web\Controller {
|
|||||||
* dropdown menu.
|
* dropdown menu.
|
||||||
*/
|
*/
|
||||||
if(argc() > 1 && argv(1) === 'notify') {
|
if(argc() > 1 && argv(1) === 'notify') {
|
||||||
$t = q("select count(*) as total from notify where uid = %d and seen = 0",
|
$t = q("select * from notify where uid = %d and seen = 0 order by created desc",
|
||||||
intval(local_channel())
|
intval(local_channel())
|
||||||
);
|
);
|
||||||
if($t && intval($t[0]['total']) > 49) {
|
|
||||||
$z = q("select * from notify where uid = %d
|
|
||||||
and seen = 0 order by created desc limit 50",
|
|
||||||
intval(local_channel())
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$z1 = q("select * from notify where uid = %d
|
|
||||||
and seen = 0 order by created desc limit 50",
|
|
||||||
intval(local_channel())
|
|
||||||
);
|
|
||||||
$z2 = q("select * from notify where uid = %d
|
|
||||||
and seen = 1 order by created desc limit %d",
|
|
||||||
intval(local_channel()),
|
|
||||||
intval(50 - intval($t[0]['total']))
|
|
||||||
);
|
|
||||||
$z = array_merge($z1,$z2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($z)) {
|
if($t) {
|
||||||
foreach($z as $zz) {
|
foreach($t as $tt) {
|
||||||
$notifs[] = array(
|
$notifs[] = array(
|
||||||
'notify_link' => z_root() . '/notify/view/' . $zz['id'],
|
'notify_link' => z_root() . '/notify/view/' . $tt['id'],
|
||||||
'name' => $zz['xname'],
|
'name' => $tt['xname'],
|
||||||
'url' => $zz['url'],
|
'url' => $tt['url'],
|
||||||
'photo' => $zz['photo'],
|
'photo' => $tt['photo'],
|
||||||
'when' => relative_date($zz['created']),
|
'when' => relative_date($tt['created']),
|
||||||
'hclass' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'),
|
'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'),
|
||||||
'message' => strip_tags(bbcode($zz['msg']))
|
'message' => strip_tags(bbcode($tt['msg']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -946,6 +946,7 @@ function notify_popup_loader(notifyType) {
|
|||||||
|
|
||||||
$("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark);
|
$("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark);
|
||||||
$("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark);
|
$("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark);
|
||||||
|
$("." + notifyType + "-update").html(data.notify.length);
|
||||||
|
|
||||||
$(data.notify).each(function() {
|
$(data.notify).each(function() {
|
||||||
html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass);
|
html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass);
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
<div class="mb-2 notif-item">
|
<div class="mb-4 notif-item">
|
||||||
<a href="{{$item_link}}"><img src="{{$item_image}}" class="menu-img-1">{{$item_text}} <span class="notif-when">{{$item_when}}</span></a>
|
{{if ! $item_seen}}
|
||||||
|
<span class="float-right badge badge-pill badge-success text-uppercase">{{$new}}</span>
|
||||||
|
{{/if}}
|
||||||
|
<a href="{{$item_link}}">
|
||||||
|
<img src="{{$item_image}}" class="menu-img-3">
|
||||||
|
<span class="{{if $item_seen}}text-muted{{/if}}">{{$item_text}}</span><br>
|
||||||
|
<span class="dropdown-sub-text">{{$item_when}}</span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user