Fix add button. Fix hotkeys in settings. Add Workspace hotkeys
This commit is contained in:
@@ -104,6 +104,37 @@ final class WorkspaceRegistry: ObservableObject {
|
||||
persistWorkspaceSummaries()
|
||||
}
|
||||
|
||||
func updateWorkspaceHotkey(id: WorkspaceID, to hotkey: HotkeyBinding?) {
|
||||
guard let index = workspaceSummaries.firstIndex(where: { $0.id == id }) else { return }
|
||||
guard workspaceSummaries[index].hotkey != hotkey else { return }
|
||||
|
||||
workspaceSummaries[index].hotkey = hotkey
|
||||
controllers[id]?.updateHotkey(hotkey)
|
||||
persistWorkspaceSummaries()
|
||||
}
|
||||
|
||||
func nextWorkspaceID(after id: WorkspaceID) -> WorkspaceID? {
|
||||
guard !workspaceSummaries.isEmpty else { return nil }
|
||||
guard let index = workspaceSummaries.firstIndex(where: { $0.id == id }) else {
|
||||
return workspaceSummaries.first?.id
|
||||
}
|
||||
|
||||
let nextIndex = workspaceSummaries.index(after: index)
|
||||
return workspaceSummaries[nextIndex == workspaceSummaries.endIndex ? workspaceSummaries.startIndex : nextIndex].id
|
||||
}
|
||||
|
||||
func previousWorkspaceID(before id: WorkspaceID) -> WorkspaceID? {
|
||||
guard !workspaceSummaries.isEmpty else { return nil }
|
||||
guard let index = workspaceSummaries.firstIndex(where: { $0.id == id }) else {
|
||||
return workspaceSummaries.last?.id
|
||||
}
|
||||
|
||||
let previousIndex = index == workspaceSummaries.startIndex
|
||||
? workspaceSummaries.index(before: workspaceSummaries.endIndex)
|
||||
: workspaceSummaries.index(before: index)
|
||||
return workspaceSummaries[previousIndex].id
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func deleteWorkspace(id: WorkspaceID) -> Bool {
|
||||
guard canDeleteWorkspace(id: id) else { return false }
|
||||
|
||||
Reference in New Issue
Block a user