feat: add auto-update functionality
This commit is contained in:
@@ -9,8 +9,10 @@ import (
|
||||
"time"
|
||||
|
||||
"daily-timer/internal/models"
|
||||
"daily-timer/internal/services/updater"
|
||||
"daily-timer/internal/storage"
|
||||
"daily-timer/internal/timer"
|
||||
"daily-timer/internal/version"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
@@ -21,12 +23,14 @@ type App struct {
|
||||
timer *timer.Timer
|
||||
session *models.MeetingSession
|
||||
currentLogs map[uint]*models.ParticipantLog
|
||||
updater *updater.Updater
|
||||
}
|
||||
|
||||
func New(store *storage.Storage) *App {
|
||||
return &App{
|
||||
store: store,
|
||||
currentLogs: make(map[uint]*models.ParticipantLog),
|
||||
updater: updater.New(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,3 +483,28 @@ func (a *App) GetSoundsDir() string {
|
||||
_ = os.MkdirAll(soundsDir, 0755)
|
||||
return soundsDir
|
||||
}
|
||||
|
||||
// Updates
|
||||
|
||||
func (a *App) GetVersion() string {
|
||||
return version.Version
|
||||
}
|
||||
|
||||
func (a *App) CheckForUpdates() (*updater.UpdateInfo, error) {
|
||||
return a.updater.CheckForUpdates()
|
||||
}
|
||||
|
||||
func (a *App) DownloadAndInstallUpdate() error {
|
||||
err := a.updater.DownloadAndInstall(func(progress float64) {
|
||||
runtime.EventsEmit(a.ctx, "update:progress", progress)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
runtime.EventsEmit(a.ctx, "update:complete", true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestartApp() error {
|
||||
return a.updater.RestartApp()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user