jenkins-bot has submitted this change and it was merged.
Change subject: Share the dirty status across publish and draft modules
......................................................................
Share the dirty status across publish and draft modules
This helps the timer-scheduled autosave to check if publishing
happened while the timer was waiting.
If this is not done, scheduled autosave is happening after publishing,
making a published translation to draft state needlessly.
Bug: T85988
Change-Id: Icd4cf17eb54638ac30bd0a87fd6fc5bddd1da52c
---
M modules/draft/ext.cx.draft.js
M modules/publish/ext.cx.publish.js
M modules/translation/ext.cx.translation.progress.js
3 files changed, 9 insertions(+), 5 deletions(-)
Approvals:
Amire80: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/draft/ext.cx.draft.js b/modules/draft/ext.cx.draft.js
index 868a7a6..58d06d8 100644
--- a/modules/draft/ext.cx.draft.js
+++ b/modules/draft/ext.cx.draft.js
@@ -27,9 +27,10 @@
var save;
save = function ( weights ) {
- if ( weights && weights.any === 0 ) {
+ if ( weights && weights.any === 0 || !mw.cx.dirty ) {
return;
}
+
mw.hook( 'mw.cx.translation.save' ).fire();
};
diff --git a/modules/publish/ext.cx.publish.js
b/modules/publish/ext.cx.publish.js
index 745f885..55fc8fd 100644
--- a/modules/publish/ext.cx.publish.js
+++ b/modules/publish/ext.cx.publish.js
@@ -182,6 +182,7 @@
mw.cx.sourceLanguage,
mw.cx.targetLanguage
);
+ mw.cx.dirty = false;
} ).fail( function ( code, details ) {
var trace = {
sourceLanguage:
mw.cx.sourceLanguage,
diff --git a/modules/translation/ext.cx.translation.progress.js
b/modules/translation/ext.cx.translation.progress.js
index aa927c1..2673564 100644
--- a/modules/translation/ext.cx.translation.progress.js
+++ b/modules/translation/ext.cx.translation.progress.js
@@ -12,9 +12,9 @@
'use strict';
var totalSourceWeight = 0,
- dirty = false,
translationThreshold = 0.05;
+ mw.cx.dirty = false;
/**
* Get the total source weight.
* This is only calculated once per session and cached, because the
source doesn't change.
@@ -123,8 +123,10 @@
if ( !$section ) {
return;
}
- dirty = true;
+
+ mw.cx.dirty = true;
$sourceSection = mw.cx.getTranslationSection( $section.data(
'source' ) );
+
translationLength = $section.text().length;
sourceLength = $sourceSection.text().length;
@@ -147,13 +149,13 @@
any: 0
} );
mw.hook( 'mw.cx.translation.saved' ).add( function () {
- dirty = false;
+ mw.cx.dirty = false;
} );
window.onbeforeunload = function () {
var weights;
if ( mw.config.get( 'wgContentTranslationDatabase' )
!== null ) {
- if ( dirty ) {
+ if ( mw.cx.dirty ) {
mw.hook( 'mw.cx.translation.save'
).fire();
}
--
To view, visit https://gerrit.wikimedia.org/r/183777
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icd4cf17eb54638ac30bd0a87fd6fc5bddd1da52c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
Gerrit-Reviewer: Amire80 <[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