Skip to content

Commit

Permalink
Disable shortcuts according to authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Sep 7, 2024
1 parent 8be0a67 commit 675a05a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions Fyreplace/Commands/DestinationCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@ struct DestinationCommands: Commands {

var body: some Commands {
CommandGroup(after: .sidebar) {
Divider()
DestinationCommandsContent(eventBus: eventBus)
}
}
}

struct DestinationCommandsContent: View {
let eventBus: EventBus

ForEach(Destination.all) { destination in
Button(destination.titleKey) {
Task {
await eventBus.send(.navigationShortcut(to: destination))
}
@KeychainStorage("connection.token")
private var token

var body: some View {
Divider()

ForEach(Destination.all) { destination in
Button(destination.titleKey) {
Task {
eventBus.send(.navigationShortcut(to: destination))
}
.keyboardShortcut(destination.keyboardShortcut)
}

Divider()
.disabled(destination.requiresAuthentication && token.isEmpty)
.keyboardShortcut(destination.keyboardShortcut)
}

Divider()
}
}

0 comments on commit 675a05a

Please sign in to comment.