Skip to content

Commit

Permalink
Fix EXEs opening directly if only 1 bottle exists
Browse files Browse the repository at this point in the history
Co-authored-by: nastys <[email protected]>
  • Loading branch information
IsaacMarovitz and nastys committed Mar 6, 2024
1 parent 5c6ecca commit 977ff34
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 977ff34

Please sign in to comment.