fix: preference saving might fail
This commit is contained in:
parent
b3c494f15e
commit
ab2056ba3e
|
@ -7,6 +7,7 @@ import (
|
|||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"tinyrdm/backend/consts"
|
||||
"tinyrdm/backend/types"
|
||||
)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
16
main.go
16
main.go
|
@ -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{}{
|
||||
|
|
Loading…
Reference in New Issue