mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Use new TalkPageNotificationManager
Bug: T239640 Change-Id: Iba015bf246250fc144022d92b88eb00882dd1d3a
This commit is contained in:
parent
f54bfb63d3
commit
6dd0f21968
|
@ -1168,7 +1168,9 @@ class EchoHooks {
|
||||||
// * User actually has new messages
|
// * User actually has new messages
|
||||||
// * User is not viewing their user talk page, as user_newtalk
|
// * User is not viewing their user talk page, as user_newtalk
|
||||||
// will not have been cleared yet. (bug T107655).
|
// will not have been cleared yet. (bug T107655).
|
||||||
if ( $user->getNewtalk() && !$user->getTalkPage()->equals( $title ) ) {
|
$userHasNewMessages = MediaWikiServices::getInstance()
|
||||||
|
->getTalkPageNotificationManager()->userHasNewMessages( $user );
|
||||||
|
if ( $userHasNewMessages && !$user->getTalkPage()->equals( $title ) ) {
|
||||||
if ( Hooks::run( 'BeforeDisplayOrangeAlert', [ $user, $title ] ) ) {
|
if ( Hooks::run( 'BeforeDisplayOrangeAlert', [ $user, $title ] ) ) {
|
||||||
$personal_urls['mytalk']['text'] = $sk->msg( 'echo-new-messages' )->text();
|
$personal_urls['mytalk']['text'] = $sk->msg( 'echo-new-messages' )->text();
|
||||||
$personal_urls['mytalk']['class'] = [ 'mw-echo-alert' ];
|
$personal_urls['mytalk']['class'] = [ 'mw-echo-alert' ];
|
||||||
|
|
|
@ -254,13 +254,15 @@ class MWEchoNotifUser {
|
||||||
|
|
||||||
// After this 'mark read', is there any unread edit-user-talk
|
// After this 'mark read', is there any unread edit-user-talk
|
||||||
// remaining? If not, we should clear the newtalk flag.
|
// remaining? If not, we should clear the newtalk flag.
|
||||||
if ( $this->mUser->getNewtalk() ) {
|
$talkPageNotificationManager = MediaWikiServices::getInstance()
|
||||||
|
->getTalkPageNotificationManager();
|
||||||
|
if ( $talkPageNotificationManager->userHasNewMessages( $this->mUser ) ) {
|
||||||
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
||||||
$categoryMap = $attributeManager->getEventsByCategory();
|
$categoryMap = $attributeManager->getEventsByCategory();
|
||||||
$usertalkTypes = $categoryMap['edit-user-talk'];
|
$usertalkTypes = $categoryMap['edit-user-talk'];
|
||||||
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
||||||
if ( $unreadEditUserTalk === [] ) {
|
if ( $unreadEditUserTalk === [] ) {
|
||||||
$this->mUser->setNewtalk( false );
|
$talkPageNotificationManager->removeUserHasNewMessages( $this->mUser );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,13 +289,15 @@ class MWEchoNotifUser {
|
||||||
|
|
||||||
// After this 'mark unread', is there any unread edit-user-talk?
|
// After this 'mark unread', is there any unread edit-user-talk?
|
||||||
// If so, we should add the edit-user-talk flag
|
// If so, we should add the edit-user-talk flag
|
||||||
if ( !$this->mUser->getNewtalk() ) {
|
$talkPageNotificationManager = MediaWikiServices::getInstance()
|
||||||
|
->getTalkPageNotificationManager();
|
||||||
|
if ( !$talkPageNotificationManager->userHasNewMessages( $this->mUser ) ) {
|
||||||
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
$attributeManager = EchoAttributeManager::newFromGlobalVars();
|
||||||
$categoryMap = $attributeManager->getEventsByCategory();
|
$categoryMap = $attributeManager->getEventsByCategory();
|
||||||
$usertalkTypes = $categoryMap['edit-user-talk'];
|
$usertalkTypes = $categoryMap['edit-user-talk'];
|
||||||
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
$unreadEditUserTalk = $this->notifMapper->fetchUnreadByUser( $this->mUser, 1, null, $usertalkTypes, null, DB_MASTER );
|
||||||
if ( $unreadEditUserTalk !== [] ) {
|
if ( $unreadEditUserTalk !== [] ) {
|
||||||
$this->mUser->setNewtalk( true );
|
$talkPageNotificationManager->setUserHasNewMessages( $this->mUser );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
|
||||||
class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +122,9 @@ class EchoNotification extends EchoAbstractEntity implements Bundleable {
|
||||||
$notifMapper->insert( $this );
|
$notifMapper->insert( $this );
|
||||||
|
|
||||||
if ( $this->event->getCategory() === 'edit-user-talk' ) {
|
if ( $this->event->getCategory() === 'edit-user-talk' ) {
|
||||||
$this->user->setNewtalk( true );
|
MediaWikiServices::getInstance()
|
||||||
|
->getTalkPageNotificationManager()
|
||||||
|
->setUserHasNewMessages( $this->user );
|
||||||
}
|
}
|
||||||
Hooks::run( 'EchoCreateNotificationComplete', [ $this ] );
|
Hooks::run( 'EchoCreateNotificationComplete', [ $this ] );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue