Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(backend): Reset document session and yjs file when file is deleted
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Mar 13, 2024
commit 02c1e083c8a28ef50797b6c688c4c66226ec1e7c
9 changes: 7 additions & 2 deletions lib/Listeners/BeforeNodeDeletedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace OCA\Text\Listeners;

use OCA\Text\Service\AttachmentService;
use OCA\Text\Service\DocumentService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
Expand All @@ -35,10 +36,13 @@
* @template-implements IEventListener<Event|BeforeNodeDeletedEvent>
*/
class BeforeNodeDeletedListener implements IEventListener {
private $attachmentService;
private AttachmentService $attachmentService;
private DocumentService $documentService;

public function __construct(AttachmentService $attachmentService) {
public function __construct(AttachmentService $attachmentService,
DocumentService $documentService) {
$this->attachmentService = $attachmentService;
$this->documentService = $documentService;
}

public function handle(Event $event): void {
Expand All @@ -48,6 +52,7 @@ public function handle(Event $event): void {
$node = $event->getNode();
if ($node instanceof File && $node->getMimeType() === 'text/markdown') {
$this->attachmentService->deleteAttachments($node);
$this->documentService->resetDocument($node->getId(), true);
}
}
}