From b8b86b069d632285ff1fc78f020c5393130359e7 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 27 Jan 2023 23:08:12 +0100 Subject: [PATCH] Cache headers for web app manifest based on user theme --- app/controllers/manifests_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/manifests_controller.rb b/app/controllers/manifests_controller.rb index 966f6164..1a66ff85 100644 --- a/app/controllers/manifests_controller.rb +++ b/app/controllers/manifests_controller.rb @@ -3,7 +3,13 @@ class ManifestsController < ApplicationController include ThemeHelper + skip_before_action :banned? + skip_before_action :find_active_announcements + def show + expires_in 1.day + return if fresh_when current_user&.theme + render json: { name: APP_CONFIG["site_name"], description: t("about.index.subtitle"), @@ -12,17 +18,19 @@ class ManifestsController < ApplicationController display: "standalone", categories: %w[social], lang: I18n.locale, - shortcuts: [ - webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox") - ], + shortcuts:, icons: webapp_icons, - theme_color: theme_color, + theme_color:, background_color: mobile_theme_color } end private + def shortcuts = [ + webapp_shortcut(inbox_url, t("navigation.inbox"), "inbox") + ] + def webapp_shortcut(url, name, icon_name) { name: name,