From 2822ab459ada3c7a63417f7d49dbc0bf0ed0c51f Mon Sep 17 00:00:00 2001 From: lash Date: Sat, 11 Jan 2025 21:14:24 +0000 Subject: [PATCH] Move in profile struct --- go.mod | 2 +- go.sum | 4 ++-- handlers/application/menuhandler.go | 6 +++--- profile/profile.go | 18 ++++++++++++++++++ 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 profile/profile.go diff --git a/go.mod b/go.mod index ffd31e8..23115fe 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23.4 require ( git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d - git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111204110-3e32ada4c0e2 + git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111211303-3ea726a0302c git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250111203946-a65fe6559956 github.com/alecthomas/assert/v2 v2.2.2 diff --git a/go.sum b/go.sum index 681a51c..29edbde 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d h1:bPAOVZOX4frSGhfOdcj7kc555f8dc9DmMd2YAyC2AMw= git.defalsify.org/vise.git v0.2.3-0.20250103172917-3e190a44568d/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck= -git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111204110-3e32ada4c0e2 h1:Zy7SHgZ+f9hrQKxEC9Q22MwUH8XDjEH+35voXNRyVsU= -git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111204110-3e32ada4c0e2/go.mod h1:CXdVutRsCkdWWCJ9hELi/72z3FDKkhLksxCXBSnjuKI= +git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111211303-3ea726a0302c h1:5h1nsczPXBhOfe5Wbyccp3ontooztKUVAtDw8aoT8BI= +git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250111211303-3ea726a0302c/go.mod h1:CXdVutRsCkdWWCJ9hELi/72z3FDKkhLksxCXBSnjuKI= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa h1:owrXxiDOp7uuyvGxi4DU8gu8PyA7YxVnX8bo7i28Anw= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250111163106-c93a07832daa/go.mod h1:E6W7ZOa7ZvVr0Bc5ot0LNSwpSPYq4hXlAIvEPy3AJ7U= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250111203946-a65fe6559956 h1:wTfH1CP0bh1JDcrJoqbBlnpmelpPSOslknCeCXPUpLs= diff --git a/handlers/application/menuhandler.go b/handlers/application/menuhandler.go index 08baef2..f60b462 100644 --- a/handlers/application/menuhandler.go +++ b/handlers/application/menuhandler.go @@ -21,7 +21,7 @@ import ( "git.grassecon.net/grassrootseconomics/visedriver/common" "git.grassecon.net/grassrootseconomics/visedriver/utils" - "git.grassecon.net/grassrootseconomics/sarafu-api/models" + "git.grassecon.net/grassrootseconomics/sarafu-vise/profile" "git.grassecon.net/grassrootseconomics/sarafu-api/remote" dbstorage "git.grassecon.net/grassrootseconomics/visedriver/storage/db" @@ -66,7 +66,7 @@ type MenuHandlers struct { flagManager *asm.FlagParser accountService remote.AccountService prefixDb dbstorage.PrefixDb - profile *models.Profile + profile *profile.Profile ReplaceSeparatorFunc func(string) string } @@ -89,7 +89,7 @@ func NewMenuHandlers(appFlags *asm.FlagParser, userdataStore db.Db, adminstore * adminstore: adminstore, accountService: accountService, prefixDb: prefixDb, - profile: &models.Profile{Max: 6}, + profile: &profile.Profile{Max: 6}, ReplaceSeparatorFunc: replaceSeparatorFunc, } return h, nil diff --git a/profile/profile.go b/profile/profile.go new file mode 100644 index 0000000..1804d97 --- /dev/null +++ b/profile/profile.go @@ -0,0 +1,18 @@ +package profile + +type Profile struct { + ProfileItems []string + Max int +} + +func (p *Profile) InsertOrShift(index int, value string) { + if index < len(p.ProfileItems) { + p.ProfileItems = append(p.ProfileItems[:index], value) + } else { + for len(p.ProfileItems) < index { + p.ProfileItems = append(p.ProfileItems, "0") + } + p.ProfileItems = append(p.ProfileItems, "0") + p.ProfileItems[index] = value + } +}