more fyne.Do in controller

This commit is contained in:
Drew Weymouth
2025-02-08 08:35:34 -03:00
parent 94115f2875
commit 2ff3853015
2 changed files with 83 additions and 69 deletions
+16 -4
View File
@@ -403,7 +403,7 @@ func (m *Controller) DoEditPlaylistWorkflow(playlist *mediaprovider.Playlist) {
log.Printf("error deleting playlist: %s", err.Error())
} else if rte := m.CurPageFunc(); rte.Page == Playlist && rte.Arg == playlist.ID {
// navigate to playlists page if user is still on the page of the deleted playlist
m.NavigateTo(PlaylistsRoute())
fyne.Do(func() { m.NavigateTo(PlaylistsRoute()) })
}
}()
}
@@ -418,7 +418,7 @@ func (m *Controller) DoEditPlaylistWorkflow(playlist *mediaprovider.Playlist) {
log.Printf("error updating playlist: %s", err.Error())
} else if rte := m.CurPageFunc(); rte.Page == Playlist && rte.Arg == playlist.ID {
// if user is on playlist page, reload to get the updates
m.ReloadFunc()
fyne.Do(m.ReloadFunc)
}
}()
}
@@ -479,6 +479,7 @@ func (m *Controller) PromptForLoginAndConnect() {
defer cancel()
err := m.App.ServerManager.TestConnectionAndAuth(ctx, server.ServerConnection, password)
fyne.Do(func() {
if err == backend.ErrUnreachable {
d.SetErrorText(lang.L("Server unreachable"))
} else if err != nil {
@@ -489,6 +490,7 @@ func (m *Controller) PromptForLoginAndConnect() {
m.doModalClosed()
}
d.EnableSubmit()
})
}()
}
d.OnEditServer = func(server *backend.ServerConfig) {
@@ -498,7 +500,9 @@ func (m *Controller) PromptForLoginAndConnect() {
editD.OnSubmit = func() {
d.DisableSubmit()
go func() {
if m.testConnectionAndUpdateDialogText(editD) {
success := m.testConnectionAndUpdateDialogText(editD)
fyne.Do(func() {
if success {
// connection is good
editPop.Hide()
server.Hostname = editD.Host
@@ -510,6 +514,7 @@ func (m *Controller) PromptForLoginAndConnect() {
m.doModalClosed()
}
d.EnableSubmit()
})
}()
}
editD.OnCancel = func() {
@@ -525,7 +530,9 @@ func (m *Controller) PromptForLoginAndConnect() {
newD.OnSubmit = func() {
d.DisableSubmit()
go func() {
if m.testConnectionAndUpdateDialogText(newD) {
success := m.testConnectionAndUpdateDialogText(newD)
fyne.Do(func() {
if success {
// connection is good
newPop.Hide()
conn := backend.ServerConnection{
@@ -540,6 +547,7 @@ func (m *Controller) PromptForLoginAndConnect() {
m.doModalClosed()
}
d.EnableSubmit()
})
}()
}
newD.OnCancel = func() {
@@ -757,6 +765,7 @@ func (c *Controller) ShowShareDialog(id string) {
return
}
fyne.Do(func() {
hyperlink := widget.NewHyperlink(shareUrl.String(), shareUrl)
dlg := dialog.NewCustom(lang.L("Share content"), lang.L("OK"),
container.NewHBox(
@@ -775,6 +784,7 @@ func (c *Controller) ShowShareDialog(id string) {
c.MainWindow,
)
dlg.Show()
})
}()
}
@@ -908,6 +918,7 @@ func (c *Controller) ShowAlbumInfoDialog(albumID, albumName string, albumCover i
log.Print("Error getting album info: ", err)
return
}
fyne.Do(func() {
dlg := dialogs.NewAlbumInfoDialog(albumInfo, albumName, albumCover)
pop := widget.NewModalPopUp(dlg, c.MainWindow.Canvas())
dlg.OnDismiss = func() {
@@ -917,6 +928,7 @@ func (c *Controller) ShowAlbumInfoDialog(albumID, albumName string, albumCover i
c.ClosePopUpOnEscape(pop)
c.haveModal = true
pop.Show()
})
}()
}
+3 -1
View File
@@ -111,11 +111,13 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
m.BrowsingPane.AddSettingsMenuItem(lang.L("Check for Updates"), func() {
go func() {
if t := app.UpdateChecker.CheckLatestVersionTag(); t != "" && t != app.VersionTag() {
m.ShowNewVersionDialog(displayAppName, t)
fyne.Do(func() { m.ShowNewVersionDialog(displayAppName, t) })
} else {
fyne.Do(func() {
dialog.ShowInformation(lang.L("No new version found"),
lang.L("You are running the latest version of")+" "+displayAppName,
m.Window)
})
}
}()
})