aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2024-03-17 10:32:20 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2024-03-17 10:32:20 +0200
commitc3279457fcdda6198faf1db23558b0ff20babfdc (patch)
treed7a302527aa4ab6d73803e5ba35f5e8838b7333a /pkg/models
parentapp/preferences: simplify checked attr (diff)
downloadsoko-c3279457fcdda6198faf1db23558b0ff20babfdc.tar.gz
soko-c3279457fcdda6198faf1db23558b0ff20babfdc.tar.bz2
soko-c3279457fcdda6198faf1db23558b0ff20babfdc.zip
preferences: remove most of single package
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'pkg/models')
-rw-r--r--pkg/models/userpreferences.go88
1 files changed, 4 insertions, 84 deletions
diff --git a/pkg/models/userpreferences.go b/pkg/models/userpreferences.go
index 023f153..3535abb 100644
--- a/pkg/models/userpreferences.go
+++ b/pkg/models/userpreferences.go
@@ -17,39 +17,13 @@ type GeneralPreferences struct {
}
type PackagesPreferences struct {
- Overview PackagesOverviewPreferences
- PullRequests PackagesPullRequestsPreferences
- Bugs PackagesBugsPreferences
- Security PackagesSecurityPreferences
- Changelog PackagesChangelogPreferences
+ Overview PackagesOverviewPreferences
}
type PackagesOverviewPreferences struct {
- Layout string
- Keywords []string
- EAPI string
- ShowOutdated bool
- MetadataFields []string
- ChangelogType string
- ChangelogLength int
-}
-
-type PackagesPullRequestsPreferences struct {
- Layout string
-}
-
-type PackagesBugsPreferences struct {
- Layout string
-}
-
-type PackagesSecurityPreferences struct {
- Layout string
- ShowGLSAs bool
-}
-
-type PackagesChangelogPreferences struct {
- Layout string
- Size int
+ Layout string
+ Keywords []string
+ EAPI string
}
type MaintainersPreferences struct {
@@ -72,10 +46,6 @@ func GetDefaultUserPreferences() UserPreferences {
userPreferences.General = GeneralPreferences{}
userPreferences.Packages = PackagesPreferences{}
userPreferences.Packages.Overview = PackagesOverviewPreferences{}
- userPreferences.Packages.PullRequests = PackagesPullRequestsPreferences{}
- userPreferences.Packages.Bugs = PackagesBugsPreferences{}
- userPreferences.Packages.Security = PackagesSecurityPreferences{}
- userPreferences.Packages.Changelog = PackagesChangelogPreferences{}
userPreferences.Maintainers = MaintainersPreferences{}
userPreferences.Useflags = UseflagsPreferences{}
userPreferences.Arches = ArchesPreferences{}
@@ -85,20 +55,6 @@ func GetDefaultUserPreferences() UserPreferences {
userPreferences.Packages.Overview.Layout = "minimal"
userPreferences.Packages.Overview.Keywords = []string{"amd64", "x86", "alpha", "arm", "arm64", "hppa", "ia64", "ppc", "ppc64", "riscv", "sparc"}
userPreferences.Packages.Overview.EAPI = "none"
- userPreferences.Packages.Overview.ShowOutdated = true
- userPreferences.Packages.Overview.MetadataFields = []string{"homepage", "upstream", "longdescription", "useflags", "license", "maintainers"}
- userPreferences.Packages.Overview.ChangelogType = "compact"
- userPreferences.Packages.Overview.ChangelogLength = 5
-
- userPreferences.Packages.PullRequests.Layout = "default"
-
- userPreferences.Packages.Bugs.Layout = "default"
-
- userPreferences.Packages.Security.Layout = "default"
- userPreferences.Packages.Security.ShowGLSAs = false
-
- userPreferences.Packages.Changelog.Layout = "compact"
- userPreferences.Packages.Changelog.Size = 15
userPreferences.Arches.Visible = []string{"amd64", "x86", "alpha", "arm", "arm64", "hppa", "ia64", "ppc", "ppc64", "riscv", "sparc"}
userPreferences.Arches.DefaultArch = "amd64"
@@ -135,42 +91,6 @@ func (u *UserPreferences) Sanitize() {
u.Packages.Overview.EAPI = defaultUserPreferences.Packages.Overview.EAPI
}
- sanitizedMetadataFields := []string{}
- for _, metadataField := range u.Packages.Overview.MetadataFields {
- if strings.Contains(strings.Join(defaultUserPreferences.Packages.Overview.MetadataFields, ","), metadataField) {
- sanitizedMetadataFields = append(sanitizedMetadataFields, metadataField)
- }
- }
- u.Packages.Overview.MetadataFields = sanitizedMetadataFields
-
- if !(u.Packages.Overview.ChangelogType == "compact") {
- u.Packages.Overview.ChangelogType = defaultUserPreferences.Packages.Overview.ChangelogType
- }
-
- if !(u.Packages.Overview.ChangelogLength >= 100) {
- u.Packages.Overview.ChangelogLength = 100
- }
-
- if !(u.Packages.PullRequests.Layout == "default") {
- u.Packages.PullRequests.Layout = defaultUserPreferences.Packages.PullRequests.Layout
- }
-
- if !(u.Packages.Bugs.Layout == "default") {
- u.Packages.Bugs.Layout = defaultUserPreferences.Packages.Bugs.Layout
- }
-
- if !(u.Packages.Security.Layout == "default") {
- u.Packages.Security.Layout = defaultUserPreferences.Packages.Security.Layout
- }
-
- if !(u.Packages.Changelog.Layout == "default") {
- u.Packages.Changelog.Layout = defaultUserPreferences.Packages.Changelog.Layout
- }
-
- if !(u.Packages.Changelog.Size >= 100) {
- u.Packages.Changelog.Size = 100
- }
-
sanitizedVisibleArches := []string{}
for _, keyword := range u.Arches.Visible {
if strings.Contains(strings.Join(GetAllKeywords(), ","), keyword) {