jenkins-bot has submitted this change and it was merged.
Change subject: Update "Watch this page" option when necessary
......................................................................
Update "Watch this page" option when necessary
On load and change the user presses the button
Bug: T78694
Change-Id: I1df2836f8ba4ae647bfb142513e5de9f32ecd0fe
---
M ApiVisualEditor.php
M VisualEditor.hooks.php
M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
M modules/ve-mw/init/ve.init.mw.Target.js
4 files changed, 15 insertions(+), 3 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
Trevor Parscal: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index add80ed..cc4c468 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -492,7 +492,8 @@
'notices' => $notices,
'checkboxes' =>
$checkboxes,
'links' => $links,
- 'protectedClasses' =>
implode( ' ', $protectedClasses )
+ 'protectedClasses' =>
implode( ' ', $protectedClasses ),
+ 'watched' =>
$user->isWatched( $page )
),
$parsed['result']
);
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 7429a84..e616777 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -388,7 +388,6 @@
$pageLanguage = $out->getTitle()->getPageLanguage();
$vars['wgVisualEditor'] = array(
- 'isPageWatched' => $out->getUser()->isWatched(
$out->getTitle() ),
'pageLanguageCode' => $pageLanguage->getHtmlCode(),
'pageLanguageDir' => $pageLanguage->getDir(),
'svgMaxSize' => $out->getConfig()->get( 'SVGMaxSize' ),
diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
index 3b71853..04f4409 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js
@@ -242,6 +242,18 @@
this.originalEditondbclick = mw.user.options.get(
'editondblclick' );
mw.user.options.set( 'editondblclick', 0 );
+ $( '#ca-watch, #ca-unwatch' ).on( 'watchpage.mw', function ( e,
actionPerformed ) {
+ if ( !this.active && !this.activating ) {
+ return;
+ }
+ this.$checkboxes.filter( '#wpWatchthis' )
+ .prop( 'checked',
+ mw.user.options.get( 'watchdefault' ) ||
+ ( mw.user.options.get( 'watchcreations'
) && !this.pageExists ) ||
+ actionPerformed === 'watch'
+ );
+ }.bind( this ) );
+
// User interface changes
this.transformPage();
this.hideReadOnlyContent();
diff --git a/modules/ve-mw/init/ve.init.mw.Target.js
b/modules/ve-mw/init/ve.init.mw.Target.js
index e52615c..f0f3ba5 100644
--- a/modules/ve-mw/init/ve.init.mw.Target.js
+++ b/modules/ve-mw/init/ve.init.mw.Target.js
@@ -442,7 +442,7 @@
.prop( 'checked',
mw.user.options.get( 'watchdefault' ) ||
( mw.user.options.get( 'watchcreations'
) && !this.pageExists ) ||
- mw.config.get( 'wgVisualEditor'
).isPageWatched
+ data.watched
);
this.baseTimeStamp = data.basetimestamp;
--
To view, visit https://gerrit.wikimedia.org/r/182336
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1df2836f8ba4ae647bfb142513e5de9f32ecd0fe
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits