mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
Merge "Move talk page notification data from 'user-menu' to 'notifications'"
This commit is contained in:
commit
faac5178b9
|
@ -458,7 +458,6 @@
|
|||
"SkinMinervaReplaceNotificationsBadge": "EchoHooks::onSkinMinervaReplaceNotificationsBadge",
|
||||
"LoadExtensionSchemaUpdates": "EchoHooks::onLoadExtensionSchemaUpdates",
|
||||
"GetPreferences": "EchoHooks::getPreferences",
|
||||
"PersonalUrls": "EchoHooks::onPersonalUrls",
|
||||
"BeforePageDisplay": "EchoHooks::beforePageDisplay",
|
||||
"ResourceLoaderRegisterModules": "EchoHooks::onResourceLoaderRegisterModules",
|
||||
"UserGroupsChanged": "EchoHooks::onUserGroupsChanged",
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
"echo-pref-dont-email-read-notifications": "Don't include read notifications in summary emails",
|
||||
"echo-learn-more": "Learn more",
|
||||
"echo-log": "Public log",
|
||||
"echo-new-messages": "You have new messages",
|
||||
"echo-new-messages": "You have a new Talk page message",
|
||||
"echo-category-title-edit-user-talk": "Talk page {{PLURAL:$1|message|messages}}",
|
||||
"echo-category-title-article-linked": "Page {{PLURAL:$1|link|links}}",
|
||||
"echo-category-title-reverted": "Edit {{PLURAL:$1|revert|reverts}}",
|
||||
|
|
|
@ -1013,29 +1013,6 @@ class EchoHooks implements RecentChange_saveHook {
|
|||
$badge = $parser->processTemplate( 'NotificationBadge', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for PersonalUrls hook.
|
||||
* Marks the talk page link when the user has a new message.
|
||||
* @see https://www.mediawiki.org/wiki/Manual:Hooks/PersonalUrls
|
||||
* @param array &$personal_urls Array of URLs to append to.
|
||||
* @param Title &$title Title of page being visited.
|
||||
* @param SkinTemplate $sk
|
||||
*/
|
||||
public static function onPersonalUrls( &$personal_urls, &$title, $sk ) {
|
||||
$user = $sk->getUser();
|
||||
if ( !$user->isRegistered() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user has new messages, display a talk page alert
|
||||
if ( self::shouldDisplayTalkAlert( $user, $title )
|
||||
&& Hooks::run( 'BeforeDisplayOrangeAlert', [ $user, $title ] )
|
||||
) {
|
||||
$personal_urls['mytalk']['text'] = $sk->msg( 'echo-new-messages' )->text();
|
||||
$personal_urls['mytalk']['class'] = [ 'mw-echo-alert' ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a talk page alert should be displayed.
|
||||
* We need to check:
|
||||
|
@ -1148,6 +1125,22 @@ class EchoHooks implements RecentChange_saveHook {
|
|||
$alertLinkClasses[] = 'mw-echo-notifications-badge-long-label';
|
||||
}
|
||||
|
||||
if (
|
||||
self::shouldDisplayTalkAlert( $user, $title ) &&
|
||||
MediaWikiServices::getInstance()
|
||||
->getHookContainer()->run( 'BeforeDisplayOrangeAlert', [ $user, $title ] )
|
||||
) {
|
||||
// Move `mytalk` from `user-menu` to `notifications`.
|
||||
$links['notifications']['mytalk'] = array_merge(
|
||||
$links['user-menu']['mytalk'],
|
||||
[
|
||||
'text' => $skinTemplate->msg( 'echo-new-messages' )->text(),
|
||||
'class' => [ 'mw-echo-alert' ]
|
||||
]
|
||||
);
|
||||
unset( $links['user-menu']['mytalk'] );
|
||||
}
|
||||
|
||||
$links['notifications']['notifications-alert'] = [
|
||||
'href' => $url,
|
||||
'text' => $alertText,
|
||||
|
|
|
@ -265,7 +265,7 @@ function initDesktop() {
|
|||
if ( hasUnseenAlerts || hasUnseenMessages ) {
|
||||
// Clicked on the flyout due to having unread notifications
|
||||
// This is part of tracking how likely users are to click a badge with unseen notifications.
|
||||
// The other part is the 'echo.unseen' counter, see EchoHooks::onPersonalUrls().
|
||||
// The other part is the 'echo.unseen' counter, see EchoHooks::onSkinTemplateNavigationUniversal().
|
||||
mw.track( 'counter.MediaWiki.echo.unseen.click' );
|
||||
}
|
||||
}, function () {
|
||||
|
|
Loading…
Reference in a new issue