mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-11-24 07:34:11 +00:00
Merge "Hygiene: DRY up eventLogging reducer"
This commit is contained in:
commit
ecdb6e4821
BIN
resources/dist/index.js
vendored
BIN
resources/dist/index.js
vendored
Binary file not shown.
BIN
resources/dist/index.js.map
vendored
BIN
resources/dist/index.js.map
vendored
Binary file not shown.
|
@ -81,7 +81,11 @@ function createAbandonEvent( interaction ) {
|
|||
* @return {Object} The state as a result of processing the action
|
||||
*/
|
||||
module.exports = function ( state, action ) {
|
||||
var nextCount;
|
||||
var nextCount,
|
||||
actionTypesWithTokens = [
|
||||
actionTypes.FETCH_COMPLETE,
|
||||
actionTypes.ABANDON_END
|
||||
];
|
||||
|
||||
if ( state === undefined ) {
|
||||
state = {
|
||||
|
@ -92,6 +96,15 @@ module.exports = function ( state, action ) {
|
|||
};
|
||||
}
|
||||
|
||||
// Was the action delayed? Then it requires a token to be reduced. Enforce
|
||||
// this here to avoid repetion and reduce nesting below.
|
||||
if (
|
||||
actionTypesWithTokens.indexOf( action.type ) !== -1 &&
|
||||
( !state.interaction || action.token !== state.interaction.token )
|
||||
) {
|
||||
return state;
|
||||
}
|
||||
|
||||
switch ( action.type ) {
|
||||
case actionTypes.BOOT:
|
||||
return nextState( state, {
|
||||
|
@ -108,15 +121,11 @@ module.exports = function ( state, action ) {
|
|||
} );
|
||||
|
||||
case actionTypes.FETCH_COMPLETE:
|
||||
if ( state.interaction && action.token === state.interaction.token ) {
|
||||
return nextState( state, {
|
||||
interaction: nextState( state.interaction, {
|
||||
previewType: action.result.type
|
||||
} )
|
||||
} );
|
||||
}
|
||||
|
||||
return state;
|
||||
return nextState( state, {
|
||||
interaction: nextState( state.interaction, {
|
||||
previewType: action.result.type
|
||||
} )
|
||||
} );
|
||||
|
||||
case actionTypes.PREVIEW_SHOW:
|
||||
nextCount = state.previewCount + 1;
|
||||
|
@ -185,7 +194,7 @@ module.exports = function ( state, action ) {
|
|||
} );
|
||||
|
||||
case actionTypes.ABANDON_END:
|
||||
if ( action.token === state.interaction.token && !state.interaction.isUserDwelling ) {
|
||||
if ( !state.interaction.isUserDwelling ) {
|
||||
return nextState( state, {
|
||||
interaction: undefined,
|
||||
event: createAbandonEvent( state.interaction )
|
||||
|
|
Loading…
Reference in a new issue