Skip to content

Commit 9e3f665

Browse files
committed
fix(widget): Implement icon handling for widget api
Signed-off-by: Julius Härtl <[email protected]>
1 parent e08d9f7 commit 9e3f665

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/AppInfo/DashboardWidget.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
use OCA\Notes\Service\NotesService;
99
use OCP\Dashboard\IAPIWidget;
1010
use OCP\Dashboard\IButtonWidget;
11+
use OCP\Dashboard\IIconWidget;
1112
use OCP\Dashboard\IWidget;
1213
use OCP\Dashboard\Model\WidgetButton;
1314
use OCP\Dashboard\Model\WidgetItem;
1415
use OCP\IL10N;
1516
use OCP\IURLGenerator;
1617

17-
class DashboardWidget implements IWidget, IButtonWidget, IAPIWidget {
18+
class DashboardWidget implements IWidget, IButtonWidget, IAPIWidget, IIconWidget {
1819
private IURLGenerator $url;
1920
private IL10N $l10n;
2021
private NotesService $notesService;
@@ -91,8 +92,16 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
9192
} catch (\Throwable $e) {
9293
}
9394
$link = $this->url->linkToRouteAbsolute('notes.page.indexnote', ['id' => $note->getId()]);
94-
$icon = $note->getFavorite() ? $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')) : '';
95+
$icon = $this->url->getAbsoluteURL(
96+
$note->getFavorite()
97+
? $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))
98+
: $this->getIconUrl()
99+
);
95100
return new WidgetItem($note->getTitle(), $excerpt, $link, $icon, (string)$note->getModified());
96101
}, $notes);
97102
}
103+
104+
public function getIconUrl(): string {
105+
return $this->url->getAbsoluteURL($this->url->imagePath('notes', 'notes-dark.svg'));
106+
}
98107
}

0 commit comments

Comments
 (0)