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:
Santhosh Thottingal
2016-05-09 11:51:42 +05:30
parent 836444fccb
commit 1bc3f3b065

View File

@@ -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
*/ */