mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Start using edit api results for watchlist UI updates
This patch starts using watchlist related values from ApiEditPage
results instead of updating the "watch link" based on whether the
checkbox was selected or not at the time of saving the article.
This change does not depend on T261030 and can be merged without it
but T261030 needs to be fixed or temporarily watched items will not
display the right tooltip when hovering the "watch link" or star icon.
Bug: T260434
Change-Id: I2c844223620d7d28f36a0cd8ae3dee4b0c8ae5bf
(cherry picked from commit 4fc73112ee
)
This commit is contained in:
parent
cc95db5afd
commit
cecb076605
|
@ -447,6 +447,8 @@ class ApiVisualEditorEdit extends ApiBase {
|
|||
$result['newrevid'] = intval( $saveresult['edit']['newrevid'] );
|
||||
}
|
||||
|
||||
$result['watched'] = $saveresult['edit']['watched'] ?? false;
|
||||
$result['watchlistexpiry'] = $saveresult['edit']['watchlistexpiry'] ?? null;
|
||||
$result['result'] = 'success';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -892,7 +892,7 @@ ve.init.mw.DesktopArticleTarget.prototype.onViewTabClick = function ( e ) {
|
|||
* @inheritdoc
|
||||
*/
|
||||
ve.init.mw.DesktopArticleTarget.prototype.saveComplete = function ( data ) {
|
||||
var newUrlParams, watchChecked, watch,
|
||||
var newUrlParams, watch,
|
||||
target = this;
|
||||
|
||||
// Parent method
|
||||
|
@ -915,10 +915,12 @@ ve.init.mw.DesktopArticleTarget.prototype.saveComplete = function ( data ) {
|
|||
// User logged in if module loaded.
|
||||
if ( mw.loader.getState( 'mediawiki.page.watch.ajax' ) === 'ready' ) {
|
||||
watch = require( 'mediawiki.page.watch.ajax' );
|
||||
watchChecked = this.checkboxesByName.wpWatchthis && this.checkboxesByName.wpWatchthis.isSelected();
|
||||
|
||||
watch.updateWatchLink(
|
||||
$( '#ca-watch a, #ca-unwatch a' ),
|
||||
watchChecked ? 'unwatch' : 'watch'
|
||||
data.watched ? 'unwatch' : 'watch',
|
||||
'idle',
|
||||
data.watchlistexpiry
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue