tiki/internal/bootstrap/models.go
2026-03-23 21:50:12 -04:00

35 lines
1.1 KiB
Go

package bootstrap
import (
"github.com/boolean-maybe/tiki/config"
"github.com/boolean-maybe/tiki/model"
"github.com/boolean-maybe/tiki/store/tikistore"
)
// InitHeaderAndLayoutModels creates the header config and layout model with
// persisted visibility preferences applied.
func InitHeaderAndLayoutModels() (*model.HeaderConfig, *model.LayoutModel) {
headerConfig := model.NewHeaderConfig()
layoutModel := model.NewLayoutModel()
// Load user preference from saved config
headerVisible := config.GetHeaderVisible()
headerConfig.SetUserPreference(headerVisible)
headerConfig.SetVisible(headerVisible)
return headerConfig, layoutModel
}
// InitStatuslineModel creates and populates the statusline config with base stats (version, branch, user).
func InitStatuslineModel(tikiStore *tikistore.TikiStore) *model.StatuslineConfig {
cfg := model.NewStatuslineConfig()
cfg.SetLeftStat("Version", config.Version, 0)
for _, stat := range tikiStore.GetStats() {
value := stat.Value
if stat.Name == "Branch" {
value = "\ue0a0 " + value
}
cfg.SetLeftStat(stat.Name, value, stat.Order)
}
return cfg
}