Skip to content

Commit 808457c

Browse files
committed
Fix caching bug on topic index
We included the user-specific async data retrieval in the cached block, but only if we had a signed in user. This worked perfectly if the page first was cached by a signed in user, but failed if it was first cached by a guest, as after that signed in users didn't get their additional information rendered. This commit fixes the problem by moving the user specific part outside of the cached part.
1 parent 9822638 commit 808457c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

app/views/topics/index.html.slim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
span Filtering by ##{@active_note_tag}
88
= link_to "Clear", topics_path, class: "clear-tag-filter"
99

10-
- if user_signed_in?
11-
#user-state-requests
12-
= turbo_frame_tag "user-state-root", src: user_state_frame_topics_path(topic_ids: @topics.map(&:id), format: :turbo_stream), loading: :eager
13-
1410
.topics-table
1511
- if user_signed_in?
1612
.topics-actions data-controller="topics-aware" data-topics-aware-aware-url-value=aware_bulk_topics_path data-topics-aware-aware-all-url-value=aware_all_topics_path
@@ -34,6 +30,10 @@
3430
- else
3531
= turbo_frame_tag "pagination"
3632

33+
- if user_signed_in?
34+
#user-state-requests
35+
= turbo_frame_tag "user-state-root", src: user_state_frame_topics_path(topic_ids: @topics.map(&:id), format: :turbo_stream), loading: :eager
36+
3737
- if @page_cache_key
3838
= render partial: "sidebar", locals: { available_note_tags: @available_note_tags, search_query: @search_query }
3939
- cache(@page_cache_key) do

0 commit comments

Comments
 (0)