diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index d7e7075ed..61c1c5926 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -196,13 +196,27 @@ class Notification $this->addUnreadBy($addressee); } + foreach ($this->removedAddresses as $addressee) { + $this->removeAddressee($addressee); + } + if (null !== $this->addressesOnLoad) { foreach ($this->addressees as $existingAddresse) { if (!$this->addressesOnLoad->contains($existingAddresse)) { $this->addUnreadBy($existingAddresse); } } + + foreach ($this->addressesOnLoad as $onLoadAddressee) { + if (!$this->addressees->contains($onLoadAddressee)) { + $this->removeUnreadBy($onLoadAddressee); + } + } } + + $this->removedAddresses = []; + $this->addedAddresses = []; + $this->addressesOnLoad = null; } public function removeAddressee(User $addressee): self