mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
FIX: Preload readonly mode attribute seperately.
There are two problems I'm trying to tackle here. 1. The site json is cached for anonymous users so readonly mode can be cached for up to 30 minutes which makes it confusing. 2. We've already checked for readonly mode in the controller so having to check for readonly mode again in `SiteSerializer` is adding an extra Redis query on every request.
This commit is contained in:
parent
2e2dcb7d93
commit
62ad473716
|
@ -132,7 +132,9 @@ Site.reopenClass(Singleton, {
|
|||
// The current singleton will retrieve its attributes from the `PreloadStore`.
|
||||
createCurrent() {
|
||||
const store = Discourse.__container__.lookup("service:store");
|
||||
return store.createRecord("site", PreloadStore.get("site"));
|
||||
const siteAttributes = PreloadStore.get("site");
|
||||
siteAttributes["isReadOnly"] = PreloadStore.get("isReadOnly");
|
||||
return store.createRecord("site", siteAttributes);
|
||||
},
|
||||
|
||||
create() {
|
||||
|
|
|
@ -539,6 +539,7 @@ class ApplicationController < ActionController::Base
|
|||
store_preloaded("customHTML", custom_html_json)
|
||||
store_preloaded("banner", banner_json)
|
||||
store_preloaded("customEmoji", custom_emoji)
|
||||
store_preloaded("isReadOnly", @readonly_mode.to_s)
|
||||
end
|
||||
|
||||
def preload_current_user_data
|
||||
|
|
|
@ -12,7 +12,6 @@ class SiteSerializer < ApplicationSerializer
|
|||
:top_menu_items,
|
||||
:anonymous_top_menu_items,
|
||||
:uncategorized_category_id, # this is hidden so putting it here
|
||||
:is_readonly,
|
||||
:disabled_plugins,
|
||||
:user_field_max_length,
|
||||
:post_action_types,
|
||||
|
@ -95,10 +94,6 @@ class SiteSerializer < ApplicationSerializer
|
|||
SiteSetting.uncategorized_category_id
|
||||
end
|
||||
|
||||
def is_readonly
|
||||
Discourse.readonly_mode?
|
||||
end
|
||||
|
||||
def disabled_plugins
|
||||
Discourse.disabled_plugin_names
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user