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:
Guo Xiang Tan
2020-06-12 09:54:05 +08:00
parent 2e2dcb7d93
commit 62ad473716
3 changed files with 4 additions and 6 deletions

View File

@ -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