From 977e286ba3179e7e85807726db4a9879d3dad0ac Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 29 Aug 2022 12:49:11 -0500 Subject: [PATCH] Allow prev action on TelSelections search results --- lib/tel_selections.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/tel_selections.rb b/lib/tel_selections.rb index 3006a63..8b309d9 100644 --- a/lib/tel_selections.rb +++ b/lib/tel_selections.rb @@ -49,14 +49,16 @@ class TelSelections end def choose_from_list(tns) - if tns.empty? - choose_tel(error: "No numbers found, try another search.") - else - Command.reply { |reply| - reply.allowed_actions = [:next] - reply.command << FormTemplate.render("tn_list", tns: tns) - }.then { |iq| iq.form.field("tel").value.to_s.strip } - end + raise "No numbers found, try another search." if tns.empty? + + Command.reply { |reply| + reply.allowed_actions = [:next, :prev] + reply.command << FormTemplate.render("tn_list", tns: tns) + }.then { |iq| + next choose_tel if iq.prev? + + iq.form.field("tel").value.to_s.strip + } end class AvailableNumber -- 2.38.4