Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(widget): Implement icon handling for widget api
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Feb 2, 2023
commit 9e3f6657a7d0e9825e680fae1cd51146b49d3469
13 changes: 11 additions & 2 deletions lib/AppInfo/DashboardWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
use OCA\Notes\Service\NotesService;
use OCP\Dashboard\IAPIWidget;
use OCP\Dashboard\IButtonWidget;
use OCP\Dashboard\IIconWidget;
use OCP\Dashboard\IWidget;
use OCP\Dashboard\Model\WidgetButton;
use OCP\Dashboard\Model\WidgetItem;
use OCP\IL10N;
use OCP\IURLGenerator;

class DashboardWidget implements IWidget, IButtonWidget, IAPIWidget {
class DashboardWidget implements IWidget, IButtonWidget, IAPIWidget, IIconWidget {
private IURLGenerator $url;
private IL10N $l10n;
private NotesService $notesService;
Expand Down Expand Up @@ -91,8 +92,16 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
} catch (\Throwable $e) {
}
$link = $this->url->linkToRouteAbsolute('notes.page.indexnote', ['id' => $note->getId()]);
$icon = $note->getFavorite() ? $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg')) : '';
$icon = $this->url->getAbsoluteURL(
$note->getFavorite()
? $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/starred.svg'))
: $this->getIconUrl()
);
return new WidgetItem($note->getTitle(), $excerpt, $link, $icon, (string)$note->getModified());
}, $notes);
}

public function getIconUrl(): string {
return $this->url->getAbsoluteURL($this->url->imagePath('notes', 'notes-dark.svg'));
}
}