Merge pull request #1303 from basecamp/card-broadcasts
Improve page refreshes
This commit is contained in:
@@ -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" }
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module CollectionsHelper
|
||||
def referenced_collections_from(records)
|
||||
Current.user.collections.where id: records.pluck(:collection_id).uniq
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
<% referenced_collections_from(records).each do |collection| %>
|
||||
<%= turbo_stream_from collection %>
|
||||
<% end %>
|
||||
@@ -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 %>
|
||||
<section class="cards cards--grid">
|
||||
<%= 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 %>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<section class="cards cards--grid">
|
||||
<%= 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 %>
|
||||
</section>
|
||||
|
||||
@@ -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" %>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<% if filter.collections.any? %>
|
||||
<% filter.collections.each do |collection| %>
|
||||
<%= turbo_stream_from collection %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= turbo_stream_from :collections %>
|
||||
<% end %>
|
||||
@@ -2,7 +2,10 @@
|
||||
<%= page_title_tag %>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover">
|
||||
<meta name="view-transition" content="same-origin">
|
||||
|
||||
<% unless @disable_view_transition %>
|
||||
<meta name="view-transition" content="same-origin">
|
||||
<% end %>
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)">
|
||||
<meta name="theme-color" content="#000000" media="(prefers-color-scheme: dark)">
|
||||
|
||||
Reference in New Issue
Block a user