Skip to content

Commit

Permalink
Fix opening exe files with one bottle
Browse files Browse the repository at this point in the history
  • Loading branch information
nastys committed Feb 26, 2024
1 parent a424573 commit 35e5117
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Whisky/Views/FileOpenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,19 @@ struct FileOpenView: View {
}
.frame(minWidth: 400, minHeight: 115)
.onAppear {
if bottles.count <= 1 {
// Makes sure there are more than 0 bottles.
// Otherwise, it will crash on the nil cascade
if bottles.count <= 0 {
dismiss()
return
}

selection = bottles.first(where: { $0.url == currentBottle })?.url ?? bottles[0].url

if bottles.count == 1 {
// If the user only has one bottle
// there's nothing for them to select
run()
} else if bottles.count > 0 {
// Makes sure there are more than 0 bottles.
// Otherwise, it will crash on the nil cascade
selection = bottles.first(where: { $0.url == currentBottle })?.url ?? bottles[0].url
}
}
}
Expand Down

0 comments on commit 35e5117

Please sign in to comment.