From 7ae038a68e4d651959c564fc883f42879c484b93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= <francisco.bolivar@nazaries.com>
Date: Tue, 15 Nov 2022 09:28:17 +0100
Subject: [PATCH 1/3] Fix resource_icon with component or manifest nil

---
 decidim-core/app/helpers/decidim/icon_helper.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/decidim-core/app/helpers/decidim/icon_helper.rb b/decidim-core/app/helpers/decidim/icon_helper.rb
index a2a7653bbecd8..8fc114730fdfa 100644
--- a/decidim-core/app/helpers/decidim/icon_helper.rb
+++ b/decidim-core/app/helpers/decidim/icon_helper.rb
@@ -42,9 +42,9 @@ def manifest_icon(manifest, options = {})
     def resource_icon(resource, options = {})
       if resource.class.name == "Decidim::Comments::Comment"
         icon "comment-square", options
-      elsif resource.respond_to?(:component)
+      elsif resource.respond_to?(:component) && resource.component.present?
         component_icon(resource.component, options)
-      elsif resource.respond_to?(:manifest)
+      elsif resource.respond_to?(:manifest) && resource.manifest.present?
         manifest_icon(resource.manifest, options)
       elsif resource.is_a?(Decidim::User)
         icon "person", options

From 4d3d9c0836a6af897436f718d2f3f7f96a02c915 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= <francisco.bolivar@nazaries.com>
Date: Wed, 16 Nov 2022 11:44:17 +0100
Subject: [PATCH 2/3] Add safe navigator to icon_helper to avoid undefined
 method error

---
 decidim-core/app/helpers/decidim/icon_helper.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/decidim-core/app/helpers/decidim/icon_helper.rb b/decidim-core/app/helpers/decidim/icon_helper.rb
index 8fc114730fdfa..d274c2522e914 100644
--- a/decidim-core/app/helpers/decidim/icon_helper.rb
+++ b/decidim-core/app/helpers/decidim/icon_helper.rb
@@ -24,7 +24,7 @@ def component_icon(component, options = {})
     #
     # Returns an HTML tag with the icon.
     def manifest_icon(manifest, options = {})
-      if manifest.icon
+      if manifest&.icon
         external_icon manifest.icon, options
       else
         icon "question-mark", options

From cd6b318e7dfd1cb697a1cb87401a2058451ffa1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Francisco=20Bol=C3=ADvar?= <francisco.bolivar@nazaries.com>
Date: Wed, 16 Nov 2022 11:55:15 +0100
Subject: [PATCH 3/3] Fix with respond_to? and present?

---
 decidim-core/app/helpers/decidim/icon_helper.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/decidim-core/app/helpers/decidim/icon_helper.rb b/decidim-core/app/helpers/decidim/icon_helper.rb
index d274c2522e914..ce2602bae2200 100644
--- a/decidim-core/app/helpers/decidim/icon_helper.rb
+++ b/decidim-core/app/helpers/decidim/icon_helper.rb
@@ -24,7 +24,7 @@ def component_icon(component, options = {})
     #
     # Returns an HTML tag with the icon.
     def manifest_icon(manifest, options = {})
-      if manifest&.icon
+      if manifest.respond_to?(:icon) && manifest.icon.present?
         external_icon manifest.icon, options
       else
         icon "question-mark", options