diff --git a/lib/tel_selections.rb b/lib/tel_selections.rb index 3006a63a94e760e27ca8f5588593c97df5d4d779..8b309d946da86a119f167b2159c756514910f0ef 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