only set the flag if the user has a single voucher

This commit is contained in:
Alfred Kamanda 2026-02-17 14:04:17 +03:00
parent a346adb8f9
commit 96ba48bcba
Signed by: Alfred-mk
GPG Key ID: 7EA3D01708908703
2 changed files with 9 additions and 0 deletions

View File

@ -33,6 +33,7 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher") flag_no_active_voucher, _ := h.flagManager.GetFlag("flag_no_active_voucher")
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error") flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
flag_no_stable_vouchers, _ := h.flagManager.GetFlag("flag_no_stable_vouchers") flag_no_stable_vouchers, _ := h.flagManager.GetFlag("flag_no_stable_vouchers")
flag_single_voucher, _ := h.flagManager.GetFlag("flag_single_voucher")
publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY) publicKey, err := userStore.ReadEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY)
if err != nil { if err != nil {
@ -73,6 +74,13 @@ func (h *MenuHandlers) ManageVouchers(ctx context.Context, sym string, input []b
return res, nil return res, nil
} }
// only set the flag if the user has a single voucher
if len(vouchersResp) == 1 {
res.FlagSet = append(res.FlagSet, flag_single_voucher)
} else {
res.FlagReset = append(res.FlagReset, flag_single_voucher)
}
res.FlagReset = append(res.FlagReset, flag_no_active_voucher) res.FlagReset = append(res.FlagReset, flag_no_active_voucher)
// add a variable to filter out the active voucher // add a variable to filter out the active voucher

View File

@ -37,3 +37,4 @@ flag,flag_low_swap_amount,43,this is set when the swap max limit is less than 0.
flag,flag_alias_unavailable,44,this is set when the preferred alias is not available flag,flag_alias_unavailable,44,this is set when the preferred alias is not available
flag,flag_swap_transaction,45,this is set when the transaction will involve performing a swap flag,flag_swap_transaction,45,this is set when the transaction will involve performing a swap
flag,flag_no_stable_vouchers,46,this is set when the user does not have a stable voucher flag,flag_no_stable_vouchers,46,this is set when the user does not have a stable voucher
flag,flag_single_voucher,47,this is set when the user only has a single voucher

1 flag flag_language_set 8 checks whether the user has set their prefered language
37 flag flag_alias_unavailable 44 this is set when the preferred alias is not available
38 flag flag_swap_transaction 45 this is set when the transaction will involve performing a swap
39 flag flag_no_stable_vouchers 46 this is set when the user does not have a stable voucher
40 flag flag_single_voucher 47 this is set when the user only has a single voucher