@@ -36,27 +36,28 @@ def new_topics_count
3636 end
3737
3838 def show
39- messages_scope = @topic . messages . includes (
40- :attachments ,
41- :sender ,
42- :sender_person ,
43- { sender_person : :default_alias } ,
44- {
45- reply_to : [
46- :sender ,
47- :sender_person ,
48- { sender_person : :default_alias }
49- ]
50- }
51- )
39+ messages_scope = @topic . messages
40+ . eager_load (
41+ :sender ,
42+ :sender_person ,
43+ { sender_person : :default_alias } ,
44+ {
45+ reply_to : [
46+ :sender ,
47+ :sender_person ,
48+ { sender_person : :default_alias }
49+ ]
50+ }
51+ )
52+ . preload ( :attachments )
5253
5354 @messages = messages_scope . order ( created_at : :asc )
5455 @message_numbers = @messages . each_with_index . to_h { |msg , idx | [ msg . id , idx + 1 ] }
5556 preload_read_state!
5657 auto_mark_aware!
5758
5859 build_participants_sidebar_data ( messages_scope )
59- build_thread_outline ( messages_scope )
60+ build_thread_outline ( @messages )
6061 load_commitfest_sidebar
6162 if user_signed_in?
6263 load_notes
@@ -324,17 +325,17 @@ def build_participants_sidebar_data(_messages_scope)
324325
325326 {
326327 alias : alias_record ,
328+ person : tp . person ,
327329 message_count : tp . message_count ,
328330 first_at : tp . first_message_at ,
329331 last_at : tp . last_message_at
330332 }
331333 end . compact
332334 end
333335
334- def build_thread_outline ( messages_scope )
335- ordered_messages = messages_scope . order ( :created_at )
336+ def build_thread_outline ( messages )
336337 children = Hash . new { |h , k | h [ k ] = [ ] }
337- ordered_messages . each do |msg |
338+ messages . each do |msg |
338339 children [ msg . reply_to_id ] << msg
339340 end
340341
0 commit comments