From 3c052e9e0e894dbdb6cfdce7dbf80597081e64c6 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 4 Mar 2023 18:40:29 +0100 Subject: [PATCH] Fix trivial lint issues --- app/models/inbox.rb | 6 ++++-- app/views/navigation/_desktop.html.haml | 2 +- app/views/navigation/_main.html.haml | 13 +++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/models/inbox.rb b/app/models/inbox.rb index 41372957..6a74687f 100644 --- a/app/models/inbox.rb +++ b/app/models/inbox.rb @@ -27,6 +27,8 @@ class Inbox < ApplicationRecord self.destroy end + def notification_icon = question.author_is_anonymous ? "/icons/maskable_icon_x128.png" : question.user.profile_picture.url(:small) + def as_push_notification { title: I18n.t( @@ -37,11 +39,11 @@ class Inbox < ApplicationRecord question.user.profile.safe_name end ), - icon: question.author_is_anonymous ? "/icons/maskable_icon_x128.png" : question.user.profile_picture.url(:small), + icon: notification_icon, body: question.content.truncate(Question::SHORT_QUESTION_MAX_LENGTH), data: { click_url: "/inbox", - } + }, } end end diff --git a/app/views/navigation/_desktop.html.haml b/app/views/navigation/_desktop.html.haml index 4739226f..2d8093bc 100644 --- a/app/views/navigation/_desktop.html.haml +++ b/app/views/navigation/_desktop.html.haml @@ -10,7 +10,7 @@ DEV %ul.nav.navbar-nav.me-auto = nav_entry t("navigation.timeline"), root_path, icon: 'home' - = nav_entry t("navigation.inbox"), '/inbox', icon: 'inbox', badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } } + = nav_entry t("navigation.inbox"), "/inbox", icon: "inbox", badge: inbox_count, badge_attr: { data: { controller: "pwa-badge" } } - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t("navigation.discover"), discover_path, icon: 'compass' %ul.nav.navbar-nav diff --git a/app/views/navigation/_main.html.haml b/app/views/navigation/_main.html.haml index 76baee17..a58e50b1 100644 --- a/app/views/navigation/_main.html.haml +++ b/app/views/navigation/_main.html.haml @@ -1,9 +1,10 @@ -- notifications = Notification.for(current_user).where(new: true).includes([:target]).limit(4) -- inbox_count = current_user.unread_inbox_count -- notification_count = current_user.unread_notification_count -= render 'navigation/desktop', notifications:, inbox_count:, notification_count: -= render 'navigation/mobile', inbox_count:, notification_count: +:ruby + notifications = Notification.for(current_user).where(new: true).includes([:target]).limit(4) + inbox_count = current_user.unread_inbox_count + notification_count = current_user.unread_notification_count += render "navigation/desktop", notifications:, inbox_count:, notification_count: += render "navigation/mobile", inbox_count:, notification_count: -= render 'modal/ask' += render "modal/ask" %button.btn.btn-primary.btn-fab.d-block.d-lg-none.d-print-none{ data: { bs_target: "#modal-ask-followers", bs_toggle: :modal }, type: "button" } %i.fa.fa-pencil-square-o