<% value.each do |link_code| %> <% klass, id = link_code.split('-') %> <%# In most cases, a user will be seeing their own content most of the time. This allows us to primarily rely on @current_user_content but fall back on js-load-page-name to fetch & load in post-page-load if the content isn't ours. %> <% content = if user_signed_in? @current_user_content.fetch(klass, []).detect do |page| page.page_type === klass && page.id === id.to_i end else nil end %> <%# TODO: we should extract chips out into a react component, probably %>
<%= link_to send("#{klass.downcase}_path", id) do %> <%= content_class_from_name(klass).icon %> <%= content.try(:name) || "Loading #{klass}".html_safe %> <% end %>
<% end %>