Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-06-04 16:19:19 +0300
committerJoas Schilling <coding@schilljs.com>2020-07-09 12:37:49 +0300
commit429305bb8aaedac3c9176d81b58368a34e492ae1 (patch)
tree520c1b26d51e0bd5cd4c4e5f3b31ec037347384c /lib/Notification
parent78836260e467bba23bd827c6d4184a75b4208c63 (diff)
Defer sending the notifications when we interact multiple times
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification')
-rw-r--r--lib/Notification/Listener.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php
index ec832633d..67ab8aa68 100644
--- a/lib/Notification/Listener.php
+++ b/lib/Notification/Listener.php
@@ -121,6 +121,7 @@ class Listener {
$actorId = $actor->getUID();
$notification = $this->notificationManager->createNotification();
+ $shouldFlush = $this->notificationManager->defer();
$dateTime = $this->timeFactory->getDateTime();
try {
$notification->setApp('spreed')
@@ -131,6 +132,9 @@ class Listener {
]);
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'spreed']);
+ if ($shouldFlush) {
+ $this->notificationManager->flush();
+ }
return;
}
@@ -147,6 +151,10 @@ class Listener {
$this->logger->logException($e, ['app' => 'spreed']);
}
}
+
+ if ($shouldFlush) {
+ $this->notificationManager->flush();
+ }
}
/**
@@ -206,8 +214,8 @@ class Listener {
$actor = $this->userSession->getUser();
$actorId = $actor instanceof IUser ? $actor->getUID() :'';
- $this->dispatcher->dispatch(IApp::class . '::defer', new Event());
$notification = $this->notificationManager->createNotification();
+ $shouldFlush = $this->notificationManager->defer();
$dateTime = $this->timeFactory->getDateTime();
try {
// Remove all old notifications for this room
@@ -224,7 +232,9 @@ class Listener {
->setDateTime($dateTime);
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, ['app' => 'spreed']);
- $this->dispatcher->dispatch(IApp::class . '::flush', new Event());
+ if ($shouldFlush) {
+ $this->notificationManager->flush();
+ }
return;
}
@@ -241,7 +251,10 @@ class Listener {
$this->logger->logException($e, ['app' => 'spreed']);
}
}
- $this->dispatcher->dispatch(IApp::class . '::flush', new Event());
+
+ if ($shouldFlush) {
+ $this->notificationManager->flush();
+ }
}
/**