Kmuthu has uploaded a new change for review.

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

Change subject: Show orange alert when message is posted on flow
......................................................................

Show orange alert when message is posted on flow

Bug: T137954
Change-Id: I0b49c3a5eb0a027f8839ab86e77c527357907dd0
---
M Hooks.php
M includes/NotifUser.php
M includes/model/Notification.php
3 files changed, 18 insertions(+), 8 deletions(-)


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

diff --git a/Hooks.php b/Hooks.php
index 3caf0bc..0d88108 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -957,9 +957,11 @@
                if ( $wgEchoNewMsgAlert && $user->getOption( 'echo-show-alert' )
                        && $user->getNewtalk() && 
!$user->getTalkPage()->equals( $title )
                ) {
-                       $personal_urls['mytalk']['text'] = $sk->msg( 
'echo-new-messages' )->text();
-                       $personal_urls['mytalk']['class'] = array( 
'mw-echo-alert' );
-                       $sk->getOutput()->addModuleStyles( 
'ext.echo.styles.alert' );
+                       if ( Hooks::run( 'AbortOrangeAlert', array( $user, 
$title ) ) ) {
+                               $personal_urls['mytalk']['text'] = 
$sk->msg('echo-new-messages')->text();
+                               $personal_urls['mytalk']['class'] = 
array('mw-echo-alert');
+                               
$sk->getOutput()->addModuleStyles('ext.echo.styles.alert');
+                       }
                }
 
                return true;
diff --git a/includes/NotifUser.php b/includes/NotifUser.php
index e7d6ded..405b70b 100644
--- a/includes/NotifUser.php
+++ b/includes/NotifUser.php
@@ -134,6 +134,7 @@
         */
        public function flagCacheWithNewTalkNotification() {
                $this->cache->set( $this->getTalkNotificationCacheKey(), '1', 
86400 );
+               $this->mUser->setNewTalk( true );
        }
 
        /**
@@ -148,7 +149,6 @@
         */
        public function getTalkNotificationCacheKey() {
                global $wgEchoConfig;
-
                return wfMemcKey( 'echo-new-talk-notification', 
$this->mUser->getId(), $wgEchoConfig['version'] );
        }
 
@@ -365,7 +365,10 @@
                        // After this 'mark read', is there any unread 
edit-user-talk
                        // remaining?  If not, we should clear the newtalk flag.
                        if ( $this->mUser->getNewtalk() ) {
-                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, array( 
'edit-user-talk' ), null, DB_MASTER );
+                               $attributeManager = 
EchoAttributeManager::newFromGlobalVars();
+                               $categoryMap = 
$attributeManager->getEventsByCategory();
+                               $usertalkTypes = $categoryMap['edit-user-talk'];
+                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, 
null, DB_MASTER );
                                if ( count( $unreadEditUserTalk ) === 0 ) {
                                        $this->mUser->setNewtalk( false );
                                }
@@ -394,7 +397,10 @@
                        // After this 'mark unread', is there any unread 
edit-user-talk?
                        // If so, we should add the edit-user-talk flag
                        if ( !$this->mUser->getNewtalk() ) {
-                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, array( 
'edit-user-talk' ), null, DB_MASTER );
+                               $attributeManager = 
EchoAttributeManager::newFromGlobalVars();
+                               $categoryMap = 
$attributeManager->getEventsByCategory();
+                               $usertalkTypes = $categoryMap['edit-user-talk'];
+                               $unreadEditUserTalk = 
$this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, 
null, DB_MASTER );
                                if ( count( $unreadEditUserTalk ) > 0 ) {
                                        $this->mUser->setNewtalk( true );
                                }
diff --git a/includes/model/Notification.php b/includes/model/Notification.php
index 3114969..cef07c2 100644
--- a/includes/model/Notification.php
+++ b/includes/model/Notification.php
@@ -142,8 +142,10 @@
 
                $notifMapper->insert( $this );
 
-               if ( $this->event->getType() === 'edit-user-talk' ) {
-                       $notifUser->flagCacheWithNewTalkNotification();
+               if ( $this->event->getCategory() === 'edit-user-talk' ) {
+                       if ( !$this->user->getNewtalk() ) {
+                               $notifUser->flagCacheWithNewTalkNotification();
+                       }
                }
                Hooks::run( 'EchoCreateNotificationComplete', array( $this ) );
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b49c3a5eb0a027f8839ab86e77c527357907dd0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Kmuthu <kmu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to