jenkins-bot has submitted this change and it was merged.
Change subject: Load the category informaton in parallel with source load
......................................................................
Load the category informaton in parallel with source load
And display the categories once source is loaded.
This helps to avoid a flicker in screen when categories
fetched and inserted after source is rendered.
Make use of the time while we wait for source article.
Bug: T90106
Change-Id: I9e37d4843a3515d1248c89e207f78986fec88bac
---
M modules/tools/ext.cx.tools.categories.js
M tests/qunit/tools/ext.cx.tools.categories.test.js
2 files changed, 17 insertions(+), 9 deletions(-)
Approvals:
Santhosh: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/tools/ext.cx.tools.categories.js
b/modules/tools/ext.cx.tools.categories.js
index 5a4cb7a..5238d7c 100644
--- a/modules/tools/ext.cx.tools.categories.js
+++ b/modules/tools/ext.cx.tools.categories.js
@@ -597,8 +597,7 @@
};
/**
- * Retrieves the specified set of categories
- *
+ * Retrieves the categories
* @return {jQuery.Promise}
*/
CXCategoryTool.prototype.getCategories = function () {
@@ -677,17 +676,26 @@
}
};
- // Expose the CXCategoryTool (required by publishing)
- mw.cx.categoryTool = new CXCategoryTool( mw.cx.siteMapper );
-
// Expose the CXCategoryTool class for unit testing
if ( typeof QUnit !== undefined ) {
mw.cx.CategoryTool = CXCategoryTool;
}
$( function () {
- mw.hook( 'mw.cx.source.loaded' ).add( function () {
- mw.cx.categoryTool.getCategories().done( function (
categories ) {
+ var sitemapper;
+
+ sitemapper = new mw.cx.SiteMapper(
+ mw.config.get( 'wgContentTranslationSiteTemplates' )
+ );
+ // The module will be loaded in the context of Unit tests too,
there
+ // source language may not set. Check and abort if that is the
case.
+ if ( !mw.cx.sourceLanguage ) {
+ return;
+ }
+ // Expose the CXCategoryTool (required by publishing)
+ mw.cx.categoryTool = new CXCategoryTool( sitemapper );
+ mw.cx.categoryTool.getCategories().done( function ( categories
) {
+ mw.hook( 'mw.cx.source.loaded' ).add( function () {
mw.cx.categoryTool.initializeWidgets( 'source'
);
mw.cx.categoryTool.initializeWidgets(
'translation' );
if ( Object.keys( categories.source ).length >
0 ) {
diff --git a/tests/qunit/tools/ext.cx.tools.categories.test.js
b/tests/qunit/tools/ext.cx.tools.categories.test.js
index ab0fa5e..687f2e3 100644
--- a/tests/qunit/tools/ext.cx.tools.categories.test.js
+++ b/tests/qunit/tools/ext.cx.tools.categories.test.js
@@ -9,7 +9,7 @@
QUnit.module( 'ext.cx.tools.categories', QUnit.newMwEnvironment( {
setup: function () {
- mw.cx.siteMapper = new mw.cx.SiteMapper(
+ this.sitemapper = new mw.cx.SiteMapper(
mw.config.get(
'wgContentTranslationSiteTemplates' )
);
mw.cx.sourceLanguage = 'es';
@@ -18,7 +18,7 @@
} ) );
QUnit.test( 'Get categories', function ( assert ) {
- var done, categoryTool = new mw.cx.CategoryTool(
mw.cx.siteMapper );
+ var done, categoryTool = new mw.cx.CategoryTool(
this.sitemapper );
done = assert.async();
QUnit.expect( 3 );
--
To view, visit https://gerrit.wikimedia.org/r/190797
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e37d4843a3515d1248c89e207f78986fec88bac
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[email protected]>
Gerrit-Reviewer: Jsahleen <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Santhosh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits