From 34b07d64fd15653af6e7fc842e62736797718953 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 8 Jun 2022 12:32:27 +0200 Subject: [PATCH] fix search fallback icon [skip ci] Signed-off-by: Julien Veyssier --- css/cospend-search.css | 9 +++++++++ lib/AppInfo/Application.php | 3 ++- lib/Search/CospendSearchProvider.php | 11 +++-------- 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 css/cospend-search.css diff --git a/css/cospend-search.css b/css/cospend-search.css new file mode 100644 index 00000000..98639d00 --- /dev/null +++ b/css/cospend-search.css @@ -0,0 +1,9 @@ +.icon-cospend-search-fallback { + background-image: url(./../img/app_black.svg); + filter: var(--background-invert-if-dark); +} + +/* for NC <= 24 */ +body.theme--dark .icon-cospend-search-fallback { + background-image: url(./../img/app.svg); +} diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 935d01e1..a7cd9ab3 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -20,6 +20,7 @@ use OCP\Notification\IManager as INotificationManager; use OCA\Cospend\Search\CospendSearchProvider; use OCA\Cospend\Dashboard\CospendWidget; use OCA\Cospend\Notification\Notifier; +use OCP\Util; /** * Class Application @@ -91,7 +92,7 @@ class Application extends App implements IBootstrap { } public function boot(IBootContext $context): void { + Util::addStyle(self::APP_ID, 'cospend-search'); } - } diff --git a/lib/Search/CospendSearchProvider.php b/lib/Search/CospendSearchProvider.php index c062c24b..80d3bf23 100644 --- a/lib/Search/CospendSearchProvider.php +++ b/lib/Search/CospendSearchProvider.php @@ -124,11 +124,6 @@ class CospendSearchProvider implements IProvider { $offset = $query->getCursor(); $offset = $offset ? (int) $offset : 0; - $theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme'); - $thumbnailUrl = ($theme === 'dark') ? - $this->urlGenerator->imagePath('cospend', 'app.svg') : - $this->urlGenerator->imagePath('cospend', 'app_black.svg'); - $resultBills = []; // get user's projects @@ -154,15 +149,15 @@ class CospendSearchProvider implements IProvider { $resultBills = array_slice($resultBills, $offset, $limit); // build formatted - $formattedResults = array_map(function (array $bill) use ($projectsById, $thumbnailUrl):CospendSearchResultEntry { + $formattedResults = array_map(function (array $bill) use ($projectsById):CospendSearchResultEntry { $projectId = $bill['projectId']; // $projectName = $projectsById[$projectId]['name']; return new CospendSearchResultEntry( - $thumbnailUrl, + '', $this->getMainText($bill, $projectsById[$projectId]), $this->getSubline($bill, $projectsById[$projectId]), $this->getDeepLinkToCospendApp($projectId, $bill['id']), - '', + 'icon-cospend-search-fallback', false ); }, $resultBills);