Ajax watch: Move JS config var to packageFiles

To improve performance, the watchlist expiry flag was moved to
packageFiles instead of the OutputPage.php file

Bug: T249259
Change-Id: If57030db7d1e90b0890ee2a1ad466772a2f8b8bc
This commit is contained in:
suecarmol 2020-05-22 19:19:32 -05:00
parent 0f97cb3e2a
commit b32e71aa60
3 changed files with 7 additions and 3 deletions

View file

@ -3332,7 +3332,6 @@ class OutputPage extends ContextSource {
'wgPageContentModel' => $title->getContentModel(),
'wgRelevantPageName' => $relevantTitle->getPrefixedDBkey(),
'wgRelevantArticleId' => $relevantTitle->getArticleID(),
'wgWatchlistExpiry' => $this->getContext()->getConfig()->get( 'WatchlistExpiry' ),
];
if ( $user->isLoggedIn() ) {
$vars['wgUserId'] = $user->getId();

View file

@ -1504,8 +1504,13 @@ return [
],
],
'mediawiki.page.watch.ajax' => [
'localBasePath' => "$IP/resources/src",
'remoteBasePath' => "$wgResourceBasePath/resources/src",
'targets' => [ 'desktop', 'mobile' ],
'scripts' => 'resources/src/mediawiki.page.watch.ajax.js',
'packageFiles' => [
'mediawiki.page.watch.ajax.js',
[ 'name' => 'config.json', 'config' => [ 'WatchlistExpiry' ] ],
],
'dependencies' => [
'mediawiki.api',
'mediawiki.util',

View file

@ -181,7 +181,7 @@
.done( function ( watchResponse ) {
var message,
watchlistPopup = null,
isWatchlistExpiryEnabled = mw.config.get( 'wgWatchlistExpiry' ),
isWatchlistExpiryEnabled = require( './config.json' ).WatchlistExpiry,
otherAction = action === 'watch' ? 'unwatch' : 'watch';
if ( mwTitle.isTalkPage() ) {