Module: Protege::BroadcastableThread
- Extended by:
- ActiveSupport::Concern
- Included in:
- EmailThread
- Defined in:
- app/models/concerns/protege/broadcastable_thread.rb
Overview
Drives real-time Turbo Stream broadcasting for EmailThread records — keeping the inbox sidebar
live as threads come, change, and go.
On create the thread's row is prepended to the list (newest-first); on update its row is replaced
in place (also invoked directly by BroadcastableMessage when a new message arrives, so the row
reflects the latest activity and counts); on destroy the row is removed. First-page viewers subscribe
via turbo_stream_from "protege:threads" (see SidebarHelper#sidebar_stream).
Constant Summary collapse
- STREAM =
Turbo Stream channel for all
EmailThreadrecords. 'protege:threads'
Instance Method Summary collapse
-
#broadcast_thread_created ⇒ void
Prepend this thread's row to the inbox list on creation.
-
#broadcast_thread_removed ⇒ void
Remove this thread's row from the inbox list on destruction.
-
#broadcast_thread_updated ⇒ void
Broadcast an in-place replacement of this thread's inbox-sidebar row.
Instance Method Details
#broadcast_thread_created ⇒ void
This method returns an undefined value.
Prepend this thread's row to the inbox list on creation.
27 28 29 30 31 32 |
# File 'app/models/concerns/protege/broadcastable_thread.rb', line 27 def broadcast_thread_created broadcast_prepend_to STREAM, target: 'threads_list', partial: 'protege/threads/thread', locals: { thread: self } end |
#broadcast_thread_removed ⇒ void
This method returns an undefined value.
Remove this thread's row from the inbox list on destruction.
50 51 52 53 |
# File 'app/models/concerns/protege/broadcastable_thread.rb', line 50 def broadcast_thread_removed broadcast_remove_to STREAM, target: ActionView::RecordIdentifier.dom_id(self) end |
#broadcast_thread_updated ⇒ void
This method returns an undefined value.
Broadcast an in-place replacement of this thread's inbox-sidebar row.
Public by design so BroadcastableMessage can trigger the refresh after a new message saves,
not only on the thread's own attribute changes.
40 41 42 43 44 45 |
# File 'app/models/concerns/protege/broadcastable_thread.rb', line 40 def broadcast_thread_updated broadcast_replace_to STREAM, target: ActionView::RecordIdentifier.dom_id(self), partial: 'protege/threads/thread', locals: { thread: self } end |