Skip to content

Commit

Permalink
use since param to build widget item list
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Sep 16, 2022
1 parent 0c95e7c commit 44127d4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Dashboard/DeckWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ public function load(): void {
public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
$upcomingCards = $this->dashboardService->findUpcomingCards($userId);
$nowTimestamp = (new Datetime())->getTimestamp();
$upcomingCards = array_filter($upcomingCards, static function(array $card) use ($nowTimestamp) {
$sinceTimestamp = $since !== null ? (new Datetime($since))->getTimestamp() : null;
$upcomingCards = array_filter($upcomingCards, static function(array $card) use ($nowTimestamp, $sinceTimestamp) {
if ($card['duedate']) {
$ts = (new Datetime($card['duedate']))->getTimestamp();
return $ts > $nowTimestamp;
return $ts > $nowTimestamp && ($sinceTimestamp === null || $ts > $sinceTimestamp);
}
return false;
});
Expand Down

0 comments on commit 44127d4

Please sign in to comment.