Class: Spree::Admin::ImportRowSubscriber

Inherits:
Subscriber
  • Object
show all
Defined in:
app/subscribers/spree/admin/import_row_subscriber.rb

Overview

Handles ImportRow events for the admin interface.

This subscriber listens to import_row.completed and import_row.failed events and handles:

  • Adding the row to the import view (Turbo Streams)

  • Updating the footer in the import view (Turbo Streams)

We use async: false because the UI updates should happen immediately.

Instance Method Summary collapse

Instance Method Details

#update_import_view(event) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/subscribers/spree/admin/import_row_subscriber.rb', line 20

def update_import_view(event)
  import_row_id = event.payload['id']
  return unless import_row_id

  import_row = Spree::ImportRow.find_by_prefix_id(import_row_id)
  return unless import_row

  add_row_to_import_view(import_row)
  update_footer_in_import_view(import_row)
end