diff --git a/StikJIT/Utilities/Extensions.swift b/StikJIT/Utilities/Extensions.swift index d224f6e..1e2067b 100644 --- a/StikJIT/Utilities/Extensions.swift +++ b/StikJIT/Utilities/Extensions.swift @@ -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. diff --git a/StikJIT/Views/HomeView.swift b/StikJIT/Views/HomeView.swift index 52c1e0d..8af78fa 100644 --- a/StikJIT/Views/HomeView.swift +++ b/StikJIT/Views/HomeView.swift @@ -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)") } diff --git a/StikJIT/Views/InstalledAppsListView.swift b/StikJIT/Views/InstalledAppsListView.swift index 278f1c5..adc15a1 100644 --- a/StikJIT/Views/InstalledAppsListView.swift +++ b/StikJIT/Views/InstalledAppsListView.swift @@ -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