fix crash
Some checks failed
CloudSave/pipeline/head There was a failure building this commit

This commit is contained in:
2025-09-07 19:30:05 +02:00
parent e6ca29a7aa
commit 7e5d8855d4

View File

@@ -43,6 +43,14 @@ func Make(a fyne.App, d *data.Service) fyne.Window {
toolbar := widget.NewToolbar(
widget.NewToolbarAction(theme.FolderNewIcon(), func() {
folderSelection := dialog.NewFolderOpen(func(lu fyne.ListableURI, err error) {
if err != nil {
d := dialog.NewError(fmt.Errorf("failed to open window: %w", err), w)
d.Show()
return
}
if lu == nil {
return
}
confirmDialog := dialog.NewConfirm("Add", "Do you want to add and scan '"+lu.Path()+"'?", func(accepted bool) {
if !accepted {
return
@@ -55,22 +63,32 @@ func Make(a fyne.App, d *data.Service) fyne.Window {
go func() {
gameID, err := d.Add(name, lu.Path(), "")
if err != nil {
d := dialog.NewError(fmt.Errorf("failed to create metadata the directory: %w", err), w)
d.Show()
fyne.Do(func() {
d := dialog.NewError(fmt.Errorf("failed to create metadata the directory: %w", err), w)
d.Show()
loadingDialog.Hide()
})
return
}
_, err = d.Scan(gameID)
if err != nil {
d := dialog.NewError(fmt.Errorf("failed to scan the directory: %w", err), w)
d.Show()
fyne.Do(func() {
d := dialog.NewError(fmt.Errorf("failed to scan the directory: %w", err), w)
d.Show()
loadingDialog.Hide()
})
return
}
games, err = d.AllGames()
if err != nil {
d := dialog.NewError(fmt.Errorf("failed to load datastore: %w", err), w)
d.Show()
fyne.Do(func() {
d := dialog.NewError(fmt.Errorf("failed to load datastore: %w", err), w)
d.Show()
loadingDialog.Hide()
})
return
}
fyne.Do(func() {