merge and add opened comment view

This commit is contained in:
isUnknown 2024-10-29 16:13:07 +01:00
parent c3860d4a38
commit 4e4216f8d3
6 changed files with 164 additions and 134 deletions

View file

@ -12,11 +12,11 @@ Template: document
Comments:
m2u905al:
m2ucagze:
pageUri: >
projects/miss-dior-blooming-bouquet/client-brief
fileUuid: file://s0lNtRA0Z7ybTCWG
filePageTarget: 1
filePageIndex: 1
position:
x: null
y: null
@ -27,22 +27,22 @@ m2u905al:
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-29T10:31:23+01:00
id: m2u905al
m2u955a7:
date: 2024-10-29T12:03:24+01:00
id: m2ucagze
m2ucgaoe:
pageUri: >
projects/miss-dior-blooming-bouquet/client-brief
fileUuid: file://s0lNtRA0Z7ybTCWG
filePageTarget: 1
filePageIndex: 1
position:
x: null
y: null
replies: [ ]
text: come2
text: Deuxième commentaire
user:
name: Adrien Payet
email: adrien.payet@outlook.com
uuid: user://WWjXgPWk
role: admin
date: 2024-10-29T10:35:16+01:00
id: m2u955a7
date: 2024-10-29T12:07:55+01:00
id: m2ucgaoe

View file

@ -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);
}

View 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;
};

View 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);
}
}
};