jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/353711 )

Change subject: RCFilters: Always put highlight values in the URL
......................................................................


RCFilters: Always put highlight values in the URL

Up until now, we only populated highlights in the URL if the item had
a highlight, otherwise it was not in the url at all. However, now that
the system can load defaults from saved queries that can have highlights
themselves, then every time we reload the page (and the system checks
to get defaults merged with the URL query) nothing actively overrides
the default highlight value if it exists.

This meant that if you have a saved query default with any highlights
in it, every time you load the page from the URL it will **also add**
the default highlights that you have saved.

To prevent this, the URL now needs to always populate items with
highlight value, even if that value is null. When we literally ask
for defaults or when we actively load a saved query, that value will
be overridden, but if we have a URL with highlights enabled at all,
the defaults will not override and add a redundany unneeded highlight
just because it existed in your saved query.

Bug: T165231
Change-Id: Ia43b5c777c0b4e238e99818696a3a60dda0daca9
---
M resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
1 file changed, 11 insertions(+), 6 deletions(-)

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



diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js 
b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
index 81b9dc3..4a9e780 100644
--- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
+++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
@@ -179,7 +179,8 @@
                        highlightedItems[ item.getName() ] = highlightEnabled ?
                                item.getHighlightColor() : null;
                } );
-               highlightedItems.highlight = 
this.filtersModel.isHighlightEnabled();
+               // Stored as a string '0' or '1'
+               highlightedItems.highlight = String( Number( 
this.filtersModel.isHighlightEnabled() ) );
 
                // Add item
                this.savedQueriesModel.addNewQuery(
@@ -576,11 +577,15 @@
                // highlight params
                uri.query.highlight = Number( 
this.filtersModel.isHighlightEnabled() );
                Object.keys( highlightParams ).forEach( function ( paramName ) {
-                       if ( highlightParams[ paramName ] ) {
-                               uri.query[ paramName ] = highlightParams[ 
paramName ];
-                       } else {
-                               delete uri.query[ paramName ];
-                       }
+                       // Always have some value (either the color or null) so 
that
+                       // if we have something in the URL that doesn't have 
the highlight
+                       // intentionally, it can override default with 
highlight.
+                       // Otherwise, the $.extend will always add the 
highlight that
+                       // exists in the default even if the URL query that is 
being
+                       // refreshed has different highlights, or has 
highlights enabled
+                       // but no active highlights anywhere
+                       uri.query[ paramName ] = highlightParams[ paramName ] ?
+                               highlightParams[ paramName ] : null;
                } );
 
                return uri;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia43b5c777c0b4e238e99818696a3a60dda0daca9
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>
Gerrit-Reviewer: Mooeypoo <mor...@gmail.com>
Gerrit-Reviewer: Sbisson <sbis...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to