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>;
|
final place = item as Map<String, dynamic>;
|
||||||
return PlaceRecommendation(
|
return PlaceRecommendation(
|
||||||
id: place['id'] as String,
|
id: place['id'] as String,
|
||||||
|
googlePlaceId: place['googlePlaceId'] as String,
|
||||||
name: place['name'] as String,
|
name: place['name'] as String,
|
||||||
area: '',
|
area: '',
|
||||||
photoUrls: const [],
|
photoUrls: const [],
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ extension PlaceTraitText on PlaceTrait {
|
|||||||
class PlaceRecommendation {
|
class PlaceRecommendation {
|
||||||
const PlaceRecommendation({
|
const PlaceRecommendation({
|
||||||
required this.id,
|
required this.id,
|
||||||
|
required this.googlePlaceId,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.area,
|
required this.area,
|
||||||
required this.photoUrls,
|
required this.photoUrls,
|
||||||
@@ -92,6 +93,7 @@ class PlaceRecommendation {
|
|||||||
});
|
});
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
|
final String googlePlaceId;
|
||||||
final String name;
|
final String name;
|
||||||
final String area;
|
final String area;
|
||||||
final List<String> photoUrls;
|
final List<String> photoUrls;
|
||||||
|
|||||||
@@ -869,7 +869,7 @@ class _AddExperienceFlowState extends ConsumerState<AddExperienceFlow> {
|
|||||||
}
|
}
|
||||||
setState(() => _submitting = true);
|
setState(() => _submitting = true);
|
||||||
controller.setReviewPlace(selectedPlace.name);
|
controller.setReviewPlace(selectedPlace.name);
|
||||||
await controller.publishReview(coordinate: selectedPlace.coordinate);
|
await controller.publishReview(place: selectedPlace);
|
||||||
if (!context.mounted) {
|
if (!context.mounted) {
|
||||||
return;
|
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;
|
final value = state.requireValue;
|
||||||
if (!value.hasTelegramAuth) {
|
if (!value.hasTelegramAuth) {
|
||||||
throw StateError('Открой через Telegram, чтобы оставить голос.');
|
throw StateError('Открой через Telegram, чтобы оставить голос.');
|
||||||
}
|
}
|
||||||
|
|
||||||
final draft = value.reviewDraft;
|
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(
|
await _api.createVoiceExperience(
|
||||||
googlePlaceId: 'manual-${point.latitude}-${point.longitude}-$placeName',
|
googlePlaceId: place.googlePlaceId,
|
||||||
googleName: placeName,
|
googleName: place.name,
|
||||||
coordinate: point,
|
coordinate: place.coordinate,
|
||||||
durationSeconds: draft.duration.inSeconds,
|
durationSeconds: draft.duration.inSeconds,
|
||||||
audioObjectKey: 'web-recording-${DateTime.now().microsecondsSinceEpoch}',
|
audioObjectKey: 'web-recording-${DateTime.now().microsecondsSinceEpoch}',
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user