aboutsummaryrefslogtreecommitdiff
path: root/Hotline/MacApp.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-10-24 14:16:30 -0700
committerDustin Mierau <dustin@mierau.me>2025-10-24 14:16:30 -0700
commit8bab12046b2c91cff7e1194e576acecf57551e08 (patch)
treeefd06a26ee7a12e43b6d77c147347459f8092427 /Hotline/MacApp.swift
parent2df678753e2e6fe309de6b546925540f89e3d680 (diff)
Further along work towards auto updating. Show release notes for the builds that are more recent than yours.
Diffstat (limited to 'Hotline/MacApp.swift')
-rw-r--r--Hotline/MacApp.swift56
1 files changed, 53 insertions, 3 deletions
diff --git a/Hotline/MacApp.swift b/Hotline/MacApp.swift
index a4ff3cb..a91df52 100644
--- a/Hotline/MacApp.swift
+++ b/Hotline/MacApp.swift
@@ -61,6 +61,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// NotificationCenter.default.removeObserver(token)
// }
// }
+
+ Task {
+ await AppUpdate.shared.checkForUpdatesOnLaunch()
+ }
}
func applicationWillTerminate(_ notification: Notification) {
@@ -78,6 +82,7 @@ struct Application: App {
@State private var hotlinePanel: HotlinePanel? = nil
@State private var selection: TrackerSelection? = nil
+ @Bindable private var update = AppUpdate.shared
@FocusedValue(\.activeHotlineModel) private var activeHotline: Hotline?
@FocusedValue(\.activeServerState) private var activeServerState: ServerState?
@@ -112,15 +117,43 @@ struct Application: App {
}
}
}
+ .onChange(of: self.update.showWindow) {
+ if self.update.showWindow {
+ self.openWindow(id: "update")
+ }
+ }
// MARK: About Box
Window("About", id: "about") {
AboutView()
- .ignoresSafeArea()
- .background(Color.hotlineRed)
+ .background(Color.hotlineRed, ignoresSafeAreaEdges: .all)
+ .windowFullScreenBehavior(.disabled)
+ .toolbar(removing: .title)
+ .gesture(WindowDragGesture())
+ .background(
+ WindowConfigurator { window in
+ window.titlebarAppearsTransparent = true
+ window.titlebarSeparatorStyle = .none
+ window.isMovableByWindowBackground = true
+
+ if let closeButton = window.standardWindowButton(.closeButton) {
+ closeButton.isHidden = false // make sure it’s visible
+ closeButton.isEnabled = true
+ }
+
+ if let btn = window.standardWindowButton(.zoomButton) {
+ btn.isHidden = true
+ }
+
+ if let btn = window.standardWindowButton(.miniaturizeButton) {
+ btn.isHidden = true
+ }
+ }
+ )
}
.windowResizability(.contentSize)
.windowStyle(.hiddenTitleBar)
+ .restorationBehavior(.disabled)
.defaultPosition(.center)
.commandsRemoved() // Remove About that was automatically added to Window menu.
.commands {
@@ -128,9 +161,26 @@ struct Application: App {
Button("About Hotline") {
openWindow(id: "about")
}
+
+ Button("Check for Updates...") {
+ Task {
+ await AppUpdate.shared.checkForUpdatesManually()
+ }
+ }
}
}
+ // MARK: Update Window
+ Window("New Update", id: "update") {
+ AppUpdateView()
+ .windowFullScreenBehavior(.disabled)
+ }
+ .windowResizability(.contentSize)
+ .windowStyle(.hiddenTitleBar)
+ .restorationBehavior(.disabled)
+ .defaultPosition(.center)
+ .commandsRemoved()
+
// MARK: Server Window
WindowGroup(id: "server", for: Server.self) { server in
ServerView(server: server)
@@ -189,7 +239,7 @@ struct Application: App {
}
}
Divider()
- Button("Download Latest...") {
+ Button("Open Latest Release Page...") {
if let url = URL(string: "https://github.com/mierau/hotline/releases/latest") {
openURL(url)
}