Skip to content

Commit 962106c

Browse files
committed
fix bugs and add a refresh button
1 parent d51f8e9 commit 962106c

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

StikJIT/Utilities/Extensions.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ extension UIDocumentPickerViewController {
1919
}
2020
}
2121

22+
extension Notification.Name {
23+
static let pairingFileImported = Notification.Name("PairingFileImported")
24+
}
25+
2226
extension UserDefaults {
2327
enum Keys {
2428
/// Forces the app to treat the current device as TXM-capable so scripts always run.

StikJIT/Views/HomeView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,16 @@ struct HomeView: View {
133133
try fileManager.removeItem(at: dest)
134134
}
135135
try fileManager.copyItem(at: url, to: dest)
136+
pubHeartBeat = false
136137
startHeartbeatInBackground()
138+
NotificationCenter.default.post(name: .pairingFileImported, object: nil)
139+
// Dismiss any existing heartbeat error alert
140+
if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
141+
let root = scene.windows.first?.rootViewController {
142+
var top = root
143+
while let presented = top.presentedViewController { top = presented }
144+
if top is UIAlertController { top.dismiss(animated: true) }
145+
}
137146
} catch {
138147
print("Error copying pairing file: \(error)")
139148
}

StikJIT/Views/InstalledAppsListView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ private enum AppListTab: Int, CaseIterable, Identifiable {
195195
ToolbarItem(placement: .navigationBarTrailing) {
196196
Button("Done") { dismiss() }.fontWeight(.semibold)
197197
}
198+
} else {
199+
ToolbarItem(placement: .navigationBarTrailing) {
200+
Button {
201+
viewModel.refreshAppLists()
202+
} label: {
203+
Image(systemName: "arrow.clockwise")
204+
}
205+
.disabled(viewModel.isLoading)
206+
}
198207
}
199208
}
200209
.onAppear {
@@ -233,6 +242,9 @@ private enum AppListTab: Int, CaseIterable, Identifiable {
233242
}
234243
.onChange(of: selectedTab) { _, _ in prefetchPriorityIcons() }
235244
.onChange(of: pinnedSystemApps) { _, _ in prefetchPriorityIcons() }
245+
.onReceive(NotificationCenter.default.publisher(for: .pairingFileImported)) { _ in
246+
viewModel.refreshAppLists()
247+
}
236248
}
237249

238250
// MARK: Apps List

0 commit comments

Comments
 (0)