fix bugs and add a refresh button

This commit is contained in:
Stephen B 2026-03-02 09:16:02 -05:00
parent d51f8e9b6c
commit 962106c63d
3 changed files with 25 additions and 0 deletions

View file

@ -19,6 +19,10 @@ extension UIDocumentPickerViewController {
}
}
extension Notification.Name {
static let pairingFileImported = Notification.Name("PairingFileImported")
}
extension UserDefaults {
enum Keys {
/// Forces the app to treat the current device as TXM-capable so scripts always run.

View file

@ -133,7 +133,16 @@ struct HomeView: View {
try fileManager.removeItem(at: dest)
}
try fileManager.copyItem(at: url, to: dest)
pubHeartBeat = false
startHeartbeatInBackground()
NotificationCenter.default.post(name: .pairingFileImported, object: nil)
// Dismiss any existing heartbeat error alert
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let root = scene.windows.first?.rootViewController {
var top = root
while let presented = top.presentedViewController { top = presented }
if top is UIAlertController { top.dismiss(animated: true) }
}
} catch {
print("Error copying pairing file: \(error)")
}

View file

@ -195,6 +195,15 @@ private enum AppListTab: Int, CaseIterable, Identifiable {
ToolbarItem(placement: .navigationBarTrailing) {
Button("Done") { dismiss() }.fontWeight(.semibold)
}
} else {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
viewModel.refreshAppLists()
} label: {
Image(systemName: "arrow.clockwise")
}
.disabled(viewModel.isLoading)
}
}
}
.onAppear {
@ -233,6 +242,9 @@ private enum AppListTab: Int, CaseIterable, Identifiable {
}
.onChange(of: selectedTab) { _, _ in prefetchPriorityIcons() }
.onChange(of: pinnedSystemApps) { _, _ in prefetchPriorityIcons() }
.onReceive(NotificationCenter.default.publisher(for: .pairingFileImported)) { _ in
viewModel.refreshAppLists()
}
}
// MARK: Apps List