Fix Swift 6 isolation: hop to @MainActor inside Timer callback for EOSE tracker mutations

This commit is contained in:
jack
2025-09-13 11:53:19 +02:00
parent fecebb05d5
commit 5bf28e5ba4
2 changed files with 11 additions and 6 deletions
+7 -5
View File
@@ -264,11 +264,13 @@ final class NostrRelayManager: ObservableObject {
var tracker = EOSETracker(pendingRelays: Set(urls), callback: onEOSE, timer: nil)
// Fallback timeout to avoid hanging if a relay never sends EOSE
tracker.timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { [weak self] _ in
guard let self = self else { return }
if let t = self.eoseTrackers[id] {
t.timer?.invalidate()
self.eoseTrackers.removeValue(forKey: id)
onEOSE()
Task { @MainActor in
guard let self = self else { return }
if let t = self.eoseTrackers[id] {
t.timer?.invalidate()
self.eoseTrackers.removeValue(forKey: id)
onEOSE()
}
}
}
eoseTrackers[id] = tracker
+4 -1
View File
@@ -1183,7 +1183,7 @@ struct ContentView: View {
notesGeohash = LocationChannelManager.shared.availableChannels.first(where: { $0.level == .block })?.geohash
showLocationNotes = true
}) {
HStack(spacing: 4) {
HStack(alignment: .center, spacing: 4) {
Image(systemName: "long.text.page.and.pencil")
.font(.system(size: 12))
.foregroundColor(Color(hue: 0.60, saturation: 0.85, brightness: 0.82))
@@ -1191,8 +1191,11 @@ struct ContentView: View {
Text("\(c)")
.font(.system(size: 11, design: .monospaced))
.foregroundColor(Color(hue: 0.60, saturation: 0.85, brightness: 0.82))
.lineLimit(1)
.fixedSize(horizontal: true, vertical: false)
}
}
.fixedSize(horizontal: true, vertical: false)
}
.buttonStyle(.plain)
.accessibilityLabel("Location notes for this place")