Merge "Limited width made persistent for anonymous users"

This commit is contained in:
jenkins-bot 2023-01-25 20:08:24 +00:00 committed by Gerrit Code Review
commit a327d43984
2 changed files with 18 additions and 2 deletions

View file

@ -4,13 +4,28 @@ let /** @type {MwApi} */ api;
const debounce = require( /** @type {string} */ ( 'mediawiki.util' ) ).debounce;
/**
* Saves preference to user preferences if user is logged in
* Saves preference to user preferences and/or cookies.
*
* @param {string} feature
* @param {boolean} enabled
*/
function save( feature, enabled ) {
if ( !mw.user.isAnon() ) {
if ( mw.user.isAnon() ) {
switch ( feature ) {
case 'limited-width':
if ( enabled ) {
// @ts-ignore
mw.cookie.set( 'mwclientprefs', null );
} else {
// @ts-ignore
mw.cookie.set( 'mwclientprefs', 'vector-feature-limited-width' );
}
break;
default:
// not a supported anonymous preference
break;
}
} else {
debounce( function () {
api = api || new mw.Api();
api.saveOption( 'vector-' + feature, enabled ? 1 : 0 );

View file

@ -382,6 +382,7 @@
"mediawiki.page.watch.ajax",
"mediawiki.util",
"mediawiki.storage",
"mediawiki.cookie",
"mediawiki.experiments"
],
"messages": [