From c63bf73c695f3c58385f6cdd78f485df0196cc9c Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 12 Nov 2025 16:52:22 -0500 Subject: [PATCH] No more async in list_for We have a loader, let's use it Probably we want to load list of command as part of the sgx repo? But maybe that's too heavy and we don't always need it? --- lib/command_list.rb | 16 +++++++--------- sgx_jmp.rb | 10 ++++------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lib/command_list.rb b/lib/command_list.rb index 4a091372879db288b0fbbc82aa6396bdfb85c2c8..330cd3d4c55370d426adc44e0281df9c934090aa 100644 --- a/lib/command_list.rb +++ b/lib/command_list.rb @@ -10,11 +10,7 @@ class CommandList def self.for(customer, from_jid) args_for(customer, from_jid).then do |kwargs| - EMPromise.all( - @commands.select { |c| - c.list_for?(**kwargs) - }.then(&method(:new)) - ) + new(@commands.select { |c| c.list_for?(**kwargs) }) end end @@ -23,13 +19,15 @@ class CommandList from_jid: from_jid, customer: customer, tel: customer&.registered? ? customer&.registered?&.phone : nil, fwd: customer&.fwd, feature_flags: customer&.feature_flags || [], - payment_methods: [], - tn_portable: false + payment_methods: [] } return EMPromise.resolve(args) unless customer&.plan_name - customer.payment_methods.then do |payment_methods| - args.merge(payment_methods: payment_methods) + EMPromise.all([ + customer.payment_methods, + customer.commands + ]).then do |(payment_methods, sgx_commands)| + args.merge(payment_methods: payment_methods, sgx_commands: sgx_commands) end end diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 77c4745c8f8ebd90fa937b7ff228fe7d8d746464..9f28737ec2c80e9b502b2cbbdcc04a1cd6740a53 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -875,12 +875,10 @@ Command.new( Command.new( "set-port-out-pin", "🔐 Set Port-out PIN", - list_for: lambda do |customer:, **| - customer.commands.then { |cmds| - cmds.any? { |item| - item.node == "set-port-out-pin" - } - }.then { customer.active? } + list_for: lambda do |sgx_commands:, **| + sgx_commands.any? { |item| + item.node == "set-port-out-pin" + } end ) { Command.customer.then do |customer|