merge and add opened comment view
This commit is contained in:
parent
c3860d4a38
commit
4e4216f8d3
6 changed files with 164 additions and 134 deletions
|
|
@ -17,7 +17,7 @@ return [
|
|||
$newComment = [
|
||||
'pageUri' => $data->pageUri,
|
||||
'fileUuid' => (string) $file->uuid(),
|
||||
'filePageTarget' => $data->targetPage,
|
||||
'filePageIndex' => $data->filePageIndex,
|
||||
'position' => [
|
||||
'x' => null,
|
||||
'y' => null
|
||||
|
|
@ -40,7 +40,7 @@ return [
|
|||
'comments' => $comments
|
||||
]);
|
||||
|
||||
$user->sendNotification('comments', $newComment);
|
||||
// $user->sendNotification('comments', $newComment);
|
||||
|
||||
return getFileData($newFile);
|
||||
}
|
||||
|
|
|
|||
16
public/site/plugins/notifications/user-methods/read.php
Normal file
16
public/site/plugins/notifications/user-methods/read.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
return function ($group, $notificationId) {
|
||||
$notifications = Yaml::decode($this->notifications()->value());
|
||||
|
||||
try {
|
||||
$notifications[$group][$notificationId]['isRead'] = true;
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
}
|
||||
|
||||
$this->update([
|
||||
"notifications" => $notifications
|
||||
]);
|
||||
return $notifications;
|
||||
};
|
||||
26
public/site/plugins/notifications/user-methods/send.php
Normal file
26
public/site/plugins/notifications/user-methods/send.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
return function ($group, $data) {
|
||||
foreach (kirby()->users()->not($this) as $otherUser) {
|
||||
try {
|
||||
$notifications = $otherUser->notifications()->isNotEmpty()
|
||||
? Yaml::decode($otherUser->notifications()->value())
|
||||
: [];
|
||||
|
||||
if (!isset($notifications[$group])) {
|
||||
$notifications[$group] = [];
|
||||
}
|
||||
|
||||
|
||||
$data['isRead'] = false;
|
||||
|
||||
$notifications[$group][$data['id']] = $data;
|
||||
|
||||
$otherUser->update([
|
||||
'notifications' => $notifications
|
||||
]);
|
||||
} catch (\Throwable $th) {
|
||||
throw new Exception("Error updating notifications: " . $th->getMessage() . ' line ' . $th->getLine(), 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue