read comment notification working
This commit is contained in:
parent
9222069ef5
commit
246d21f85a
17 changed files with 86 additions and 111 deletions
|
|
@ -31,7 +31,36 @@ class NotificationsPage extends Page {
|
|||
}
|
||||
|
||||
$this->update([
|
||||
'notifications' => Yaml::encode(array_values($notifications))
|
||||
'notifications' => $notifications
|
||||
]);
|
||||
}
|
||||
|
||||
public function readNotification($notificationId) {
|
||||
$notifications = $this->notifications()->isNotEmpty()
|
||||
? Yaml::decode($this->notifications()->value())
|
||||
: [];
|
||||
|
||||
foreach ($notifications as $key => &$notification) {
|
||||
if ($notification['id'] !== $notificationId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($notification["readby"])) {
|
||||
$notification["readby"] = [];
|
||||
}
|
||||
|
||||
$userUuid = (string) kirby()->user()->uuid();
|
||||
if (in_array($userUuid, $notification["readby"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notification["readby"][] = $userUuid;
|
||||
break;
|
||||
}
|
||||
|
||||
$this->update([
|
||||
'notifications' => Yaml::encode($notifications)
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue