add-space-after-colon #211
@ -69,18 +69,19 @@ func (fm *FlagManager) GetFlag(label string) (uint32, error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Handlers struct {
 | 
			
		||||
	pe             *persist.Persister
 | 
			
		||||
	st             *state.State
 | 
			
		||||
	ca             cache.Memory
 | 
			
		||||
	userdataStore  common.DataStore
 | 
			
		||||
	adminstore     *utils.AdminStore
 | 
			
		||||
	flagManager    *asm.FlagParser
 | 
			
		||||
	accountService remote.AccountServiceInterface
 | 
			
		||||
	prefixDb       storage.PrefixDb
 | 
			
		||||
	profile        *models.Profile
 | 
			
		||||
	pe               *persist.Persister
 | 
			
		||||
	st               *state.State
 | 
			
		||||
	ca               cache.Memory
 | 
			
		||||
	userdataStore    common.DataStore
 | 
			
		||||
	adminstore       *utils.AdminStore
 | 
			
		||||
	flagManager      *asm.FlagParser
 | 
			
		||||
	accountService   remote.AccountServiceInterface
 | 
			
		||||
	prefixDb         storage.PrefixDb
 | 
			
		||||
	profile          *models.Profile
 | 
			
		||||
	ReplaceSeparator func(string) string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *utils.AdminStore, accountService remote.AccountServiceInterface) (*Handlers, error) {
 | 
			
		||||
func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *utils.AdminStore, accountService remote.AccountServiceInterface, replaceSeparator func(string) string) (*Handlers, error) {
 | 
			
		||||
	if userdataStore == nil {
 | 
			
		||||
		return nil, fmt.Errorf("cannot create handler with nil userdata store")
 | 
			
		||||
	}
 | 
			
		||||
@ -93,12 +94,13 @@ func NewHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore *util
 | 
			
		||||
	prefixDb := storage.NewSubPrefixDb(userdataStore, prefix)
 | 
			
		||||
 | 
			
		||||
	h := &Handlers{
 | 
			
		||||
		userdataStore:  userDb,
 | 
			
		||||
		flagManager:    appFlags,
 | 
			
		||||
		adminstore:     adminstore,
 | 
			
		||||
		accountService: accountService,
 | 
			
		||||
		prefixDb:       prefixDb,
 | 
			
		||||
		profile:        &models.Profile{Max: 6},
 | 
			
		||||
		userdataStore:    userDb,
 | 
			
		||||
		flagManager:      appFlags,
 | 
			
		||||
		adminstore:       adminstore,
 | 
			
		||||
		accountService:   accountService,
 | 
			
		||||
		prefixDb:         prefixDb,
 | 
			
		||||
		profile:          &models.Profile{Max: 6},
 | 
			
		||||
		ReplaceSeparator: replaceSeparator,
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 | 
			||||
	}
 | 
			
		||||
	return h, nil
 | 
			
		||||
}
 | 
			
		||||
@ -1676,11 +1678,6 @@ func (h *Handlers) CheckVouchers(ctx context.Context, sym string, input []byte)
 | 
			
		||||
func (h *Handlers) GetVoucherList(ctx context.Context, sym string, input []byte) (resource.Result, error) {
 | 
			
		||||
	var res resource.Result
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 
				
					
						lash
						commented  
			
		why wouldnt this be set directly as a property in the handler? why wouldnt this be set directly as a property in the handler? 
			
			
		
				
					
						Alfred-mk
						commented  
			
		It would be easier setting it in the context for use by downstream functions, similar to how the database is set. Also. it won't be used by most of the handler functions. It's only usable by functions that generate custom menu items (such as the voucher list and transfers list) It would be easier setting it in the context for use by downstream functions, similar to how the database is set.
Also. it won't be used by most of the handler functions. It's only usable by functions that generate custom menu items (such as the voucher list and transfers list) 
			
			
		
				
					
						lash
						commented  
			
		ref phone conversation, let store a function pointer in the handlers that does the translation with the separator selected :) ref phone conversation, let store a function pointer in the handlers that does the translation with the separator selected :) 
			
			
		
				
					
						Alfred-mk
						commented  
			
		This has been done. The function is passed from the LocalHandlerService to the Handlers This has been done. The function is passed from the LocalHandlerService to the Handlers 
			
			
		 | 
			||||
 | 
			
		||||
	menuSeparator, ok := ctx.Value("MenuSeparator").(string)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return res, fmt.Errorf("missing menu Separator")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Read vouchers from the store
 | 
			
		||||
	voucherData, err := h.prefixDb.Get(ctx, common.ToBytes(common.DATA_VOUCHER_SYMBOLS))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -1688,7 +1685,7 @@ func (h *Handlers) GetVoucherList(ctx context.Context, sym string, input []byte)
 | 
			
		||||
		return res, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	formattedData := strings.ReplaceAll(string(voucherData), ":", menuSeparator)
 | 
			
		||||
	formattedData := h.ReplaceSeparator(string(voucherData))
 | 
			
		||||
 | 
			
		||||
	res.Content = string(formattedData)
 | 
			
		||||
 | 
			
		||||
@ -1861,11 +1858,6 @@ func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []
 | 
			
		||||
		return res, fmt.Errorf("missing session")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	menuSeparator, ok := ctx.Value("MenuSeparator").(string)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		return res, fmt.Errorf("missing menu Separator")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	store := h.userdataStore
 | 
			
		||||
	publicKey, err := store.ReadEntry(ctx, sessionId, common.DATA_PUBLIC_KEY)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
@ -1913,7 +1905,9 @@ func (h *Handlers) GetTransactionsList(ctx context.Context, sym string, input []
 | 
			
		||||
			status = "Sent"
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		formattedTransactions = append(formattedTransactions, fmt.Sprintf("%d%s%s %s %s %s", i+1, menuSeparator, status, value, sym, date))
 | 
			
		||||
		// Use the ReplaceSeparator function for the menu separator
 | 
			
		||||
		transactionLine := fmt.Sprintf("%d%s%s %s %s %s", i+1, h.ReplaceSeparator(":"), status, value, sym, date)
 | 
			
		||||
		formattedTransactions = append(formattedTransactions, transactionLine)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	res.Content = strings.Join(formattedTransactions, "\n")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
Let's name it
ReplaceSeparatorFuncThis has been done