Added update ball notifications
Former-commit-id: 60c253a1b64d1084ae732e88e0a6fb1f98cf8a12
This commit is contained in:
parent
1223ce69da
commit
17c012cd83
|
@ -425,7 +425,22 @@ config_check();
|
|||
"last_id": last_id
|
||||
},
|
||||
function (data, status) {
|
||||
if(!data.has_new_notifications) return;
|
||||
// Substitute the ball
|
||||
var new_ball = atob(data.new_ball);
|
||||
var ball_wrapper = document
|
||||
.getElementById('notification-ball-header')
|
||||
.parentElement;
|
||||
if (ball_wrapper === null) {
|
||||
console.error('Cannot update notification ball');
|
||||
return;
|
||||
}
|
||||
ball_wrapper.innerHTML = new_ball;
|
||||
|
||||
// Show the toasts
|
||||
//TODO
|
||||
|
||||
|
||||
},
|
||||
"json"
|
||||
)
|
||||
|
|
|
@ -98,15 +98,20 @@ if (get_parameter('check_new_notifications', 0)) {
|
|||
$last_id_ui = (int) get_parameter('last_id', 0);
|
||||
$counters = notifications_get_counters();
|
||||
if ((int) $last_id_ui === (int) $counters['last_id']) {
|
||||
echo json_encode(['new_notifications' => []]);
|
||||
echo json_encode(['has_new_notifications' => false]);
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is new messages, get the info.
|
||||
echo json_encode(
|
||||
[
|
||||
'notifications' => $counters['notifications'],
|
||||
'last_id' => $counters['last_id'],
|
||||
'has_new_notifications' => true,
|
||||
'new_ball' => base64_encode(
|
||||
notifications_print_ball(
|
||||
$counters['notifications'],
|
||||
$counters['last_id']
|
||||
)
|
||||
),
|
||||
'new_notifications' => messages_get_overview(
|
||||
'timestamp',
|
||||
'ASC',
|
||||
|
|
Loading…
Reference in New Issue