jenkins-bot has submitted this change and it was merged.

Change subject: Display only one foreign bundle on mobile
......................................................................


Display only one foreign bundle on mobile

Display a single foreign bundle containing both
alerts and messages on mobile.

Bug: T131683
Change-Id: I9d3d160586c31457d3a1825e9cecadde42debf7c
---
M i18n/en.json
M i18n/qqq.json
M includes/api/ApiEchoNotifications.php
M modules/ooui/mw.echo.ui.NotificationsWrapper.js
4 files changed, 12 insertions(+), 9 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index ae046ea..679c5cd 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -205,6 +205,7 @@
        "echo-rev-deleted-text-view": "This page revision has been suppressed.",
        "notification-header-foreign-alert": "More alerts from 
{{PLURAL:$5|another wiki|$5 other wikis}}",
        "notification-header-foreign-message": "More messages from 
{{PLURAL:$5|another wiki|$5 other wikis}}",
+       "notification-header-foreign-all": "More notifications from 
{{PLURAL:$5|another wiki|$5 other wikis}}",
        "notification-body-foreign": "$1",
        "echo-foreign-wiki-lang": "$1 - $2",
        "echo-badge-count": "{{PLURAL:$1|$1|100=99+}}",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7c3cb37..5bb22f5 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -196,6 +196,7 @@
        "echo-rev-deleted-text-view": "Short message displayed instead of edit 
content when revision text is suppressed.",
        "notification-header-foreign-alert": "Flyout-specific format for 
displaying notification header of having alert notifications on foreign 
wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 
- the username for GENDER\n* $3 (deprecated) - 1 of the foreign wikis you have 
notifications on\n* $4 (deprecated) - the number of remaining other wikis you 
have notifications on\n*$5 - the number of other wikis you have notifications 
on",
        "notification-header-foreign-message": "Flyout-specific format for 
displaying notification header of having message notifications on foreign 
wikis.\n\nParameters:\n* $1 - the formatted username of the current user.\n* $2 
- the username for GENDER\n* $3 (deprecated) - 1 of the foreign wikis you have 
notifications on\n* $4 (deprecated) - the number of remaining other wikis you 
have notifications on\n*$5 - the number of other wikis you have notifications 
on",
+       "notification-header-foreign-all": "Flyout-specific format for 
displaying notification header of having notifications (combined alerts and 
messages) on foreign wikis.\n\nParameters:\n* $1 - the formatted username of 
the current user.\n* $2 - the username for GENDER\n* $3 (deprecated) - 1 of the 
foreign wikis you have notifications on\n* $4 (deprecated) - the number of 
remaining other wikis you have notifications on\n*$5 - the number of other 
wikis you have notifications on",
        "notification-body-foreign": "{{notranslate}}",
        "echo-foreign-wiki-lang": "Title of the wiki for which you're seeing 
foreign notifications:\n\nParameters:\n* $1 - the name of the site (e.g. 
'Wikipedia', 'Wikiversity', ...)\n* $2 - the language of the website (e.g. 
'English', 'Deutsch', ...)",
        "echo-badge-count": "Used only for the two Echo badges shown on the 
personal toolbar.\nParameters:\n* $1 - Formatted notification count.  However, 
for 100 or greater, 100 will be passed.",
diff --git a/includes/api/ApiEchoNotifications.php 
b/includes/api/ApiEchoNotifications.php
index c4ed7bf..4dbed47 100644
--- a/includes/api/ApiEchoNotifications.php
+++ b/includes/api/ApiEchoNotifications.php
@@ -69,11 +69,12 @@
                                );
 
                                if ( $foreignNotifications ) {
-                                       // insert fake notifications for 
foreign notifications
-                                       foreach ( $params['sections'] as $i => 
$section ) {
-                                               if ( 
$foreignNotifications->getCount( $section ) > 0 ) {
-                                                       $result['list'][-$i-1] 
= $this->makeForeignNotification( $user, $params['format'], 
$foreignNotifications, $section );
-                                               }
+                                       // if exactly 1 section is specified, 
we consider only that section, otherwise
+                                       // we pass 'null' to consider all 
foreign notifications
+                                       $section = count( $params['sections'] ) 
=== 1 ? reset( $params['sections'] ) : null;
+
+                                       if ( $foreignNotifications->getCount( 
$section ) > 0 ) {
+                                               $result['list'][-1] = 
$this->makeForeignNotification( $user, $params['format'], 
$foreignNotifications, $section );
                                        }
                                }
 
@@ -275,7 +276,7 @@
                return $result;
        }
 
-       protected function makeForeignNotification( User $user, $format, 
EchoForeignNotifications $foreignNotifications, $section ) {
+       protected function makeForeignNotification( User $user, $format, 
EchoForeignNotifications $foreignNotifications, $section = null ) {
                $wikis = $foreignNotifications->getWikis( $section );
                $count = $foreignNotifications->getCount( $section );
 
@@ -296,7 +297,7 @@
                $row->event_page_namespace = null;
                $row->event_page_title = null;
                $row->event_extra = serialize( array(
-                       'section' => $section,
+                       'section' => $section ?: 'all',
                        'wikis' => $wikis,
                        'count' => $count
                ) );
@@ -313,7 +314,7 @@
                $output = EchoDataOutputFormatter::formatOutput( $notif, 
$format, $user, $this->getLanguage() );
 
                // Add cross-wiki-specific data
-               $output['section'] = $section;
+               $output['section'] = $section ?: 'all';
                $output['count'] = $count;
                $output['sources'] = $foreignNotifications->getApiEndpoints( 
$wikis );
                // Add timestamp information
diff --git a/modules/ooui/mw.echo.ui.NotificationsWrapper.js 
b/modules/ooui/mw.echo.ui.NotificationsWrapper.js
index 87c3416..16ce20b 100644
--- a/modules/ooui/mw.echo.ui.NotificationsWrapper.js
+++ b/modules/ooui/mw.echo.ui.NotificationsWrapper.js
@@ -1,6 +1,6 @@
 ( function ( mw ) {
        /**
-        * Wapper for the notifications widget, for view outside the popup.
+        * Wrapper for the notifications widget, for view outside the popup.
         *
         * @class
         * @extends OO.ui.Widget

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9d3d160586c31457d3a1825e9cecadde42debf7c
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to