aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib/Dashboard/UserStatusWidget.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_status/lib/Dashboard/UserStatusWidget.php')
-rw-r--r--apps/user_status/lib/Dashboard/UserStatusWidget.php63
1 files changed, 16 insertions, 47 deletions
diff --git a/apps/user_status/lib/Dashboard/UserStatusWidget.php b/apps/user_status/lib/Dashboard/UserStatusWidget.php
index 127f95d0a0e..2870a2c1907 100644
--- a/apps/user_status/lib/Dashboard/UserStatusWidget.php
+++ b/apps/user_status/lib/Dashboard/UserStatusWidget.php
@@ -3,26 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2020, Georg Ehrke
- *
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Richard Steinmetz <richard@steinmetz.cloud>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\UserStatus\Dashboard;
@@ -50,14 +32,6 @@ use OCP\UserStatus\IUserStatus;
* @package OCA\UserStatus
*/
class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOptionWidget {
- private IL10N $l10n;
- private IDateTimeFormatter $dateTimeFormatter;
- private IURLGenerator $urlGenerator;
- private IInitialState $initialStateService;
- private IUserManager $userManager;
- private IUserSession $userSession;
- private StatusService $service;
-
/**
* UserStatusWidget constructor
*
@@ -69,20 +43,15 @@ class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOption
* @param IUserSession $userSession
* @param StatusService $service
*/
- public function __construct(IL10N $l10n,
- IDateTimeFormatter $dateTimeFormatter,
- IURLGenerator $urlGenerator,
- IInitialState $initialStateService,
- IUserManager $userManager,
- IUserSession $userSession,
- StatusService $service) {
- $this->l10n = $l10n;
- $this->dateTimeFormatter = $dateTimeFormatter;
- $this->urlGenerator = $urlGenerator;
- $this->initialStateService = $initialStateService;
- $this->userManager = $userManager;
- $this->userSession = $userSession;
- $this->service = $service;
+ public function __construct(
+ private IL10N $l10n,
+ private IDateTimeFormatter $dateTimeFormatter,
+ private IURLGenerator $urlGenerator,
+ private IInitialState $initialStateService,
+ private IUserManager $userManager,
+ private IUserSession $userSession,
+ private StatusService $service,
+ ) {
}
/**
@@ -142,7 +111,7 @@ class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOption
$this->service->findAllRecentStatusChanges($limit + 1, 0),
static function (UserStatus $status) use ($userId, $since): bool {
return $status->getUserId() !== $userId
- && ($since === null || $status->getStatusTimestamp() > (int) $since);
+ && ($since === null || $status->getStatusTimestamp() > (int)$since);
}
),
0,
@@ -174,21 +143,21 @@ class UserStatusWidget implements IAPIWidget, IAPIWidgetV2, IIconWidget, IOption
public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
$widgetItemsData = $this->getWidgetData($userId, $since, $limit);
- return array_map(function (array $widgetData) {
+ return array_values(array_map(function (array $widgetData) {
$formattedDate = $this->dateTimeFormatter->formatTimeSpan($widgetData['timestamp']);
return new WidgetItem(
$widgetData['displayName'],
$widgetData['icon'] . ($widgetData['icon'] ? ' ' : '') . $widgetData['message'] . ', ' . $formattedDate,
// https://nextcloud.local/index.php/u/julien
$this->urlGenerator->getAbsoluteURL(
- $this->urlGenerator->linkToRoute('core.ProfilePage.index', ['targetUserId' => $widgetData['userId']])
+ $this->urlGenerator->linkToRoute('profile.ProfilePage.index', ['targetUserId' => $widgetData['userId']])
),
$this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $widgetData['userId'], 'size' => 44])
),
- (string) $widgetData['timestamp']
+ (string)$widgetData['timestamp']
);
- }, $widgetItemsData);
+ }, $widgetItemsData));
}
/**