Replaces $user->isWatching call with WatchedItemStore isWatching service call

Bug: T208766
Change-Id: I178b1a1aa0106d82f1b336f2bda5c6371468d741
This commit is contained in:
Vedmaka 2019-04-28 02:07:20 +03:00 committed by Jdlrobson
parent 05aab42559
commit 2fce68778c

View file

@ -22,6 +22,8 @@
* @ingroup Skins
*/
use MediaWiki\MediaWikiServices;
/**
* QuickTemplate subclass for Vector
* @ingroup Skins
@ -41,9 +43,16 @@ class VectorTemplate extends BaseTemplate {
// Move the watch/unwatch star outside of the collapsed "actions" menu to the main "views" menu
if ( $this->config->get( 'VectorUseIconWatch' ) ) {
$mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() )
? 'unwatch'
: 'watch';
$mode = ( $this->getSkin()->getRelevantTitle()->isWatchable() &&
MediaWikiServices::getInstance()->getPermissionManager()->userHasRight(
$this->getSkin()->getUser(),
'viewmywatchlist'
) &&
MediaWikiServices::getInstance()->getWatchedItemStore()->isWatched(
$this->getSkin()->getUser(),
$this->getSkin()->getRelevantTitle()
)
) ? 'unwatch' : 'watch';
if ( isset( $this->data['action_urls'][$mode] ) ) {
$this->data['view_urls'][$mode] = $this->data['action_urls'][$mode];