Respond fast by rendering only partial

This commit is contained in:
Maikel Linke
2023-12-15 12:19:22 +11:00
parent 1d7f96e965
commit 35ca66cbb7
3 changed files with 12 additions and 2 deletions

View File

@@ -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: },

View File

@@ -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

View File

@@ -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"