Replace server tabs with one window and a server picker
This commit is contained in:
@@ -24,7 +24,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
if flag {
|
||||
return true
|
||||
}
|
||||
Servers.shared.openAll()
|
||||
Servers.shared.openWindow?()
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -64,8 +64,8 @@ struct ByreApp: App {
|
||||
@NSApplicationDelegateAdaptor private var delegate: AppDelegate
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup(id: "main", for: String.self) { $origin in
|
||||
ServerWindow(origin: $origin)
|
||||
Window("byre", id: "main") {
|
||||
ServerWindow()
|
||||
}
|
||||
.defaultSize(width: 1280, height: 820)
|
||||
.restorationBehavior(.disabled)
|
||||
@@ -86,23 +86,16 @@ struct ByreCommands: Commands {
|
||||
Updater.shared.check()
|
||||
}
|
||||
Button("Forget Server") {
|
||||
focus?.forget?()
|
||||
focus?.forget()
|
||||
}
|
||||
.disabled(focus?.forget == nil)
|
||||
.disabled(focus == nil)
|
||||
}
|
||||
CommandGroup(replacing: .newItem) {
|
||||
Button("New Server Window") {
|
||||
Button("Add Server…") {
|
||||
Servers.shared.current = nil
|
||||
openWindow(id: "main")
|
||||
}
|
||||
.keyboardShortcut("n")
|
||||
Menu("Open Server") {
|
||||
ForEach(Servers.shared.origins, id: \.self) { origin in
|
||||
Button(URL(string: origin)?.host() ?? origin) {
|
||||
openWindow(id: "main", value: origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
.disabled(Servers.shared.origins.isEmpty)
|
||||
}
|
||||
PasteboardCommands()
|
||||
CommandMenu("Go") {
|
||||
@@ -119,9 +112,7 @@ struct ByreCommands: Commands {
|
||||
|
||||
private func serverButton(_ label: String, _ key: Character, _ step: Int) -> some View {
|
||||
Button(label) {
|
||||
if let origin = Servers.shared.step(from: focus?.origin, by: step) {
|
||||
openWindow(id: "main", value: origin)
|
||||
}
|
||||
Servers.shared.current = Servers.shared.step(from: Servers.shared.current, by: step)
|
||||
}
|
||||
.keyboardShortcut(KeyEquivalent(key))
|
||||
.disabled(Servers.shared.origins.isEmpty)
|
||||
|
||||
Reference in New Issue
Block a user