mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
enable filters and mark-all-seen button to forum notifications
This commit is contained in:
@@ -12,33 +12,51 @@ class Notifications extends \Zotlabs\Web\Controller {
|
||||
}
|
||||
|
||||
// ajax mark all unseen items read
|
||||
if(x($_REQUEST, 'markRead')) {
|
||||
if(isset($_REQUEST['markRead'])) {
|
||||
if (str_starts_with($_REQUEST['markRead'], 'forum_')) {
|
||||
$forum_id = substr($_REQUEST['markRead'], 6);
|
||||
|
||||
$abook = q("SELECT abook_xchan FROM abook WHERE abook_channel = %d AND abook_id = %d",
|
||||
intval(local_channel()),
|
||||
intval($forum_id)
|
||||
);
|
||||
|
||||
if ($abook) {
|
||||
q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND owner_xchan = '%s' AND item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)",
|
||||
intval(local_channel()),
|
||||
dbesc($abook[0]['abook_xchan'])
|
||||
);
|
||||
}
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
switch($_REQUEST['markRead']) {
|
||||
case 'dm':
|
||||
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_private = 2",
|
||||
q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_private = 2",
|
||||
intval(local_channel())
|
||||
);
|
||||
break;
|
||||
case 'network':
|
||||
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_private IN (0, 1)",
|
||||
q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_wall = 0 AND item_private IN (0, 1)",
|
||||
intval(local_channel())
|
||||
);
|
||||
break;
|
||||
case 'home':
|
||||
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1)",
|
||||
q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1 AND item_wall = 1 AND item_private IN (0, 1)",
|
||||
intval(local_channel())
|
||||
);
|
||||
break;
|
||||
case 'all_events':
|
||||
$evdays = intval(get_pconfig(local_channel(), 'system', 'evdays', 3));
|
||||
$r = q("UPDATE event SET dismissed = 1 WHERE uid = %d AND dismissed = 0 AND dtstart < '%s' AND dtstart > '%s' ",
|
||||
q("UPDATE event SET dismissed = 1 WHERE uid = %d AND dismissed = 0 AND dtstart < '%s' AND dtstart > '%s' ",
|
||||
intval(local_channel()),
|
||||
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + ' . intval($evdays) . ' days')),
|
||||
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
|
||||
);
|
||||
break;
|
||||
case 'notify':
|
||||
$r = q("UPDATE notify SET seen = 1 WHERE seen = 0 AND uid = %d",
|
||||
q("UPDATE notify SET seen = 1 WHERE seen = 0 AND uid = %d",
|
||||
intval(local_channel())
|
||||
);
|
||||
break;
|
||||
@@ -48,15 +66,17 @@ class Notifications extends \Zotlabs\Web\Controller {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
// ajax mark all comments of a parent item read
|
||||
if(x($_REQUEST, 'markItemRead') && local_channel()) {
|
||||
if(isset($_REQUEST['markItemRead']) && local_channel()) {
|
||||
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND parent = %d",
|
||||
intval(local_channel()),
|
||||
intval($_REQUEST['markItemRead'])
|
||||
);
|
||||
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class Notifications {
|
||||
'label' => t('Network stream')
|
||||
],
|
||||
'markall' => [
|
||||
'label' => t('Mark all read')
|
||||
'label' => t('Mark all seen')
|
||||
],
|
||||
'filter' => [
|
||||
'posts_label' => t('Conversation starters'),
|
||||
@@ -67,7 +67,7 @@ class Notifications {
|
||||
'label' => t('Private stream')
|
||||
],
|
||||
'markall' => [
|
||||
'label' => t('Mark all read')
|
||||
'label' => t('Mark all seen')
|
||||
],
|
||||
'filter' => [
|
||||
'posts_label' => t('Conversation starters'),
|
||||
@@ -132,7 +132,18 @@ class Notifications {
|
||||
'icon' => 'chat-quote',
|
||||
'severity' => 'secondary',
|
||||
'label' => $forum['xchan_name'],
|
||||
'title' => t('Unseen forum activity')
|
||||
'title' => t('Unseen forum activity'),
|
||||
'filter' => [
|
||||
'posts_label' => t('Conversation starters'),
|
||||
'name_label' => t('Filter by name or address')
|
||||
],
|
||||
'viewall' => [
|
||||
'url' => 'network?pf=1&cid=' . $forum['abook_id'],
|
||||
'label' => t('View all')
|
||||
],
|
||||
'markall' => [
|
||||
'label' => t('Mark all seen')
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
2
boot.php
2
boot.php
@@ -70,7 +70,7 @@ require_once('include/security.php');
|
||||
|
||||
|
||||
define('PLATFORM_NAME', 'hubzilla');
|
||||
define('STD_VERSION', '10.5.12');
|
||||
define('STD_VERSION', '10.5.13');
|
||||
define('ZOT_REVISION', '6.0');
|
||||
|
||||
define('DB_UPDATE_VERSION', 1264);
|
||||
|
||||
@@ -134,6 +134,8 @@
|
||||
|
||||
sse_bs_active = false;
|
||||
sse_partial_result = true;
|
||||
sse_offset = obj[sse_type].offset;
|
||||
|
||||
if (sse_offset < 0) {
|
||||
document.getElementById("nav-" + sse_type + "-loading").style.display = 'none';
|
||||
}
|
||||
@@ -197,11 +199,6 @@
|
||||
let menu = document.querySelector('#nav-{{$notification.type}}-menu');
|
||||
let notifications = menu.querySelectorAll('.notification[data-thread_top="false"]');
|
||||
|
||||
// Function to check if an element is visible
|
||||
function isVisible(el) {
|
||||
return el.offsetWidth > 0 && el.offsetHeight > 0;
|
||||
}
|
||||
|
||||
if (element.classList.contains('active') && element.classList.contains('sticky-top')) {
|
||||
notifications.forEach(function(notification) {
|
||||
notification.classList.remove('tt-filter-active');
|
||||
@@ -307,6 +304,11 @@
|
||||
});
|
||||
|
||||
|
||||
// Function to check if an element is visible
|
||||
function isVisible(el) {
|
||||
return el.offsetWidth > 0 && el.offsetHeight > 0;
|
||||
}
|
||||
|
||||
function sse_bs_init() {
|
||||
// Check if 'notification_open' exists in sessionStorage or if sse_type is defined
|
||||
if (sessionStorage.getItem('notification_open') !== null || typeof sse_type !== 'undefined') {
|
||||
@@ -492,7 +494,7 @@
|
||||
// Load more notifications if visible notifications count becomes low
|
||||
if (sse_type && sse_offset !== -1) {
|
||||
let menu = document.getElementById('nav-' + sse_type + '-menu');
|
||||
if (menu && menu.children.length < 15) {
|
||||
if (menu && Array.from(menu.querySelectorAll('.notification')).filter(isVisible).length < 15) {
|
||||
sse_bs_notifications(sse_type, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user