Skip to content

Commit

Permalink
refactor: revert inline_svg optimization (#3179)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianthedev authored Aug 23, 2024
1 parent 806c0b9 commit 792390d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion app/assets/config/avo_manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//= link_directory ../images/avo
//= link_directory ../svgs
//= link_tree ../builds
//= link avo-rhino_field
11 changes: 3 additions & 8 deletions app/helpers/avo/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module ApplicationHelper
include ::Pagy::Frontend
include Avo::ResourcesHelper

AVO_CACHED_SVGS = {}

def render_license_warning(title: "", message: "", icon: "exclamation")
render partial: "avo/sidebar/license_warning", locals: {
title: title,
Expand Down Expand Up @@ -67,12 +65,9 @@ def svg(file_name, **args)

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

inline_svg svg_path(file_name), **args
end

# The path shouldn't change between reboots so we can memoize the paths based on the filename.
def svg_path(file_name)
AVO_CACHED_SVGS[file_name] ||= Avo::SvgFinder.find_asset(file_name).pathname.to_s
with_asset_finder(::Avo::SvgFinder) do
inline_svg file_name, **args
end
end

def input_classes(extra_classes = "", has_error: false)
Expand Down
2 changes: 1 addition & 1 deletion lib/avo/svg_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def paths
Avo::Engine.root.join("app", "assets", "svgs", "heroicons", "outline", @filename),
Avo::Engine.root.join(@filename).to_s,
# Add all paths from Rails including engines
*Rails.application.assets.paths.map { |path| File.join(path, @filename) }
*Rails.application.config.assets&.paths&.map { |path| File.join(path, @filename) }
].map(&:to_s).uniq
end

Expand Down

0 comments on commit 792390d

Please sign in to comment.