Fix #4930: "Show scores" setting should be preserved
Make "show scores" setting persistent. The setting is stored in a `post_preview_show_votes` cookie. This means it's remembered on a per-device basis, but not on a per-account basis. This is so users without an account can use the setting, and so you can use different settings on desktop and mobile. The `view=score` URL param has been replaced by `show_votes=true`. The `show_votes` URL param overrides the `post_preview_show_votes` cookie.
This commit is contained in:
@@ -7,17 +7,18 @@ module PostSets
|
||||
MAX_PER_PAGE = 200
|
||||
MAX_SIDEBAR_TAGS = 25
|
||||
|
||||
attr_reader :page, :format, :tag_string, :query, :normalized_query, :view
|
||||
attr_reader :page, :format, :tag_string, :query, :normalized_query, :show_votes
|
||||
delegate :post_count, to: :normalized_query
|
||||
alias_method :show_votes?, :show_votes
|
||||
|
||||
def initialize(tags, page = 1, per_page = nil, user: CurrentUser.user, format: "html", view: "simple")
|
||||
def initialize(tags, page = 1, per_page = nil, user: CurrentUser.user, format: "html", show_votes: false)
|
||||
@query = PostQueryBuilder.new(tags, user, tag_limit: user.tag_query_limit, safe_mode: CurrentUser.safe_mode?, hide_deleted_posts: user.hide_deleted_posts?)
|
||||
@normalized_query = query.normalized_query
|
||||
@tag_string = tags
|
||||
@page = page
|
||||
@per_page = per_page
|
||||
@format = format.to_s
|
||||
@view = view.presence || "simple"
|
||||
@show_votes = show_votes
|
||||
end
|
||||
|
||||
def humanized_tag_string
|
||||
@@ -126,10 +127,6 @@ module PostSets
|
||||
end
|
||||
end
|
||||
|
||||
def show_votes?
|
||||
view == "score"
|
||||
end
|
||||
|
||||
def includes
|
||||
if show_votes?
|
||||
[:media_asset, :vote_by_current_user]
|
||||
|
||||
Reference in New Issue
Block a user