show What's New dialog when launching updated version

This commit is contained in:
Drew Weymouth
2023-11-06 17:59:35 -08:00
parent 7e8f0328ff
commit b83387e29c
7 changed files with 121 additions and 15 deletions
+12 -1
View File
@@ -46,6 +46,8 @@ type App struct {
appName string
appVersionTag string
configFile string
isFirstLaunch bool // set by config file reader
bgrndCtx context.Context
cancel context.CancelFunc
}
@@ -119,14 +121,23 @@ func StartupApp(appName, displayAppName, appVersionTag, configFile, latestReleas
return a, nil
}
func (a *App) IsFirstLaunch() bool {
return a.isFirstLaunch
}
func (a *App) readConfig() {
configdir.MakePath(configdir.LocalConfig(a.appName))
cfgPath := a.configPath()
var cfgExists bool
if _, err := os.Stat(cfgPath); err == nil {
cfgExists = true
}
a.isFirstLaunch = !cfgExists
cfg, err := ReadConfigFile(cfgPath, a.appVersionTag)
if err != nil {
log.Printf("Error reading app config file: %v", err)
cfg = DefaultConfig(a.appVersionTag)
if _, err := os.Stat(cfgPath); err == nil {
if cfgExists {
backupCfgName := fmt.Sprintf("%s.bak", a.configFile)
log.Printf("Config file may be malformed: copying to %s", backupCfgName)
_ = util.CopyFile(cfgPath, path.Join(configdir.LocalConfig(a.appName), backupCfgName))
+2
View File
@@ -25,6 +25,7 @@ type AppConfig struct {
WindowWidth int
WindowHeight int
LastCheckedVersion string
LastLaunchedVersion string
EnableSystemTray bool
CloseToSystemTray bool
StartupPage string
@@ -128,6 +129,7 @@ func DefaultConfig(appVersionTag string) *Config {
WindowWidth: 1000,
WindowHeight: 800,
LastCheckedVersion: appVersionTag,
LastLaunchedVersion: "",
EnableSystemTray: true,
CloseToSystemTray: false,
StartupPage: "Albums",