mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2025-01-09 12:44:16 +00:00
eabb7011fb
If the user abandons the link after the API request delay (500 ms) but before the it resolves (~10e3 ms), then the preview shouldn't be rendered. Changes: * actions: Include the link in the FETCH_START, FETCH_FAILED, and FETCH_END actions. * reducers: If the active link has changed, then FETCH_END is a NOOP. Supporting changes: * reducers: Signal that a preview should be rendered and shown with preview.shouldShow. Change-Id: I3dd1c0c566ec63de515174c14845d7927583ce93
25 lines
576 B
JavaScript
25 lines
576 B
JavaScript
( function ( mw ) {
|
|
|
|
/**
|
|
* Creates an instance of the render change listener.
|
|
*
|
|
* @return {ext.popups.ChangeListener}
|
|
*/
|
|
mw.popups.changeListeners.render = function () {
|
|
var preview;
|
|
|
|
return function ( prevState, state ) {
|
|
if ( state.preview.shouldShow && !preview ) {
|
|
preview = mw.popups.renderer.render( state.preview.fetchResponse );
|
|
preview.show( state.preview.activeEvent );
|
|
} else if ( !state.preview.shouldShow && preview ) {
|
|
preview.hide()
|
|
.done( function () {
|
|
preview = undefined;
|
|
} );
|
|
}
|
|
};
|
|
};
|
|
|
|
}( mediaWiki ) );
|