refactor: remove cached AppConfig pointer and read configuration directly from DB

Replace in-memory atomic AppConfig caching with direct DB queries via db.GetConfig
across application and page layers. This simplifies state management and ensures
all components always operate on the latest persisted configuration.

Key changes:
- Remove Application.Config atomic cache and refreshCache mechanism
- Eliminate PageCtx.CfgPtr and pass DB handle instead
- Replace all cfg reads with db.GetConfig(app.DB)
- Update mixer, audio, UI pages, and initialization paths accordingly
- Explicitly set AppConfig table name to avoid GORM pluralization issues
- Reduce DB connection pooling (SetMaxIdleConns(1))
- Standardize application font to SpaceMonoNerdFont-Regular
- Lower default audio volume (1.0 → 0.2)
- Add Unicode checkmark glyph to font map

Behavioral impact:
- Configuration is no longer cached in memory
- Every config access now hits the DB (more consistent, slightly more overhead)
This commit is contained in:
NeilClack
2026-06-26 22:51:32 -05:00
parent 6fd5ec919c
commit 2735af5fbb
15 changed files with 239 additions and 138 deletions
+19 -7
View File
@@ -8,6 +8,7 @@ import (
"github.com/go-gl/mathgl/mgl32"
"github.com/veandco/go-sdl2/sdl"
"rhemawavetech.com/rhemawave/internal/colors"
"rhemawavetech.com/rhemawave/internal/db"
"rhemawavetech.com/rhemawave/internal/fontManager"
"rhemawavetech.com/rhemawave/internal/shaderManager"
)
@@ -59,7 +60,7 @@ func (p *EmailAddressPage) Init(ctx *PageCtx) error {
p.title = "Your Email Address"
applicationFont := "Roboto-Regular"
applicationFont := "SpaceMonoNerdFont-Regular"
fm := fontManager.Get()
textShader, ok := shaderManager.Get().Get("text")
@@ -81,7 +82,11 @@ func (p *EmailAddressPage) Init(ctx *PageCtx) error {
p.titleTextureHeight = titleHeight
// Load existing email address from database
emailAddress := ctx.CfgPtr.EmailAddress
config, err := db.GetConfig(p.Context.DbPtr)
if err != nil {
panic(err)
}
emailAddress := config.EmailAddress
if emailAddress != "" {
p.inputText = emailAddress
@@ -154,9 +159,12 @@ func (p *EmailAddressPage) HandleEvent(event *sdl.Event) error {
sdl.StopTextInput()
// Save email address to database
p.Context.CfgPtr.EmailAddress = p.inputText
p.Context.DbPtr.Save(p.Context.CfgPtr)
p.Context.RefreshConfig()
config, err := db.GetConfig(p.Context.DbPtr)
if err != nil {
panic(err)
}
config.EmailAddress = p.inputText
p.Context.DbPtr.Save(config)
if p.isFirstTimeSetup {
// First-time setup: navigate to License Key page
@@ -189,7 +197,7 @@ func (p *EmailAddressPage) HandleEvent(event *sdl.Event) error {
// Update updates animations and changing textures and other changes using `dt` which represents a time delta in float32.
func (p *EmailAddressPage) Update(dt float32) error {
// Get application font from database
applicationFont := "Roboto-Regular"
applicationFont := "SpaceMonoNerdFont-Regular"
fm := fontManager.Get()
sm := shaderManager.Get()
@@ -252,8 +260,12 @@ func (p *EmailAddressPage) Update(dt float32) error {
// Render performs page drawing logic.
func (p *EmailAddressPage) Render() error {
config, err := db.GetConfig(p.Context.DbPtr)
if err != nil {
panic(err)
}
// Get base font size from database
baseFontSize := p.Context.CfgPtr.StandardFontSize
baseFontSize := config.StandardFontSize
sm := shaderManager.Get()