mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Respond fast by rendering only partial
This commit is contained in:
@@ -17,7 +17,7 @@ class ConnectAppJob < ApplicationJob
|
||||
|
||||
return unless channel
|
||||
|
||||
selector = "#edit_enterprise_#{enterprise.id} #connected_apps_panel div"
|
||||
selector = "#edit_enterprise_#{enterprise.id} #connected-app-discover-regen"
|
||||
html = ApplicationController.render(
|
||||
partial: "admin/enterprises/form/connected_apps",
|
||||
locals: { enterprise: },
|
||||
|
||||
@@ -7,10 +7,20 @@ module Admin
|
||||
authorize! :admin, enterprise
|
||||
app = ConnectedApp.create!(enterprise_id: enterprise.id)
|
||||
|
||||
selector = "#edit_enterprise_#{enterprise.id} #connected-app-discover-regen"
|
||||
html = ApplicationController.render(
|
||||
partial: "admin/enterprises/form/connected_apps",
|
||||
locals: { enterprise: },
|
||||
)
|
||||
|
||||
# Avoid race condition by sending before enqueuing job:
|
||||
cable_ready.morph(selector:, html:).broadcast
|
||||
|
||||
ConnectAppJob.perform_later(
|
||||
app, current_user.spree_api_key,
|
||||
channel: SessionChannel.for_request(request),
|
||||
)
|
||||
morph :nothing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
- enterprise ||= f.object
|
||||
%div{ data: {reflex: {root: ".connected-app__head, .connected-app__connection"}} }
|
||||
#connected-app-discover-regen
|
||||
.connected-app__head
|
||||
%div
|
||||
%h3= t ".title"
|
||||
|
||||
Reference in New Issue
Block a user