Skip to content

Commit

Permalink
Remove message view caching
Browse files Browse the repository at this point in the history
Fixes #849
  • Loading branch information
nikolai-b committed May 8, 2019
1 parent 9c7cc66 commit 5f99221
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/message_threads/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- if permitted_to? :destroy, @thread
%li= link_to t(".destroy"), thread_path(@thread), method: :delete, data: { confirm: t("are_you_sure") }

= render collection: @messages, partial: "messages/message", locals: { view_from: @view_from, thread: @thread }, cached: true
= render collection: @messages, partial: "messages/message", locals: { view_from: @view_from, thread: @thread }
- if @thread.closed
- closed_by = permitted_to?(:view_profile, @thread.closed_by.last) ? link_to_profile(@thread.closed_by.last) : @thread.closed_by.last.display_name_or_anon
= t '.closed_html', by: closed_by, at: time_ago_in_words(@thread.message_thread_closes.last.created_at)
Expand Down

2 comments on commit 5f99221

@mvl22
Copy link
Member

@mvl22 mvl22 commented on 5f99221 May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was happening here?

@nikolai-b
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message was rendered (say 6 mins after the post was created) and than I was caching the view so long as the message wasn't updated then the cached view would be served see https://guides.rubyonrails.org/caching_with_rails.html#fragment-caching
Sadly we've got a timestamp in there so the time ago in words was also cached. Ideally we'd render the time and use JS to update to convert that to time ago in words i.e. use https://github.com/hustcc/timeago.js but it looks like that doesn't have cz support yet

Please sign in to comment.