Fix for map screen

This commit is contained in:
Selim Mustafaev 2025-05-17 17:55:26 +03:00
parent cc65dfbc06
commit 9fca82d2d9
3 changed files with 11 additions and 10 deletions

View File

@ -1661,7 +1661,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 164;
CURRENT_PROJECT_VERSION = 165;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
@ -1690,7 +1690,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 164;
CURRENT_PROJECT_VERSION = 165;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;

View File

@ -20,8 +20,6 @@ struct MapScreen: View {
init(mapInput: MapInput) {
print("==== MapScreen init ====")
self.viewModel = MapViewModel(
apiService: ServiceContainer.shared.resolve(ApiServiceProtocol.self),
mapInput: mapInput
@ -51,7 +49,6 @@ struct MapScreen: View {
}
.onMapCameraChange(frequency: .onEnd) { context in
Task.detached {
print("==== on map camera change ====")
await viewModel.reloadMarkers()
}
}

View File

@ -29,6 +29,13 @@ final class MapViewModel: ACHudContainer {
var mapSize: CGSize = .zero
var currentRegion: MKCoordinateRegion = .init()
var isFilter: Bool {
switch mapInput {
case .event: false
case .filter: true
}
}
init(apiService: ApiServiceProtocol, mapInput: MapInput) {
self.apiService = apiService
@ -40,8 +47,6 @@ final class MapViewModel: ACHudContainer {
return
}
print("===== onAppear ====")
switch mapInput {
case .event(let event):
markers = [makeMarkerModel(from: event)]
@ -63,7 +68,6 @@ final class MapViewModel: ACHudContainer {
}
func loadEvents(with filter: Filter) async {
print("==== Loading events ====")
await wrapWithToast { [weak self] in
guard let self else { return }
let events = try await apiService.events(with: filter)
@ -75,10 +79,10 @@ final class MapViewModel: ACHudContainer {
}
nonisolated func reloadMarkers() async {
guard await markers.isEmpty else {
guard await isFilter else {
return
}
print("==== Reloading markers ====")
async let changes = clusterManager.reload(
mapViewSize: mapSize,
coordinateRegion: currentRegion