mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Merge "Use new wikipage.watchlistChange
hook"
This commit is contained in:
commit
a627011ddf
|
@ -991,11 +991,8 @@ function update( data, comment, pageName, replyWidget ) {
|
|||
if ( mw.loader.getState( 'mediawiki.page.watch.ajax' ) === 'ready' ) {
|
||||
var watch = require( 'mediawiki.page.watch.ajax' );
|
||||
|
||||
watch.updateWatchLink(
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
$( '#ca-watch a, #ca-unwatch a' ),
|
||||
data.watched ? 'unwatch' : 'watch',
|
||||
'idle',
|
||||
watch.updatePageWatchStatus(
|
||||
data.watched,
|
||||
data.watchlistexpiry
|
||||
);
|
||||
}
|
||||
|
|
|
@ -542,8 +542,7 @@ ReplyWidget.prototype.setup = function ( data ) {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
$( '#ca-watch, #ca-unwatch' ).on( 'watchpage.mw', this.onWatchToggleHandler );
|
||||
mw.hook( 'wikipage.watchlistChange' ).add( this.onWatchToggleHandler );
|
||||
|
||||
return this;
|
||||
};
|
||||
|
@ -627,8 +626,7 @@ ReplyWidget.prototype.teardown = function ( abandoned ) {
|
|||
this.modeTabSelect.blur();
|
||||
}
|
||||
this.unbindBeforeUnloadHandler();
|
||||
// eslint-disable-next-line no-jquery/no-global-selector
|
||||
$( '#ca-watch, #ca-unwatch' ).off( 'watchpage.mw', this.onWatchToggleHandler );
|
||||
mw.hook( 'wikipage.watchlistChange' ).remove( this.onWatchToggleHandler );
|
||||
|
||||
this.clear();
|
||||
this.emit( 'teardown', abandoned );
|
||||
|
@ -638,17 +636,18 @@ ReplyWidget.prototype.teardown = function ( abandoned ) {
|
|||
/**
|
||||
* Handle changes to the watch state of the page
|
||||
*
|
||||
* @param {jQuery.Event} e Event
|
||||
* @param {string} actionPerformed Watch action taken
|
||||
* @param {boolean} isWatched
|
||||
* @param {string} expiry
|
||||
* @param {string} expirySelected
|
||||
*/
|
||||
ReplyWidget.prototype.onWatchToggle = function ( e, actionPerformed ) {
|
||||
ReplyWidget.prototype.onWatchToggle = function ( isWatched ) {
|
||||
var widget = this;
|
||||
this.checkboxesPromise.then( function ( checkboxes ) {
|
||||
if ( checkboxes.checkboxesByName.wpWatchthis ) {
|
||||
checkboxes.checkboxesByName.wpWatchthis.setSelected(
|
||||
!!mw.user.options.get( 'watchdefault' ) ||
|
||||
( !!mw.user.options.get( 'watchcreations' ) && !widget.pageExists ) ||
|
||||
actionPerformed === 'watch'
|
||||
isWatched
|
||||
);
|
||||
}
|
||||
} );
|
||||
|
|
Loading…
Reference in a new issue