Werdna has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/148291

Change subject: Add hook to AJAX watch success.
......................................................................

Add hook to AJAX watch success.

This hook allows another extension to take over the notification,
as well.

It's being used in Flow to customise the notification so that
it fully explains what happens when you watch a Flow page.

I realise I'm probably missing some documentation here, so let me
know where I'm supposed to document it and I'll do so.

Change-Id: I9ffdc1b9acfb7423f88d8ef9ee632b141e8661aa
---
M resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/91/148291/1

diff --git a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js 
b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
index 15e9aba..c43c5d7 100644
--- a/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
+++ b/resources/src/mediawiki.page/mediawiki.page.watch.ajax.js
@@ -140,11 +140,20 @@
 
                        api[action]( title )
                                .done( function ( watchResponse ) {
-                                       var otherAction = action === 'watch' ? 
'unwatch' : 'watch';
+                                       var otherAction = action === 'watch' ? 
'unwatch' : 'watch',
+                                               notify = true;
 
-                                       mw.notify( $.parseHTML( 
watchResponse.message ), {
-                                               tag: 'watch-self'
-                                       } );
+                                       mw.hook( 'wikipage.watch.complete' 
).fire(
+                                               $link,
+                                               action,
+                                               function() { notify = false; }
+                                       );
+
+                                       if ( notify ) {
+                                               mw.notify( $.parseHTML( 
watchResponse.message ), {
+                                                       tag: 'watch-self'
+                                               } );
+                                       }
 
                                        // Set link to opposite
                                        updateWatchLink( $link, otherAction );

-- 
To view, visit https://gerrit.wikimedia.org/r/148291
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ffdc1b9acfb7423f88d8ef9ee632b141e8661aa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to