Skip to content

Commit

Permalink
adjustments in dashboard widget declaration
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier authored and nickvergessen committed Sep 19, 2022
1 parent 3ad375e commit 7b835e7
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions lib/Dashboard/ActivityWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ class ActivityWidget implements IAPIWidget, IButtonWidget, IIconWidget {
private IDateTimeFormatter $dateTimeFormatter;
private IURLGenerator $urlGenerator;

/**
* ActivityWidget constructor.
* @param IL10N $l10n
* @param Data $data
* @param GroupHelper $helper
* @param UserSettings $settings
* @param IURLGenerator $urlGenerator
* @param IDateTimeFormatter $dateTimeFormatter
*/
public function __construct(IL10N $l10n,
Data $data,
GroupHelper $helper,
Expand Down Expand Up @@ -111,7 +102,9 @@ public function getIconUrl(): string {
* @inheritDoc
*/
public function getUrl(): ?string {
return null;
return $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute(Application::APP_ID . '.Activities.showList')
);
}

/**
Expand All @@ -125,6 +118,8 @@ public function load(): void {
* @inheritDoc
*/
public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
// we set the limit to 50 here because data->get might return less activity entries
// in the end we take the first 7 of'em
$activities = $this->data->get(
$this->helper,
$this->settings,
Expand All @@ -141,9 +136,7 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$activity['subject'],
$this->dateTimeFormatter->formatTimeSpan($activity['timestamp']),
$activity['link'],
$this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $activity['affecteduser'], 'size' => 44])
),
$activity['icon'],
(string) $activity['activity_id']
);
}, array_slice($activities['data'], 0, $limit));
Expand Down

0 comments on commit 7b835e7

Please sign in to comment.