Require Google place for voice reviews
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 1m49s
All checks were successful
Build and deploy Flutter Web / build (push) Successful in 1m49s
This commit is contained in:
@@ -178,6 +178,7 @@ class MapflowApi {
|
||||
final place = item as Map<String, dynamic>;
|
||||
return PlaceRecommendation(
|
||||
id: place['id'] as String,
|
||||
googlePlaceId: place['googlePlaceId'] as String,
|
||||
name: place['name'] as String,
|
||||
area: '',
|
||||
photoUrls: const [],
|
||||
|
||||
@@ -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<String> photoUrls;
|
||||
|
||||
@@ -869,7 +869,7 @@ class _AddExperienceFlowState extends ConsumerState<AddExperienceFlow> {
|
||||
}
|
||||
setState(() => _submitting = true);
|
||||
controller.setReviewPlace(selectedPlace.name);
|
||||
await controller.publishReview(coordinate: selectedPlace.coordinate);
|
||||
await controller.publishReview(place: selectedPlace);
|
||||
if (!context.mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,23 +161,18 @@ class PlaceController extends AsyncNotifier<PlaceState> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> publishReview({LatLng? coordinate}) async {
|
||||
Future<void> 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}',
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user