Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix svg caching #3471

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/avo/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def svg(file_name, **args)

file_name = "#{file_name}.svg" unless file_name.end_with? ".svg"

Avo::CACHED_SVGS[file_name] ||= with_asset_finder(::Avo::SvgFinder) do
with_asset_finder(::Avo::SvgFinder) do
inline_svg file_name, **args
end
end
Expand Down
12 changes: 7 additions & 5 deletions lib/avo/svg_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ def initialize(filename)

# Use the default static finder logic. If that doesn't find anything, search according to our pattern:
def pathname
found_asset = default_strategy
Avo::CACHED_SVGS[@filename] ||= begin
found_asset = default_strategy

# Use the found asset
return found_asset if found_asset.present?
# Use the found asset
return found_asset if found_asset.present?

paths.find do |path|
File.exist? path
paths.find do |path|
File.exist? path
end
end
end

Expand Down
Loading