Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Mage/DataSourceMapViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DataSourceTileOverlay
import DataSourceDefinition
import Combine

@MainActor
class DataSourceMapViewModel {
var dataSource: any DataSourceDefinition
var key: String
Expand Down Expand Up @@ -45,6 +46,7 @@ class DataSourceMapViewModel {

let requerySubject = PassthroughSubject<Void, Never>()

@MainActor
init(
dataSource: any DataSourceDefinition,
key: String,
Expand Down
3 changes: 3 additions & 0 deletions Mage/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@
}
}
},
"Delete" : {
"comment" : "Alert delete button"
},
"Downloaded %@ of %@" : {
"localizations" : {
"en" : {
Expand Down
7 changes: 4 additions & 3 deletions Mage/Mixins/DataSourceMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class DataSourceMap: MapMixin {
.receive(on: DispatchQueue.main)
.sink { [weak self] annotations in
Task { [weak self] in
await self?.handleFeatureChanges(annotations: annotations)
self?.handleFeatureChanges(annotations: annotations)
}
}
.store(in: &cancellable)
Expand All @@ -62,7 +62,7 @@ class DataSourceMap: MapMixin {
.receive(on: DispatchQueue.main)
.sink { [weak self] featureOverlays in
Task { [weak self] in
await self?.handleFeatureOverlayChanges(featureOverlays: featureOverlays)
self?.handleFeatureOverlayChanges(featureOverlays: featureOverlays)
}
}
.store(in: &cancellable)
Expand All @@ -71,7 +71,7 @@ class DataSourceMap: MapMixin {
.receive(on: DispatchQueue.main)
.sink { [weak self] tileOverlays in
Task { [weak self] in
await self?.updateTileOverlays(tileOverlays: tileOverlays)
self?.updateTileOverlays(tileOverlays: tileOverlays)
}
}
.store(in: &cancellable)
Expand Down Expand Up @@ -266,6 +266,7 @@ class DataSourceMap: MapMixin {
return !inserts.isEmpty || !removals.isEmpty
}

@MainActor
func removeMixin(mapView: MKMapView, mapState: MapState) {
mapView.removeOverlays(viewModel?.featureOverlays ?? [])
mapView.removeAnnotations(viewModel?.annotations ?? [])
Expand Down
1 change: 1 addition & 0 deletions Mage/Mixins/FilteredUsersMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import MapKit
import MapFramework

@MainActor
protocol FilteredUsersMap {
var mapView: MKMapView? { get set }
var filteredUsersMapMixin: FilteredUsersMapMixin? { get set }
Expand Down
1 change: 1 addition & 0 deletions Mage/Observation/ObservationsMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ObservationsMap: DataSourceMap {
@Injected(\.observationImageRepository)
var imageRepository: ObservationImageRepository

@MainActor
init() {
super.init(
dataSource: DataSources.observation
Expand Down
5 changes: 3 additions & 2 deletions Mage/Repository/FeatureItem/FeatureItemDefinition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ extension DataSources {
static let featureItem: FeatureItemDefinition = FeatureItemDefinition.definition
}

class FeatureItemDefinition: DataSourceDefinition {
var mappable: Bool = true
final
class FeatureItemDefinition: DataSourceDefinition, Sendable {
var mappable: Bool = true

var color: UIColor = .magenta

Expand Down
2 changes: 1 addition & 1 deletion Mage/Repository/Feed/FeedItemAnnotation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FeedItemAnnotation: DataSourceAnnotation {

public override var dataSource: any DataSourceDefinition {
get {
DataSources.feedItem
DataSources.feedItem // ERROR: Main actor-isolated conformance of 'FeedItemDefinition' to 'DataSourceDefinition' cannot be used in nonisolated context; this is an error in the Swift 6 language mode
}
set { }
}
Expand Down
6 changes: 3 additions & 3 deletions Mage/Repository/MapFeatureRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import GeoPackage
import DataSourceDefinition
import MapFramework

struct AnnotationsAndOverlays {
let annotations: [DataSourceAnnotation]
let overlays: [MKOverlay]
struct AnnotationsAndOverlays: Sendable {
let annotations: [DataSourceAnnotation] // Error: Stored property 'annotations' of 'Sendable'-conforming struct 'AnnotationsAndOverlays' has non-sendable type '[DataSourceAnnotation]'
let overlays: [MKOverlay] // Error: Stored property 'overlays' of 'Sendable'-conforming struct 'AnnotationsAndOverlays' has non-sendable type '[any MKOverlay]'
}

protocol MapFeatureRepository {
Expand Down
1 change: 1 addition & 0 deletions Mage/Routing/MageNavStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Kingfisher
import UIKit
import CoreLocation

@MainActor
class MageNavStack: UIViewController {
@Injected(\.currentLocationRepository)
var currentLocationRepository: CurrentLocationRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import UIKit
import SwiftUI

//@MainActor
public protocol DataSourceDefinition: ObservableObject {
var mappable: Bool { get }
var color: UIColor { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class UnknownDefinition: DataSourceDefinition {
private init() { }
}

//@MainActor
open class DataSourceAnnotation: NSObject, MKAnnotation, Identifiable, DataSourceIdentifiable {
static func == (lhs: DataSourceAnnotation, rhs: DataSourceAnnotation) -> Bool {
lhs.id == rhs.id
Expand Down
3 changes: 2 additions & 1 deletion Packages/MapFramework/Sources/MapFramework/MapMixin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import CoreGraphics
import DataSourceTileOverlay
import SwiftUI

@MainActor
public protocol MapMixin {
var uuid: UUID { get }
func cleanupMixin()
Expand All @@ -26,7 +27,7 @@ public protocol MapMixin {
touchPoint: CGPoint
) async -> [String: [String]]

func setupMixin(mapView: MKMapView, mapState: MapState)
func setupMixin(mapView: MKMapView, mapState: MapState)
func removeMixin(mapView: MKMapView, mapState: MapState)
func updateMixin(mapView: MKMapView, mapState: MapState)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Foundation

@MainActor
protocol MapProtocol {
var mixins: MapMixins { get set }
var mapState: MapState { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI
import MapKit
import MAGEStyle

@MainActor
public struct MapRepresentable: UIViewRepresentable, MapProtocol {
var notificationOnTap: NSNotification.Name = .MapItemsTapped
var notificationOnLongPress: NSNotification.Name = .MapLongPress
Expand Down