Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
Scope turbo broadcasts for records to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
reesericci committed Feb 7, 2024
1 parent 14afa59 commit 3f6f2e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/models/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def self.create(attributes = {})
obj = new(attributes)
obj.validate!
obj.save # standard:disable all
obj.broadcast_append_to("records:main", partial: "records/record")

obj
end
Expand Down Expand Up @@ -84,13 +83,14 @@ def save

if persisted?
update_record
broadcast_replace_to(domain, partial: "records/record")
else
persist
broadcast_append_to(domain, partial: "records/record")
end

changes_applied

broadcast_replace_to("records:main", partial: "records/record")
Rails.cache.delete("records")
domain.update!(updated_at: Time.now) # standard:disable all
end
Expand All @@ -105,7 +105,7 @@ def id

def destroy!
destroy_record
broadcast_remove_to("records:main")
broadcast_remove_to(domain)
end

def self.destroy_all_host!(host)
Expand Down
2 changes: 1 addition & 1 deletion app/views/records/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</thead>
<tbody id="records" data-empty-target="watched">

<%= turbo_stream_from 'records:main' %>
<%= turbo_stream_from @domain %>

<% @records.each do |record| %>
<%= render "record", record: record %>
Expand Down

0 comments on commit 3f6f2e9

Please sign in to comment.