FIX: PWA install was broken due to missing basic logo

FIX: PWA install was broken due to missing basic logo

The current manifest validation in Chrome requires at least one non-maskable icon to make it installable.

This commit adds the maskable entry as another entry, following up on changes added in 3e590b8

diff --git a/app/controllers/metadata_controller.rb b/app/controllers/metadata_controller.rb
index 51d1a1e..279cb99 100644
--- a/app/controllers/metadata_controller.rb
+++ b/app/controllers/metadata_controller.rb
@@ -47,12 +47,16 @@ class MetadataController < ApplicationController
     }
 
     logo = SiteSetting.site_manifest_icon_url
-    manifest[:icons] << {
-      src: UrlHelper.absolute(logo),
-      purpose: "maskable",
-      sizes: "512x512",
-      type: MiniMime.lookup_by_filename(logo)&.content_type || "image/png"
-    } if logo
+    if logo
+      icon_entry = {
+        src: UrlHelper.absolute(logo),
+        sizes: "512x512",
+        type: MiniMime.lookup_by_filename(logo)&.content_type || "image/png"
+      }
+      manifest[:icons] << icon_entry.dup
+      icon_entry[:purpose] = "maskable"
+      manifest[:icons] << icon_entry
+    end
 
     manifest[:short_name] = SiteSetting.short_title if SiteSetting.short_title.present?

GitHub sha: 75436957

1 Like