aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorwinter2025-03-21 21:29:53 +0000
committerwinter2025-03-21 21:29:53 +0000
commit9a6a54e2d6a6f7bff8ca5467c8a2680f4ad735fb (patch)
treee3ad375ec978eadfef4df1719cd89877128109db
parent5e8fa866d9c390e8f364ae9de8cd94bb5a832751 (diff)
add timestamps to notifications
-rw-r--r--routes/notifications.php5
-rw-r--r--static/notifications.css6
-rw-r--r--templates/notification.php3
-rw-r--r--templates/notifications_panel.php7
4 files changed, 16 insertions, 5 deletions
diff --git a/routes/notifications.php b/routes/notifications.php
index 11a73fb..a8949e4 100644
--- a/routes/notifications.php
+++ b/routes/notifications.php
@@ -13,8 +13,8 @@ Router::getInstance()->mount('/notifications/partial', function (array $args) {
$when = new \DateTimeImmutable($_GET['since']);
$notifs = Notification::findAllForUser($user, since: $when);
- foreach ($notifs as $notif) {
- $notif = $notif->toNotifyable();
+ foreach ($notifs as $notification) {
+ $notif = $notification->toNotifyable();
if ($notif == null)
continue;
render_template('notification', [
@@ -23,6 +23,7 @@ Router::getInstance()->mount('/notifications/partial', function (array $args) {
'imageUrl' => $notif->getNotificationImageUrl(),
'titleLink' => $notif->getNotificationTitleLink(),
'imageLink' => $notif->getNotificationImageLink(),
+ 'timestamp' => $notification->created,
'unread' => true
]);
}
diff --git a/static/notifications.css b/static/notifications.css
index 9935313..3e7a434 100644
--- a/static/notifications.css
+++ b/static/notifications.css
@@ -66,5 +66,11 @@
mask-image: none;
}
}
+ .notifTimestamp {
+ text-align: end;
+ grid-column: 1 / 3;
+ font-size: var(--font-small-size);
+ color: var(--clr-lesser-foreground);
+ }
}
}
diff --git a/templates/notification.php b/templates/notification.php
index 0b105bd..0a54a6f 100644
--- a/templates/notification.php
+++ b/templates/notification.php
@@ -20,6 +20,9 @@
<?php endif; ?>
<span class="body"><?= htmlspecialchars($body, double_encode: false) ?></span>
</div>
+ <div class="notifTimestamp">
+ <?= format_datetime($timestamp) ?>
+ </div>
<div hidden class="notifier" <?php if ($unread ?? false): ?> _="
on load
set title to innerText of previous .title
diff --git a/templates/notifications_panel.php b/templates/notifications_panel.php
index 574a295..4a671b1 100644
--- a/templates/notifications_panel.php
+++ b/templates/notifications_panel.php
@@ -12,8 +12,8 @@ $notifications = Notification::findAllForUser($user, 50);
if (count($notifications) <= 0) {
call_template('placeholder_text');
}
- foreach ($notifications as $notif) {
- $notif = $notif->toNotifyable();
+ foreach ($notifications as $notification) {
+ $notif = $notification->toNotifyable();
if ($notif == null)
continue;
call_template('notification', [
@@ -21,7 +21,8 @@ $notifications = Notification::findAllForUser($user, 50);
'body' => $notif->getNotificationBody(),
'imageUrl' => $notif->getNotificationImageUrl(),
'titleLink' => $notif->getNotificationTitleLink(),
- 'imageLink' => $notif->getNotificationImageLink()
+ 'imageLink' => $notif->getNotificationImageLink(),
+ 'timestamp' => $notification->created
]);
}
?>