Move 'notification count refresh' logic out of mapper

Change-Id: I4c10b66e537dea5f9c5bc7ccba8f558cafd103d7
This commit is contained in:
bsitu 2014-08-12 13:37:04 -07:00 committed by Matthias Mullie
parent 32dd2e314b
commit 1cc0f83829
2 changed files with 7 additions and 3 deletions

View file

@ -41,9 +41,6 @@ class EchoNotificationMapper extends EchoAbstractMapper {
$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 );
}

View file

@ -144,6 +144,13 @@ class EchoNotification extends EchoAbstractEntity {
} );
}
// 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