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
@@ -10,6 +10,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/logger"
"rhemawavetech.com/rhemawave/internal/shaderManager"
@@ -55,7 +56,7 @@ func (p *LicenseKeyPage) Init(ctx *PageCtx) error {
p.title = "License Key"
// Get application font from database
applicationFont := "Roboto-Regular"
applicationFont := "SpaceMonoNerdFont-Regular"
fm := fontManager.Get()
textShader, ok := shaderManager.Get().Get("text")
@@ -77,7 +78,11 @@ func (p *LicenseKeyPage) Init(ctx *PageCtx) error {
p.titleTextureHeight = titleHeight
// Load existing license key from database
licenseKey := p.Context.CfgPtr.LicenseKey
config, err := db.GetConfig(p.Context.DbPtr)
if err != nil {
panic(err)
}
licenseKey := config.LicenseKey
if licenseKey != "" {
p.inputText = licenseKey
@@ -188,9 +193,12 @@ func (p *LicenseKeyPage) HandleEvent(event *sdl.Event) error {
sdl.StopTextInput()
// Save license key to database
p.Context.CfgPtr.LicenseKey = 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.LicenseKey = p.inputText
p.Context.DbPtr.Save(config)
// Write license key to plain text file for the updater
if homeDir, err := os.UserHomeDir(); err == nil {
@@ -239,7 +247,7 @@ func (p *LicenseKeyPage) 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 *LicenseKeyPage) Update(dt float32) error {
// Get application font from database
applicationFont := "Roboto-Regular"
applicationFont := "SpaceMonoNerdFont-Regular"
fm := fontManager.Get()
sm := shaderManager.Get()
@@ -302,8 +310,12 @@ func (p *LicenseKeyPage) Update(dt float32) error {
// Render performs page drawing logic.
func (p *LicenseKeyPage) 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()