FIX: Preload user sidebar attrs when ?enable_sidebar=1 (#19843)

This allows users to preview the sidebar even when
`SiteSetting.naviation_menu` is set to `false`.
This commit is contained in:
Alan Guo Xiang Tan
2023-01-13 06:47:58 +08:00
committed by GitHub
parent 3030a53819
commit 5db72f8daf
5 changed files with 54 additions and 2 deletions

View File

@ -640,15 +640,25 @@ class ApplicationController < ActionController::Base
def preload_current_user_data
store_preloaded(
"currentUser",
MultiJson.dump(CurrentUserSerializer.new(current_user, scope: guardian, root: false)),
MultiJson.dump(
CurrentUserSerializer.new(
current_user,
scope: guardian,
root: false,
enable_sidebar_param: params[:enable_sidebar],
),
),
)
report = TopicTrackingState.report(current_user)
serializer =
ActiveModel::ArraySerializer.new(
report,
each_serializer: TopicTrackingStateSerializer,
scope: guardian,
)
store_preloaded("topicTrackingStates", MultiJson.dump(serializer))
end