mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Add Badges to Hovercards
Summary: Fixes T8942, Makes Badges if installed show up on your hovercard. Test Plan: Give a badge, mention myself, see badge on hovercard. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8942 Differential Revision: https://secure.phabricator.com/D13703
This commit is contained in:
parent
65bef30eb8
commit
0ba6569959
1 changed files with 32 additions and 0 deletions
|
@ -32,6 +32,7 @@ final class PhabricatorPeopleHovercardEventListener
|
|||
->withIDs(array($user->getID()))
|
||||
->needAvailability(true)
|
||||
->needProfile(true)
|
||||
->needBadges(true)
|
||||
->executeOne();
|
||||
|
||||
$hovercard->setTitle($user->getUsername());
|
||||
|
@ -65,8 +66,39 @@ final class PhabricatorPeopleHovercardEventListener
|
|||
->truncateString($profile->getBlurb()));
|
||||
}
|
||||
|
||||
$badges = $this->buildBadges($user, $viewer);
|
||||
foreach ($badges as $badge) {
|
||||
$hovercard->addBadge($badge);
|
||||
}
|
||||
|
||||
$event->setValue('hovercard', $hovercard);
|
||||
}
|
||||
|
||||
private function buildBadges(
|
||||
PhabricatorUser $user,
|
||||
$viewer) {
|
||||
|
||||
$class = 'PhabricatorBadgesApplication';
|
||||
$items = array();
|
||||
|
||||
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
||||
$badge_phids = $user->getBadgePHIDs();
|
||||
if ($badge_phids) {
|
||||
$badges = id(new PhabricatorBadgesQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs($badge_phids)
|
||||
->execute();
|
||||
|
||||
foreach ($badges as $badge) {
|
||||
$items[] = id(new PHUIBadgeMiniView())
|
||||
->setIcon($badge->getIcon())
|
||||
->setHeader($badge->getName())
|
||||
->setQuality($badge->getQuality());
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue