-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
- Loading branch information
Showing
4 changed files
with
13 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
lib/Event/MoveToTrashListener.php → lib/Listener/CacheEntryRemovedListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
<?php | ||
|
||
namespace OCA\Photos\Event; | ||
namespace OCA\Photos\Listener; | ||
|
||
use OCA\Photos\Album\AlbumMapper; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use OCP\Files\Events\Node\NodeDeletedEvent; | ||
use OCA\Photos\Album\AlbumMapper; | ||
use OCP\Files\Cache\CacheEntryRemovedEvent; | ||
|
||
class MoveToTrashListener implements IEventListener { | ||
class CacheEntryRemovedListener implements IEventListener { | ||
private AlbumMapper $albumMapper; | ||
|
||
public function __construct(AlbumMapper $albumMapper) { | ||
$this->albumMapper = $albumMapper; | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof NodeDeletedEvent)) { | ||
if (!($event instanceof CacheEntryRemovedEvent)) { | ||
return; | ||
} | ||
|
||
// Remove node from all albums containing it. | ||
$albums = $this->albumMapper->getForFile($event->getNode()->getId()); | ||
$albums = $this->albumMapper->getForFile($event->getFileId()); | ||
foreach ($albums as $album) { | ||
$this->albumMapper->removeFile($album->getId(), $event->getNode()->getId()); | ||
$this->albumMapper->removeFile($album->getId(), $event->getFileId()); | ||
} | ||
} | ||
} |