FIX: Calculate experiment_enabled on server for "What's new?" (#30599)

Experimental "What's new?" feature feed items previously calculated
a boolean for experimentEnabled on the client based on the siteSettings
service, and this would control the initial state of the experiment
toggle.

However this requires the person who creates the site setting for the
experiment to remember to set it to `client: true`. This commit removes
that manual step by calculating whether the experiment is enabled
server-side, where we have access to all the site settings.
This commit is contained in:
Martin Brennan
2025-01-07 11:27:24 +10:00
committed by GitHub
parent f015ea897e
commit 725e146dca
5 changed files with 22 additions and 16 deletions

View File

@ -156,8 +156,14 @@ module DiscourseUpdates
entries.map! do |item|
next item if !item["experiment_setting"]
item["experiment_setting"] = nil if !SiteSetting.respond_to?(item["experiment_setting"]) ||
SiteSetting.type_supervisor.get_type(item["experiment_setting"].to_sym) != :bool
if !SiteSetting.respond_to?(item["experiment_setting"]) ||
SiteSetting.type_supervisor.get_type(item["experiment_setting"].to_sym) != :bool
item["experiment_setting"] = nil
item["experiment_enabled"] = false
else
item["experiment_enabled"] = SiteSetting.send(item["experiment_setting"].to_sym) if item
end
item
end