Santhosh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183777
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 not done, scheduled autosave is happening after publishing
making a published translation to draft state unintentionally
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, 7 insertions(+), 5 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation
refs/changes/77/183777/1
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 e8dd82b..95e07c3 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,7 +123,7 @@
if ( !$section ) {
return;
}
- dirty = true;
+ mw.cx.dirty = true;
$sourceSection = $( '#' + $section.data( 'source' ) );
translationLength = $section.text().length;
sourceLength = $sourceSection.text().length;
@@ -147,13 +147,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: newchange
Gerrit-Change-Id: Icd4cf17eb54638ac30bd0a87fd6fc5bddd1da52c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits