Use boolean instead of a list-single with one option

This commit is contained in:
Stephen Paul Weber 2024-02-18 21:56:12 -05:00
parent 88261571d1
commit 3a59d5ff16
No known key found for this signature in database
GPG key ID: D11C2911CE519CDE

View file

@ -693,15 +693,14 @@ class Slixfeed(slixmpp.ClientXMPP):
# session['notes'] = [['info', response]] # session['notes'] = [['info', response]]
form = self['xep_0004'].make_form('form', 'Subscription') form = self['xep_0004'].make_form('form', 'Subscription')
form['instructions'] = ('Subscription already exists at index {}.' form['instructions'] = ('Subscription already exists at index {}.'
'\n'
'Would you want to edit this subscription?'
.format(result['index'])) .format(result['index']))
options = form.add_field(var='subscription', form.add_field(ftype='boolean',
ftype='list-single', var='edit',
label='Subscription', label='Would you want to edit this subscription?')
desc='Continue to edit subscription.', form.add_field(var='subscription',
value=result['link']) ftype='hidden',
options.addOption(result['name'], result['link']) value=result['link'])
# NOTE Should we allow "Complete"? # NOTE Should we allow "Complete"?
# Do all clients provide button "Cancel". # Do all clients provide button "Cancel".
session['allow_complete'] = False session['allow_complete'] = False
@ -724,18 +723,13 @@ class Slixfeed(slixmpp.ClientXMPP):
form['instructions'] = ('New subscription' form['instructions'] = ('New subscription'
'\n' '\n'
'"{}"' '"{}"'
'\n\n'
'Continue to edit subscription?'
.format(result['name'], result['index'])) .format(result['name'], result['index']))
options = form.add_field(var='subscription', form.add_field(ftype='boolean',
ftype='list-single', var='edit',
# Should Gajim allows editing text-single label='Continue to edit subscription?')
# field when form is of type "result"? form.add_field(var='subscription',
# ftype='text-single', ftype='hidden',
label='Subscription', value=result['link'])
desc='Continue to edit subscription.',
value=result['link'])
options.addOption(result['name'], result['link'])
session['allow_complete'] = True session['allow_complete'] = True
session['allow_prev'] = False session['allow_prev'] = False
session['has_next'] = False session['has_next'] = False
@ -844,6 +838,10 @@ class Slixfeed(slixmpp.ClientXMPP):
jid = session['from'].bare jid = session['from'].bare
jid_file = jid jid_file = jid
db_file = config.get_pathname_to_database(jid_file) db_file = config.get_pathname_to_database(jid_file)
if 'edit' in payload['values'] and not payload['values']['edit']:
session['payload'] = None
session['next'] = None
return session
if 'subscription' in payload['values']: if 'subscription' in payload['values']:
urls = payload['values']['subscription'] urls = payload['values']['subscription']
elif 'subscriptions' in payload['values']: elif 'subscriptions' in payload['values']: