Compare commits

..

No commits in common. "bed7f58e815f216aabe59e39d20eac9f3a63cb1d" and "fd84f6ae98c7d721dfba02a202a477f89dc4b9bc" have entirely different histories.

4 changed files with 14 additions and 1258 deletions

View File

@ -102,12 +102,14 @@ func NewMenuHandlers(appFlags *FlagManager, userdataStore db.Db, accountService
return h, nil return h, nil
} }
// SetPersister sets persister instance to the handlers. // WithPersister sets persister instance to the handlers.
// func (h *MenuHandlers) WithPersister(pe *persist.Persister) *MenuHandlers {
func (h *MenuHandlers) SetPersister(pe *persist.Persister) { func (h *MenuHandlers) SetPersister(pe *persist.Persister) {
if h.pe != nil { if h.pe != nil {
panic("persister already set") panic("persister already set")
} }
h.pe = pe h.pe = pe
//return h
} }
// Init initializes the handler for a new session. // Init initializes the handler for a new session.
@ -2305,7 +2307,6 @@ func (h *MenuHandlers) ViewTransactionStatement(ctx context.Context, sym string,
return res, nil return res, nil
} }
// persistInitialLanguageCode receives an initial language code and persists it to the store
func (h *MenuHandlers) persistInitialLanguageCode(ctx context.Context, sessionId string, code string) error { func (h *MenuHandlers) persistInitialLanguageCode(ctx context.Context, sessionId string, code string) error {
store := h.userdataStore store := h.userdataStore
_, err := store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE) _, err := store.ReadEntry(ctx, sessionId, storedb.DATA_INITIAL_LANGUAGE_CODE)
@ -2338,8 +2339,6 @@ func (h *MenuHandlers) persistLanguageCode(ctx context.Context, code string) err
return h.persistInitialLanguageCode(ctx, sessionId, code) return h.persistInitialLanguageCode(ctx, sessionId, code)
} }
// constructAccountAlias retrieves and alias based on the first and family name
// and writes the result in DATA_ACCOUNT_ALIAS
func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error { func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error {
var alias string var alias string
store := h.userdataStore store := h.userdataStore
@ -2384,8 +2383,6 @@ func (h *MenuHandlers) constructAccountAlias(ctx context.Context) error {
return nil return nil
} }
// ClearTemporaryValue empties the DATA_TEMPORARY_VALUE at the main menu to prevent
// previously stored data from being accessed
func (h *MenuHandlers) ClearTemporaryValue(ctx context.Context, sym string, input []byte) (resource.Result, error) { func (h *MenuHandlers) ClearTemporaryValue(ctx context.Context, sym string, input []byte) (resource.Result, error) {
var res resource.Result var res resource.Result
sessionId, ok := ctx.Value("SessionId").(string) sessionId, ok := ctx.Value("SessionId").(string)

File diff suppressed because it is too large Load Diff

View File

@ -66,6 +66,7 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
if err != nil { if err != nil {
return nil, err return nil, err
} }
//appHandlers = appHandlers.WithPersister(ls.Pe)
appHandlers.SetPersister(ls.Pe) appHandlers.SetPersister(ls.Pe)
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus) ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage) ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)

View File

@ -1,42 +0,0 @@
package profile
import (
"testing"
"github.com/alecthomas/assert/v2"
"github.com/stretchr/testify/require"
)
func TestInsertOrShift(t *testing.T) {
tests := []struct {
name string
profile Profile
index int
value string
expected []string
}{
{
name: "Insert within range",
profile: Profile{ProfileItems: []string{"A", "B", "C"}, Max: 5},
index: 1,
value: "X",
expected: []string{"A", "X"},
},
{
name: "Insert beyond range",
profile: Profile{ProfileItems: []string{"A"}, Max: 5},
index: 3,
value: "Y",
expected: []string{"A", "0", "0", "Y"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
p := tt.profile
p.InsertOrShift(tt.index, tt.value)
require.NotNil(t, p.ProfileItems)
assert.Equal(t, tt.expected, p.ProfileItems)
})
}
}