Followup I59dfcfb25c, language change work with out event logging
In I59dfcfb25c, for logging events when page is navigating away, we used callbacks with mw.hook. That is wrong approach. If event logging is disabled those callbacks will never called: it broke language change and all use cases which navigates away from current page. Event logging should not interfere with any ULS functionality. If ULS functionality depends on callbacks from event logging, it is wrong. In this patch, we give a small time window to make sure event logging is fired, but we won't wait for its success or failure. If eventlogging is disabled, this time window does not exist. Change-Id: I0b7d9d8b9d1d01b99422010596ebfa80b2589d04
This commit is contained in:
committed by
Nikerabbit
parent
1f66cb22bc
commit
7649b47f5c
@@ -44,14 +44,23 @@
|
||||
* @param {string} language Language code.
|
||||
*/
|
||||
mw.uls.changeLanguage = function ( language ) {
|
||||
var uri = new mw.Uri( window.location.href );
|
||||
var uri = new mw.Uri( window.location.href ),
|
||||
deferred = new $.Deferred();
|
||||
|
||||
mw.hook( 'mw.uls.interface.language.change' ).fire( language, function () {
|
||||
deferred.done( function () {
|
||||
uri.extend( {
|
||||
setlang: language
|
||||
} );
|
||||
window.location.href = uri.toString();
|
||||
} );
|
||||
|
||||
mw.hook( 'mw.uls.interface.language.change' ).fire( language, deferred );
|
||||
|
||||
// Delay is zero if event logging is not enabled
|
||||
window.setTimeout( function () {
|
||||
deferred.resolve();
|
||||
}, mw.config.get( 'wgULSEventLogging' ) * 500 );
|
||||
|
||||
};
|
||||
|
||||
mw.uls.setPreviousLanguages = function ( previousLanguages ) {
|
||||
|
||||
Reference in New Issue
Block a user