Merge "Follow-Up 27f913cc96: Drop complicated MobileContext injection, now unused"

This commit is contained in:
jenkins-bot 2024-02-07 18:15:34 +00:00 committed by Gerrit Code Review
commit c6b47d5bfd
3 changed files with 3 additions and 27 deletions

View file

@ -96,9 +96,6 @@
"services": [
"GadgetsRepo",
"UserOptionsLookup"
],
"optional_services": [
"MobileFrontend.Context"
]
},
"GadgetCodeEditorHooks": {

View file

@ -38,22 +38,19 @@ class GadgetLoadConditions {
private $namespace;
/** @var string */
private $contentModel;
/** @var bool */
private $isMobileView;
/** @var string|null */
private $withGadgetParam;
/**
* @param OutputPage $out
*/
public function __construct( OutputPage $out, bool $isMobileView = false ) {
public function __construct( OutputPage $out ) {
$this->user = $out->getUser();
$this->skin = $out->getSkin();
$this->action = $out->getContext()->getActionName();
$this->namespace = $out->getTitle()->getNamespace();
$this->contentModel = $out->getTitle()->getContentModel();
$this->withGadgetParam = $out->getRequest()->getRawVal( 'withgadget' );
$this->isMobileView = $isMobileView;
}
/**

View file

@ -57,7 +57,6 @@ use MediaWiki\User\Hook\UserGetDefaultOptionsHook;
use MediaWiki\User\Options\UserOptionsLookup;
use MediaWiki\User\User;
use MessageSpecifier;
use MobileContext;
use OOUI\HtmlSnippet;
use RequestContext;
use Skin;
@ -83,18 +82,13 @@ class Hooks implements
{
private GadgetRepo $gadgetRepo;
private UserOptionsLookup $userOptionsLookup;
/** @phan-suppress-next-line PhanUndeclaredTypeProperty */
private ?MobileContext $mobileContext;
public function __construct(
GadgetRepo $gadgetRepo,
UserOptionsLookup $userOptionsLookup,
// @phan-suppress-next-line PhanUndeclaredTypeParameter
?MobileContext $mobileContext
UserOptionsLookup $userOptionsLookup
) {
$this->gadgetRepo = $gadgetRepo;
$this->userOptionsLookup = $userOptionsLookup;
$this->mobileContext = $mobileContext;
}
/**
@ -166,16 +160,6 @@ class Hooks implements
}
}
/**
* Check whether the gadget should load on the mobile domain based on its definition.
*
* @return bool
*/
private function isMobileView(): bool {
// @phan-suppress-next-line PhanUndeclaredClassMethod
return $this->mobileContext && $this->mobileContext->shouldDisplayMobileView();
}
/**
* GetPreferences hook handler.
* @param User $user
@ -205,7 +189,6 @@ class Hooks implements
}
$skin = RequestContext::getMain()->getSkin();
$isMobileView = $this->isMobileView();
foreach ( $gadgets as $section => $thisSection ) {
foreach ( $thisSection as $gadget ) {
// Only show option to enable gadget if it can be enabled
@ -281,13 +264,12 @@ class Hooks implements
public function onBeforePageDisplay( $out, $skin ): void {
$repo = $this->gadgetRepo;
$ids = $repo->getGadgetIds();
$isMobileView = $this->isMobileView();
if ( !$ids ) {
return;
}
$enabledLegacyGadgets = [];
$conditions = new GadgetLoadConditions( $out, $isMobileView );
$conditions = new GadgetLoadConditions( $out );
/**
* @var $gadget Gadget