Skip to content

Commit

Permalink
Merge pull request #1966 from MushroomObserver/revert-a-few-things
Browse files Browse the repository at this point in the history
Reverting a few changes from commit ca33c12
  • Loading branch information
pellaea committed Feb 27, 2024
2 parents c1a7245 + 5fc8eca commit 662f5d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
10 changes: 2 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,6 @@ def index
# id:: Warp to page that includes object with this id.
# action:: Template used to render results.
# matrix:: Displaying results as matrix?
# cache:: Cache the HTML of the results?
# letters:: Paginating by letter?
# letter_arg:: Param used to store letter for pagination.
# number_arg:: Param used to store page number for pagination.
Expand Down Expand Up @@ -1471,11 +1470,6 @@ def skip_if_coming_back(query, args)
end
end

# NOTE: there are two places where cache args have to be sent to enable
# efficient caching. Sending `cache: true` here to `show_index_of_objects`
# allows us to optimize eager-loading, doing it only for records not cached.
# (The other place is from the template to the `matrix_box` helper, which
# actually caches the HTML.)
def find_objects(query, args)
caching = args[:cache] || false
include = args[:include] || nil
Expand Down Expand Up @@ -1516,11 +1510,11 @@ def objects_with_only_needed_eager_loads(query, include)
# Check if a cached partial exists for this object.
# digest_path_from_template from ActionView::Helpers::CacheHelper :nodoc:
# https://stackoverflow.com/a/77862353/3357635
def object_fragment_exist?(obj, locale)
def object_fragment_exist?(obj, user, locale)
template = lookup_context.find(action_name, lookup_context.prefixes)
digest_path = helpers.digest_path_from_template(template)

fragment_exist?([digest_path, obj, locale])
fragment_exist?([digest_path, obj, user, locale])
end

def show_index_render(args)
Expand Down
18 changes: 9 additions & 9 deletions app/helpers/matrix_box_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def render_cached_matrix_boxes(objects, locals)
# matrix box has one version except langs.
# css hides image vote ui when body.no-user
objects.each do |object|
cache(object) do
concat(render(partial: "shared/matrix_box",
locals: { object: object }.merge(locals)))
end
# cache(object) do
concat(render(partial: "shared/matrix_box",
locals: { object: object }.merge(locals)))
# end
end
end

Expand Down Expand Up @@ -79,23 +79,23 @@ def matrix_box_image(image = nil, **args)
# end

# NOTE: object_id may be "no_ID" for logs of deleted records
def matrix_box_details(presenter, object_id, identify)
def matrix_box_details(presenter, object, object_id, identify)
tag.div(class: "panel-body rss-box-details") do
[
matrix_box_what(presenter, object_id, identify),
matrix_box_what(presenter, object, object_id, identify),
matrix_box_where(presenter),
matrix_box_when_who(presenter)
].safe_join
end
end

def matrix_box_what(presenter, object_id, identify)
def matrix_box_what(presenter, object, object_id, identify)
# heading style: bigger if no image.
# TODO: make box layouts specific to object type
h_style = presenter.image_data ? "h5" : "h3"
what = presenter.what # for an obs or rss_log, it's the obs
what = presenter.what
consensus = presenter.consensus || nil
identify_ui = matrix_box_vote_or_propose_ui(identify, what, consensus)
identify_ui = matrix_box_vote_or_propose_ui(identify, object, consensus)

tag.div(class: "rss-what") do
[
Expand Down
2 changes: 1 addition & 1 deletion app/views/controllers/shared/_matrix_box.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if presenter
[
# Helper Dependency Updated: Jan 14, 2024 at 3am
matrix_box_image(image, **image_args),
matrix_box_details(presenter, object_id, identify),
matrix_box_details(presenter, object, object_id, identify),
].safe_join
end,
matrix_box_log_footer(presenter),
Expand Down

0 comments on commit 662f5d9

Please sign in to comment.