Compact links: Avoid duplicate call of filterByCommonLanguages
It re-triggers mw.uls.getFrequentLanguageList(), getPreviousLanguages() and localstorage read. In this patch the result was saved and reused. Bug: T122341 Change-Id: I14839eb611cd3e995e8d8ab729ee3f714840f9ad
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
this.interlanguageList = {};
|
this.interlanguageList = {};
|
||||||
this.compactList = {};
|
this.compactList = {};
|
||||||
|
this.commonInterlanguageList = null;
|
||||||
this.$trigger = null;
|
this.$trigger = null;
|
||||||
this.compactSize = 0;
|
this.compactSize = 0;
|
||||||
this.listSize = 0;
|
this.listSize = 0;
|
||||||
@@ -175,7 +176,7 @@
|
|||||||
compact: true,
|
compact: true,
|
||||||
languages: ulsLanguageList,
|
languages: ulsLanguageList,
|
||||||
// Show common languages
|
// Show common languages
|
||||||
quickList: self.filterByCommonLanguages( languages )
|
quickList: self.getCommonLanguages( languages )
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@
|
|||||||
|
|
||||||
// Add all common languages to the beginning of array.
|
// Add all common languages to the beginning of array.
|
||||||
// These are the most probable languages predicted by ULS.
|
// These are the most probable languages predicted by ULS.
|
||||||
this.filterByCommonLanguages( languages ),
|
this.getCommonLanguages( languages ),
|
||||||
|
|
||||||
// Finally add the whole languages array too.
|
// Finally add the whole languages array too.
|
||||||
// We will remove duplicates and cut down to required size.
|
// We will remove duplicates and cut down to required size.
|
||||||
@@ -320,6 +321,13 @@
|
|||||||
return interlanguageList;
|
return interlanguageList;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get common languages - the most probable languages predicted by ULS.
|
||||||
|
*/
|
||||||
|
getCommonLanguages: function ( languages ) {
|
||||||
|
return this.commonInterlanguageList || this.filterByCommonLanguages( languages );
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide the original interlanguage list
|
* Hide the original interlanguage list
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user