Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/calendar.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Larch <anna@nextcloud.com>2022-10-27 15:19:15 +0300
committerAnna Larch <anna@nextcloud.com>2022-10-27 22:31:20 +0300
commita5448476a36b7fb53e3464f2bd3e8010a5f28a4f (patch)
treecd920023206b852235321fe9ec59b40c8952676f
parentfd86c3729ecee3e7801c74b16e60d67619ab68cd (diff)
Fix search results returning past events
for calendar widget Signed-off-by: Anna Larch <anna@nextcloud.com>
-rw-r--r--lib/Dashboard/CalendarWidget.php12
-rw-r--r--tests/php/unit/Dashbaord/CalendarWidgetTest.php2
2 files changed, 3 insertions, 11 deletions
diff --git a/lib/Dashboard/CalendarWidget.php b/lib/Dashboard/CalendarWidget.php
index cebe2662..662cf24f 100644
--- a/lib/Dashboard/CalendarWidget.php
+++ b/lib/Dashboard/CalendarWidget.php
@@ -142,21 +142,13 @@ class CalendarWidget implements IAPIWidget, IButtonWidget, IIconWidget, IOptionW
* @param string|null $since Use any PHP DateTime allowed values to get future dates
* @param int $limit Max 14 items is the default
*/
- public function getItems(string $userId, ?string $since = null, int $limit = 14): array {
+ public function getItems(string $userId, ?string $since = null, int $limit = 7): array {
$calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $userId);
$count = count($calendars);
if ($count === 0) {
return [];
}
- $limitPerCalendar = (int)round(($limit / $count)) ?? 1;
$dateTime = (new DateTimeImmutable())->setTimestamp($this->timeFactory->getTime());
- if ($since !== null) {
- try {
- $dateTime = new DateTimeImmutable($since);
- } catch (\Exception $e) {
- // silently drop the exception and proceed with "now"
- }
- }
$inTwoWeeks = $dateTime->add(new DateInterval('P14D'));
$options = [
'timerange' => [
@@ -166,7 +158,7 @@ class CalendarWidget implements IAPIWidget, IButtonWidget, IIconWidget, IOptionW
];
$widgetItems = [];
foreach ($calendars as $calendar) {
- $searchResult = $calendar->search('', [], $options, $limitPerCalendar);
+ $searchResult = $calendar->search('', [], $options, $limit);
foreach ($searchResult as $calendarEvent) {
/** @var DateTimeImmutable $startDate */
$startDate = $calendarEvent['objects'][0]['DTSTART'][0];
diff --git a/tests/php/unit/Dashbaord/CalendarWidgetTest.php b/tests/php/unit/Dashbaord/CalendarWidgetTest.php
index 58907b2c..81c608e4 100644
--- a/tests/php/unit/Dashbaord/CalendarWidgetTest.php
+++ b/tests/php/unit/Dashbaord/CalendarWidgetTest.php
@@ -137,7 +137,7 @@ class CalendarWidgetTest extends TestCase {
'end' => $twoWeeks,
]
];
- $limit = 14;
+ $limit = 7;
$result = [
'id' => '3599',
'uid' => '59d30b6c-5a31-4d28-b1d6-c8f928180e96',