Share hidden vault root logic across UI and API

This commit is contained in:
Joe Julian
2026-04-11 11:26:00 -07:00
parent ebb8d4f4ff
commit c8f91b300b
5 changed files with 121 additions and 28 deletions
+23
View File
@@ -0,0 +1,23 @@
package vaultview
import "git.julianfamily.org/keepassgo/internal/vault"
// HiddenRoot returns the single synthetic top-level vault group that should be
// treated as an internal storage root rather than as a user-visible group.
func HiddenRoot(model vault.Model) string {
if len(model.EntriesInPath(nil)) != 0 {
return ""
}
groups := model.ChildGroups(nil)
roots := make([]string, 0, len(groups))
for _, group := range groups {
if group == "Recycle Bin" {
continue
}
roots = append(roots, group)
}
if len(roots) != 1 {
return ""
}
return roots[0]
}