Skip to content

Commit

Permalink
fix: added count and removed slice
Browse files Browse the repository at this point in the history
Signed-off-by: yemkareems <[email protected]>
  • Loading branch information
yemkareems committed Jan 8, 2025
1 parent c6fdaca commit 909e9ee
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions apps/files/lib/Dashboard/FavoriteWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function getItems(string $userId, int $limit = 7): array {
}
$favoriteNodes = [];
$userFolder = $this->rootFolder->getUserFolder($userId);
$count = 0;
foreach ($favorites as $favorite) {
$node = $userFolder->getFirstNodeById($favorite);
if ($node) {
Expand All @@ -99,17 +100,22 @@ public function getItems(string $userId, int $limit = 7): array {
$this->mimeTypeDetector->mimeTypeIcon($node->getMimetype())
);
}
$favoriteNodes[] = new WidgetItem(
$node->getName(),
'',
$url,
$icon,
(string)$node->getCreationTime()
);
if($count < $limit) {
$favoriteNodes[] = new WidgetItem(
$node->getName(),
'',
$url,
$icon,
(string)$node->getCreationTime()
);
$count++;
} else {
break;
}
}
}

return array_slice($favoriteNodes, 0, $limit);
return $favoriteNodes;
}

public function getItemsV2(string $userId, ?string $since = null, int $limit = 7): WidgetItems {
Expand Down

0 comments on commit 909e9ee

Please sign in to comment.