Use packageFiles instead of startup module for config vars

Remove wgEchoMaxNotificationCount and wgEchoPollForUpdates from the
startup module and put them in the ext.echo.init module.

Change-Id: I03f9a3953aa97ead1a29c13a992a02404a6d0b68
This commit is contained in:
Roan Kattouw 2019-07-03 16:04:14 -07:00
parent b3df45dc34
commit d378e4e3b9
4 changed files with 16 additions and 12 deletions

View file

@ -4,6 +4,9 @@
"wikimedia/client",
"wikimedia/jquery"
],
"env": {
"commonjs": true
},
"globals": {
"OO": false,
"mw": false

View file

@ -258,8 +258,12 @@
]
},
"ext.echo.init": {
"scripts": [
"ext.echo.init.js"
"packageFiles": [
"ext.echo.init.js",
{
"name": "config.json",
"callback": "EchoHooks::getConfigVars"
}
],
"dependencies": [
"ext.echo.api",
@ -409,7 +413,6 @@
"SendWatchlistEmailNotification": "EchoHooks::onSendWatchlistEmailNotification",
"GetNewMessagesAlert": "EchoHooks::abortNewMessagesAlert",
"LinksUpdateAfterInsert": "EchoHooks::onLinksUpdateAfterInsert",
"ResourceLoaderGetConfigVars": "EchoHooks::onResourceLoaderGetConfigVars",
"SpecialMuteModifyFormFields": "EchoHooks::onSpecialMuteModifyFormFields"
},
"config": {

View file

@ -1477,13 +1477,11 @@ class EchoHooks {
return true;
}
public static function onResourceLoaderGetConfigVars( &$vars ) {
global $wgEchoPollForUpdates;
$vars['wgEchoMaxNotificationCount'] = MWEchoNotifUser::MAX_BADGE_COUNT;
$vars['wgEchoPollForUpdates'] = $wgEchoPollForUpdates;
return true;
public static function getConfigVars( ResourceLoaderContext $context ) {
return [
'EchoMaxNotificationCount' => MWEchoNotifUser::MAX_BADGE_COUNT,
'EchoPollForUpdates' => $context->getConfig()->get( 'EchoPollForUpdates' )
];
}
/**

View file

@ -25,8 +25,8 @@
alertModelManager,
unreadMessageCounter,
unreadAlertCounter,
maxNotificationCount = mw.config.get( 'wgEchoMaxNotificationCount' ),
pollingRate = mw.config.get( 'wgEchoPollForUpdates' ),
maxNotificationCount = require( './config.json' ).EchoMaxNotificationCount,
pollingRate = require( './config.json' ).EchoPollForUpdates,
documentTitle = document.title,
$existingAlertLink = $( '#pt-notifications-alert a' ),
$existingMessageLink = $( '#pt-notifications-notice a' ),