From f5f59d3020112b559ca4ce168c7dd5c3bff9de85 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Sat, 9 May 2026 14:18:07 +0700 Subject: [PATCH] Require Google place for voice reviews --- lib/api/mapflow_api.dart | 1 + lib/models/place_models.dart | 2 ++ lib/screens/mapflow_shell.dart | 2 +- lib/state/place_controller.dart | 13 ++++--------- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/api/mapflow_api.dart b/lib/api/mapflow_api.dart index 60cf676..80f6e9e 100644 --- a/lib/api/mapflow_api.dart +++ b/lib/api/mapflow_api.dart @@ -178,6 +178,7 @@ class MapflowApi { final place = item as Map; return PlaceRecommendation( id: place['id'] as String, + googlePlaceId: place['googlePlaceId'] as String, name: place['name'] as String, area: '', photoUrls: const [], diff --git a/lib/models/place_models.dart b/lib/models/place_models.dart index 0e23db9..032eec6 100644 --- a/lib/models/place_models.dart +++ b/lib/models/place_models.dart @@ -84,6 +84,7 @@ extension PlaceTraitText on PlaceTrait { class PlaceRecommendation { const PlaceRecommendation({ required this.id, + required this.googlePlaceId, required this.name, required this.area, required this.photoUrls, @@ -92,6 +93,7 @@ class PlaceRecommendation { }); final String id; + final String googlePlaceId; final String name; final String area; final List photoUrls; diff --git a/lib/screens/mapflow_shell.dart b/lib/screens/mapflow_shell.dart index 4dce632..2826572 100644 --- a/lib/screens/mapflow_shell.dart +++ b/lib/screens/mapflow_shell.dart @@ -869,7 +869,7 @@ class _AddExperienceFlowState extends ConsumerState { } setState(() => _submitting = true); controller.setReviewPlace(selectedPlace.name); - await controller.publishReview(coordinate: selectedPlace.coordinate); + await controller.publishReview(place: selectedPlace); if (!context.mounted) { return; } diff --git a/lib/state/place_controller.dart b/lib/state/place_controller.dart index e78ef33..0323379 100644 --- a/lib/state/place_controller.dart +++ b/lib/state/place_controller.dart @@ -161,23 +161,18 @@ class PlaceController extends AsyncNotifier { ); } - Future publishReview({LatLng? coordinate}) async { + Future publishReview({required PlaceRecommendation place}) async { final value = state.requireValue; if (!value.hasTelegramAuth) { throw StateError('Открой через Telegram, чтобы оставить голос.'); } final draft = value.reviewDraft; - final placeName = draft.placeName.trim().isEmpty - ? 'Место на карте' - : draft.placeName.trim(); - final point = - coordinate ?? value.userCoordinate ?? const LatLng(10.7729, 106.7004); await _api.createVoiceExperience( - googlePlaceId: 'manual-${point.latitude}-${point.longitude}-$placeName', - googleName: placeName, - coordinate: point, + googlePlaceId: place.googlePlaceId, + googleName: place.name, + coordinate: place.coordinate, durationSeconds: draft.duration.inSeconds, audioObjectKey: 'web-recording-${DateTime.now().microsecondsSinceEpoch}', );