06/22 Add Check for Update button in Settings
This commit is contained in:
@@ -1890,6 +1890,7 @@ struct SettingsView: View {
|
||||
@EnvironmentObject private var auth: AuthManager
|
||||
@EnvironmentObject private var sync: SyncManager
|
||||
@EnvironmentObject private var appearance: AppearanceManager
|
||||
@StateObject private var updateChecker = UpdateChecker.shared
|
||||
@Environment(\.modelContext) private var context
|
||||
|
||||
@State private var showClearCacheAlert = false
|
||||
@@ -1897,6 +1898,7 @@ struct SettingsView: View {
|
||||
@State private var settingsServer: ServerOption = ServerConfig.selectedOption
|
||||
@State private var pendingServer: ServerOption? = nil
|
||||
@State private var showServerSwitchAlert = false
|
||||
@State private var hasCheckedOnce = false
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
@@ -1992,6 +1994,29 @@ struct SettingsView: View {
|
||||
|
||||
Section("App Info") {
|
||||
LabeledContent("Version", value: "\(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0") (\(Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "1"))")
|
||||
|
||||
Button {
|
||||
Task {
|
||||
await updateChecker.checkForUpdate(force: true)
|
||||
hasCheckedOnce = true
|
||||
}
|
||||
} label: {
|
||||
if updateChecker.isChecking {
|
||||
HStack {
|
||||
ProgressView()
|
||||
Text("Checking…")
|
||||
}
|
||||
} else {
|
||||
Label("Check for Updates", systemImage: "arrow.triangle.2.circlepath")
|
||||
}
|
||||
}
|
||||
.disabled(updateChecker.isChecking)
|
||||
|
||||
if hasCheckedOnce, !updateChecker.isChecking, !updateChecker.updateAvailable {
|
||||
Label("You're on the latest version.", systemImage: "checkmark.circle.fill")
|
||||
.foregroundStyle(.green)
|
||||
.font(.callout)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationTitle("Settings")
|
||||
|
||||
Reference in New Issue
Block a user