Focus the project dashboard when ⌘P opens it
This commit is contained in:
@@ -8,8 +8,10 @@ private let refreshKinds: Set<String> = ["task.merged", "project.created"]
|
||||
|
||||
struct ProjectView: View {
|
||||
@Environment(Store.self) private var store
|
||||
@Environment(Overlays.self) private var overlays
|
||||
@ViewState private var todos: [String: Result<Todo, ApiError>] = [:]
|
||||
@ViewState private var off: (() -> Void)?
|
||||
@FocusState private var focused: Bool
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
@@ -23,6 +25,17 @@ struct ProjectView: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.focusable()
|
||||
.focusEffectDisabled()
|
||||
.focused($focused)
|
||||
.onChange(of: overlays.projectFocus, initial: true) {
|
||||
if overlays.projectFocus {
|
||||
overlays.projectFocus = false
|
||||
DispatchQueue.main.async {
|
||||
focused = true
|
||||
}
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
off = store.events.add { ev in
|
||||
if refreshKinds.contains(ev.kind), let projectId = ev.projectId {
|
||||
|
||||
Reference in New Issue
Block a user