diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index aa35df0b3..1de45b5c9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, WriterAffinity + include Authentication, Authorization, CurrentRequest, CurrentTimezone, SetPlatform, TurboFlash, ViewTransitions, WriterAffinity stale_when_importmap_changes allow_browser versions: :modern, block: -> { render "errors/not_acceptable", layout: "error" } diff --git a/app/controllers/concerns/view_transitions.rb b/app/controllers/concerns/view_transitions.rb new file mode 100644 index 000000000..94b9c0a55 --- /dev/null +++ b/app/controllers/concerns/view_transitions.rb @@ -0,0 +1,16 @@ +module ViewTransitions + extend ActiveSupport::Concern + + included do + before_action :disable_view_transitions, if: :page_refresh? + end + + private + def disable_view_transitions + @disable_view_transition = true + end + + def page_refresh? + request.referrer.present? && request.referrer == request.url + end +end diff --git a/app/helpers/cards_helper.rb b/app/helpers/cards_helper.rb index 07a6b931f..2ab894086 100644 --- a/app/helpers/cards_helper.rb +++ b/app/helpers/cards_helper.rb @@ -33,8 +33,4 @@ module CardsHelper title << "assigned to #{card.assignees.map(&:name).to_sentence}" if card.assignees.any? title.join(" ") end - - def cacheable_preview_parts_for(card, *options) - [ card, card.collection, card.collection.entropy_configuration, card.collection.publication, card.column&.color, *options ] - end end diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb new file mode 100644 index 000000000..ac1debab4 --- /dev/null +++ b/app/helpers/collections_helper.rb @@ -0,0 +1,5 @@ +module CollectionsHelper + def referenced_collections_from(records) + Current.user.collections.where id: records.pluck(:collection_id).uniq + end +end diff --git a/app/views/cards/_broadcasts.html.erb b/app/views/cards/_broadcasts.html.erb new file mode 100644 index 000000000..d2404ae68 --- /dev/null +++ b/app/views/cards/_broadcasts.html.erb @@ -0,0 +1,3 @@ +<% referenced_collections_from(records).each do |collection| %> + <%= turbo_stream_from collection %> +<% end %> diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index 99121d028..d700b363a 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -1,7 +1,7 @@ <% @page_title = @user_filtering.selected_collections_label %> <% turbo_exempts_page_from_cache %> -<%= render "filters/broadcasts", filter: @filter %> +<%= render "cards/broadcasts", records: @page.records %> <% content_for :head do %> <%= tag.meta property: "og:title", content: @page_title %> @@ -28,7 +28,7 @@ <%= turbo_frame_tag :cards_container do %>
<%= with_automatic_pagination :cards_paginated_container, @page do %> - <%= render partial: "cards/display/preview", collection: @page.records, as: :card, locals: { draggable: true }, cached: ->(card) { cacheable_preview_parts_for(card) } %> + <%= render partial: "cards/display/preview", collection: @page.records, as: :card, locals: { draggable: true }, cached: ->(card) { card.cache_invalidation_parts.for_preview } %> <% end %>
<% end %> diff --git a/app/views/collections/show/_filtered_cards.html.erb b/app/views/collections/show/_filtered_cards.html.erb index 63afd2920..9925e1e0a 100644 --- a/app/views/collections/show/_filtered_cards.html.erb +++ b/app/views/collections/show/_filtered_cards.html.erb @@ -1,5 +1,5 @@
<%= with_automatic_pagination :filtered_cards_paginated_container, page do %> - <%= render partial: "cards/display/preview", collection: page.records, as: :card, locals: { draggable: true }, cached: ->(card) { cacheable_preview_parts_for(card) } %> + <%= render partial: "cards/display/preview", collection: page.records, as: :card, locals: { draggable: true }, cached: ->(card) { card.cache_invalidation_parts.for_preview } %> <% end %>
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index d6a777d40..4868a5295 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Home" %> <% @header_class = "header--events" %> -<%= render "filters/broadcasts", filter: @filter %> +<%= render "cards/broadcasts", records: @day_timeline.events %> <% content_for :header do %> <%= render "filters/menu" %> diff --git a/app/views/filters/_broadcasts.html.erb b/app/views/filters/_broadcasts.html.erb deleted file mode 100644 index a432280e6..000000000 --- a/app/views/filters/_broadcasts.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% if filter.collections.any? %> - <% filter.collections.each do |collection| %> - <%= turbo_stream_from collection %> - <% end %> -<% else %> - <%= turbo_stream_from :collections %> -<% end %> diff --git a/app/views/layouts/shared/_head.html.erb b/app/views/layouts/shared/_head.html.erb index 25b06cae9..4c88b0190 100644 --- a/app/views/layouts/shared/_head.html.erb +++ b/app/views/layouts/shared/_head.html.erb @@ -2,7 +2,10 @@ <%= page_title_tag %> - + + <% unless @disable_view_transition %> + + <% end %>