mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-12-03 19:56:39 +00:00
19349c0108
Changes: * Make grunt:qunit run all QUnit tests in those modules whose names being with "ext.popups". * Add ext.popups/index.js, which initialises the mw.popups namespace. * Add ext.popups/userSettings.js, which contains the code that deals with interacting with the User Agent's storage. * Add ext.popups/experiment.js, which contains the code that that decides whether or not the user is in the experiment condition. * Add tests for both units, converting existing tests where appropriate. * Remove the associated code from ext.popups.core/ext.popups.core.js. * Finally, dispatch the BOOT action against the store in ext.popups/boot.js. Change-Id: I697207677304bd49c7cfe1d37bb0a4af7810f387
47 lines
1 KiB
JavaScript
47 lines
1 KiB
JavaScript
( function ( mw, Redux, ReduxThunk ) {
|
|
|
|
/**
|
|
* A [null](https://en.wikipedia.org/wiki/Null_Object_pattern) reducer.
|
|
*
|
|
* @param {Object} state The current state
|
|
* @param {Object} action The action that was dispatched against the store
|
|
* @return {Object} The new state
|
|
*/
|
|
function rootReducer( state, action ) {
|
|
/* jshint unused: false */
|
|
return state;
|
|
}
|
|
|
|
mw.requestIdleCallback( function () {
|
|
var compose = Redux.compose,
|
|
store,
|
|
userSettings,
|
|
isUserInCondition;
|
|
|
|
// If debug mode is enabled, then enable Redux DevTools.
|
|
if ( mw.config.get( 'debug' ) === true ) {
|
|
compose = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
}
|
|
|
|
store = Redux.createStore(
|
|
rootReducer,
|
|
compose( Redux.applyMiddleware(
|
|
ReduxThunk.default
|
|
) )
|
|
);
|
|
|
|
userSettings = mw.popups.createUserSettings(
|
|
mw.storage,
|
|
mw.user
|
|
);
|
|
isUserInCondition = mw.popups.createExperiment(
|
|
mw.config,
|
|
mw.user,
|
|
userSettings
|
|
);
|
|
|
|
store.dispatch( mw.popups.actions.boot( isUserInCondition ) );
|
|
} );
|
|
|
|
}( mediaWiki, Redux, ReduxThunk ) );
|