hacky solution to avoid occasional window misdrawing on startup
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"supersonic/backend"
|
"supersonic/backend"
|
||||||
"supersonic/ui"
|
"supersonic/ui"
|
||||||
|
"time"
|
||||||
|
|
||||||
"fyne.io/fyne/v2/app"
|
"fyne.io/fyne/v2/app"
|
||||||
"github.com/20after4/configdir"
|
"github.com/20after4/configdir"
|
||||||
@@ -28,24 +29,32 @@ func main() {
|
|||||||
|
|
||||||
fyneApp := app.New()
|
fyneApp := app.New()
|
||||||
mainWindow := ui.NewMainWindow(fyneApp, appname, myApp)
|
mainWindow := ui.NewMainWindow(fyneApp, appname, myApp)
|
||||||
defaultServer := myApp.Config.GetDefaultServer()
|
|
||||||
if defaultServer == nil {
|
// TODO: There is some race condition with running this initial startup
|
||||||
mainWindow.PromptForFirstServer(func(nick, host, user, pass string) {
|
// task immediately before showing and running the window/Fyne main loop where
|
||||||
server := myApp.Config.AddServer(nick, host, user)
|
// the window can occasionally get misdrawn on startup. (Only seen on Ubuntu so far).
|
||||||
err := keyring.Set(appname, server.ID.String(), pass)
|
// This makes it much less likely to occur (not seen on dozens of startups)
|
||||||
if err != nil {
|
// but is a hacky "solution"!
|
||||||
log.Printf("error setting keyring credentials: %v", err)
|
go func() {
|
||||||
// TODO: handle?
|
time.Sleep(75 * time.Millisecond)
|
||||||
}
|
defaultServer := myApp.Config.GetDefaultServer()
|
||||||
setupServer(myApp, server)
|
if defaultServer == nil {
|
||||||
})
|
mainWindow.PromptForFirstServer(func(nick, host, user, pass string) {
|
||||||
} else {
|
server := myApp.Config.AddServer(nick, host, user)
|
||||||
setupServer(myApp, defaultServer)
|
err := keyring.Set(appname, server.ID.String(), pass)
|
||||||
}
|
if err != nil {
|
||||||
|
log.Printf("error setting keyring credentials: %v", err)
|
||||||
|
// TODO: handle?
|
||||||
|
}
|
||||||
|
setupServer(myApp, server)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
setupServer(myApp, defaultServer)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
mainWindow.Show()
|
mainWindow.Show()
|
||||||
fyneApp.Run()
|
fyneApp.Run()
|
||||||
|
|
||||||
myApp.Config.WriteConfigFile(configPath())
|
myApp.Config.WriteConfigFile(configPath())
|
||||||
myApp.Shutdown()
|
myApp.Shutdown()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user