refactor(messagerie): preload commentaires with corrections & attachments blobs
This commit is contained in:
parent
7f871728c7
commit
b1bcc784bb
2 changed files with 3 additions and 1 deletions
|
@ -99,6 +99,8 @@ class Dossier < ApplicationRecord
|
|||
has_many :prefilled_champs_public, -> { root.public_only.prefilled }, class_name: 'Champ', inverse_of: false
|
||||
|
||||
has_many :commentaires, inverse_of: :dossier, dependent: :destroy
|
||||
has_many :preloaded_commentaires, -> { includes(:dossier_correction, piece_jointe_attachment: :blob) }, class_name: 'Commentaire', inverse_of: :dossier
|
||||
|
||||
has_many :invites, dependent: :destroy
|
||||
has_many :follows, -> { active }, inverse_of: :dossier
|
||||
has_many :previous_follows, -> { inactive }, class_name: 'Follow', inverse_of: :dossier
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.messagerie.container
|
||||
%ul.messages-list{ data: { controller: 'scroll-to' } }
|
||||
- dossier.commentaires.with_attached_piece_jointe.each do |commentaire|
|
||||
- dossier.preloaded_commentaires.each do |commentaire|
|
||||
%li.message{ class: commentaire_is_from_me_class(commentaire, connected_user), id: dom_id(commentaire) }
|
||||
= render Dossiers::MessageComponent.new(commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at, show_reply_button: show_reply_button(commentaire, connected_user))
|
||||
|
||||
|
|
Loading…
Reference in a new issue