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 cache behaviour for visited links #509

Merged
merged 2 commits into from
Nov 16, 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
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ ZwIDAQAB
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=1
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=2
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=3

GROVER_NO_SANDBOX=true # must be true for running chromium as root in Docker container
PDF_DISPLAY_URL=
2 changes: 1 addition & 1 deletion app/components/message_threads_table_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="flex flex-col justify-stretch items-stretch sm:rounded-md bg-white sm:border sm:border-gray-200" data-controller="form all-checkboxes">
<%= render MessageThreadsBulkActionsComponent.new(ids: [], filter: @filter, filter_subscription: @filter_subscription, signable: Current.user.signer?) %>
<%= form_with url: bulk_actions_message_threads_path, data: { "form-target": "form", "all-checkboxes-target": "form" } do %>
<ul role="list" id="message_threads" class="divide-y divide-gray-100">
<ul role="list" id="message_threads" data-controller="visited-links" class="divide-y divide-gray-100">
<% message_threads.each do |message_thread| %>
<%= message_thread %>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/components/message_threads_table_row_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div class="hidden sm:flex pr-2 md:gap-4 md:pr-4 items-center justify-start mb-auto h-8">
<%= check_box_tag("message_thread_ids[]", @message_thread.id, false, { id: "message_thread_#{@message_thread.id}", class: "h-4 w-4 rounded border-gray-300 text-blue-500 focus:ring-0 hidden sm:block my-auto", type: "checkbox", data: { action: "form#send" } }) %>
</div>
<%= link_to @message_thread, class: "flex flex-col md:flex-row md:flex-nowrap justify-between grow gap-2" do %>
<%= link_to @message_thread, class: class_names("flex flex-col md:flex-row md:flex-nowrap justify-between grow gap-2", :group, visited: @message_thread.all_read), data: {action: 'visited-links#visit'} do %>
<div class="flex flex-col gap-2">
<div class="flex flex-wrap grow gap-x-4 gap-y-1">
<div class="flex items-center sm:min-h-[32px]">
<span title="<%= @message_thread.title %>" class="inline text-sm sm:text-lg text-gray-900 <%= "font-semibold" unless @message_thread.all_read %> [word-break:break-word]">
<span title="<%= @message_thread.title %>" class="inline text-sm sm:text-lg text-gray-900 group-[:not(.visited)]:font-semibold [word-break:break-word]">
<%= @message_thread.title %>
</span>
</div>
Expand Down Expand Up @@ -52,7 +52,7 @@
</div>
<div class="hidden md:flex gap-x-4 items-center">
<div class="flex flex-col gap-y-1 text-right whitespace-nowrap">
<time class="text-lg text-gray-900 <%= "font-semibold" unless @message_thread.all_read %>" datetime="<%= @message_thread.last_message_delivered_at %>">
<time class="text-lg text-gray-900 group-[:not(.visited)]:font-semibold" datetime="<%= @message_thread.last_message_delivered_at %>">
<%= helpers.nice_datetime(@message_thread.last_message_delivered_at) %>
</time>
<%#= render Common::TagComponent.new("2 nové správy") %>
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ application.register("turbo-content", TurboContentController)

import ContentWithSeparator from "./content_with_separator"
application.register("content-with-separator", ContentWithSeparator)

import VisitedLinks from "./visited_links_controller"
application.register("visited-links", VisitedLinks)
8 changes: 8 additions & 0 deletions app/javascript/controllers/visited_links_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {Controller} from "@hotwired/stimulus"

// Connects to data-controller="visited-links"
export default class extends Controller {
visit(event) {
event.target.closest("a").classList.add("visited");
}
}
Loading