Bsitu has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/153702

Change subject: Move 'notification count refresh' logic out of mapper
......................................................................

Move 'notification count refresh' logic out of mapper

Change-Id: I4c10b66e537dea5f9c5bc7ccba8f558cafd103d7
---
M includes/mapper/NotificationMapper.php
M model/Notification.php
2 files changed, 7 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo 
refs/changes/02/153702/1

diff --git a/includes/mapper/NotificationMapper.php 
b/includes/mapper/NotificationMapper.php
index 8d359f1..4d0a5cd 100644
--- a/includes/mapper/NotificationMapper.php
+++ b/includes/mapper/NotificationMapper.php
@@ -41,9 +41,6 @@
                        $dbw->endAtomic( $fname );
 
                        if ( $res ) {
-                               // @Todo - move the reset notification count 
logic to a listener
-                               $user = User::newFromId( 
$row['notification_user'] );
-                               MWEchoNotifUser::newFromUser( $user 
)->resetNotificationCount( DB_MASTER );
                                foreach ( $listeners as $listener ) {
                                        call_user_func( $listener );
                                }
diff --git a/model/Notification.php b/model/Notification.php
index cd1d73e..24aad9d 100644
--- a/model/Notification.php
+++ b/model/Notification.php
@@ -150,6 +150,13 @@
                        } );
                }
 
+               // Add listener to refresh notification count upon insert
+               $notifMapper->attachListener( 'insert', 'refresh-notif-count',
+                       function() use ( $user ) {
+                               MWEchoNotifUser::newFromUser( $user 
)->resetNotificationCount( DB_MASTER );
+                       }
+               );
+
                $notifMapper->insert( $this );
 
                // Clear applicable section status from cache upon new 
notification creation

-- 
To view, visit https://gerrit.wikimedia.org/r/153702
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c10b66e537dea5f9c5bc7ccba8f558cafd103d7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to