notificaiton: handle remove addressee and reset at the end of registering unread

This commit is contained in:
Julien Fastré 2021-12-28 23:31:33 +01:00
parent cb88a37885
commit a0b112e8db

View File

@ -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