Skip to content

Commit

Permalink
fix: preference saving might fail
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Oct 8, 2023
1 parent b3c494f commit ab2056b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
4 changes: 4 additions & 0 deletions backend/storage/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"strings"
"sync"
"tinyrdm/backend/consts"
"tinyrdm/backend/types"
)

Expand Down Expand Up @@ -45,6 +46,9 @@ func (p *PreferencesStorage) GetPreferences() (ret types.Preferences) {
defer p.mutex.Unlock()

ret = p.getPreferences()
ret.Behavior.AsideWidth = max(ret.Behavior.AsideWidth, consts.DEFAULT_ASIDE_WIDTH)
ret.Behavior.WindowWidth = max(ret.Behavior.WindowWidth, consts.DEFAULT_WINDOW_WIDTH)
ret.Behavior.WindowHeight = max(ret.Behavior.WindowHeight, consts.DEFAULT_WINDOW_HEIGHT)
return
}

Expand Down
16 changes: 4 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,15 @@ func main() {
app.startup(ctx)
connSvc.Start(ctx)
},
//OnBeforeClose: func(ctx context.Context) (prevent bool) {
// // save current window size
// width, height := runtime2.WindowGetSize(ctx)
// if width > 0 && height > 0 {
// if w, h := prefSvc.GetWindowSize(); w != width || h != height {
// prefSvc.SaveWindowSize(width, height)
// }
// }
// return false
//},
OnShutdown: func(ctx context.Context) {
OnBeforeClose: func(ctx context.Context) (prevent bool) {
// save current window size
width, height := runtime2.WindowGetSize(ctx)
if width > 0 && height > 0 {
prefSvc.SaveWindowSize(width, height)
}

return false
},
OnShutdown: func(ctx context.Context) {
connSvc.Stop(ctx)
},
Bind: []interface{}{
Expand Down

0 comments on commit ab2056b

Please sign in to comment.