Skip to content

Commit 44c7166

Browse files
committed
Fix topics caching bug
We used topics.last in the watermark which is the last topic on the page instead of the first which is the newest topic on the page. This caused the page not to properly refresh if the last topic changed, but only by a thread already on the page receiveing a new message.
1 parent 67a4c9e commit 44c7166

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

app/controllers/topics_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,11 @@ def hydrate_topics_from_entries(entries)
731731
end
732732

733733
def topics_page_cache_key
734-
return nil unless @topics&.last
734+
return nil unless @topics&.first
735735
return nil if params[:filter].present? || params[:team_id].present?
736736

737-
last_topic = @topics.last
738-
watermark = "#{last_topic.last_activity.to_i}_#{last_topic.id}"
737+
latest_topic = @topics.first
738+
watermark = "#{latest_topic.last_activity.to_i}_#{latest_topic.id}"
739739
["topics-index", watermark]
740740
end
741741

0 commit comments

Comments
 (0)