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)
80 lines
1.4 KiB
Go
80 lines
1.4 KiB
Go
package page
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
"rhemawavetech.com/rhemawave/internal/download"
|
|
)
|
|
|
|
type pageType int
|
|
|
|
const (
|
|
HOME pageType = iota
|
|
SCROLLER
|
|
SETTINGS
|
|
WIFI
|
|
AUDIO
|
|
PROCLAMATIONS
|
|
LICENSE_KEY
|
|
EMAIL_ADDRESS
|
|
LOGS
|
|
MESSAGE
|
|
DOWNLOADING_ASSETS
|
|
)
|
|
|
|
type PageCtx struct {
|
|
DbPtr *gorm.DB
|
|
W, H int32
|
|
MessageChannel chan download.DownloadStatus
|
|
RefreshConfig func()
|
|
NavigateTo func(pageType)
|
|
Msg string // Message to be displayed by MessagePage
|
|
Inst string // Instructions to be displayed on MessagePage
|
|
}
|
|
|
|
type Router struct {
|
|
ActivePage Page
|
|
Context PageCtx
|
|
}
|
|
|
|
func NewRouter(pgCtx PageCtx) *Router {
|
|
r := &Router{
|
|
Context: pgCtx,
|
|
}
|
|
r.Context.NavigateTo = r.NavigateTo
|
|
r.NavigateTo(HOME)
|
|
return r
|
|
}
|
|
|
|
func (r *Router) NavigateTo(p pageType) {
|
|
if r.ActivePage != nil {
|
|
r.ActivePage.Destroy()
|
|
}
|
|
|
|
switch p {
|
|
case HOME:
|
|
r.ActivePage = &Home{}
|
|
case SCROLLER:
|
|
r.ActivePage = &ScrollerPage{}
|
|
case SETTINGS:
|
|
r.ActivePage = &Settings{}
|
|
case WIFI:
|
|
r.ActivePage = &WiFiSetupPage{}
|
|
case AUDIO:
|
|
r.ActivePage = &AudioOptions{}
|
|
case PROCLAMATIONS:
|
|
r.ActivePage = &ProclamationOptions{}
|
|
case LICENSE_KEY:
|
|
r.ActivePage = &LicenseKeyPage{}
|
|
case EMAIL_ADDRESS:
|
|
r.ActivePage = &EmailAddressPage{}
|
|
case LOGS:
|
|
r.ActivePage = &LogViewerPage{}
|
|
case MESSAGE:
|
|
r.ActivePage = &MessagePage{}
|
|
case DOWNLOADING_ASSETS:
|
|
r.ActivePage = &DownloadingAssets{}
|
|
}
|
|
|
|
r.ActivePage.Init(&r.Context)
|
|
}
|