This commit is contained in:
@@ -12,14 +12,10 @@ class MapflowRoutes {
|
||||
static const addExperience = '/experience/new';
|
||||
static const adminReviews = '/admin/reviews';
|
||||
|
||||
static String addExperienceLocation({
|
||||
required LatLng? coordinate,
|
||||
required bool hasTelegramAuth,
|
||||
}) {
|
||||
static String addExperienceLocation({required LatLng? coordinate}) {
|
||||
return Uri(
|
||||
path: addExperience,
|
||||
queryParameters: {
|
||||
'telegramAuth': hasTelegramAuth ? '1' : '0',
|
||||
if (coordinate != null) ...{
|
||||
'lat': coordinate.latitude.toString(),
|
||||
'lng': coordinate.longitude.toString(),
|
||||
@@ -46,7 +42,6 @@ GoRouter createAppRouter() {
|
||||
key: state.pageKey,
|
||||
child: AddExperienceFlow(
|
||||
coordinate: _coordinateFromQuery(queryParameters),
|
||||
hasTelegramAuth: queryParameters['telegramAuth'] != '0',
|
||||
),
|
||||
transitionsBuilder: (context, animation, _, child) {
|
||||
return SlideTransition(
|
||||
|
||||
@@ -120,11 +120,10 @@ class _MapContent extends StatelessWidget {
|
||||
child: _UserAvatar(
|
||||
user: state.currentUser,
|
||||
onAdminReviews: state.currentUser?.isAdmin == true
|
||||
? () => context.push('/admin/reviews')
|
||||
? () => context.push(MapflowRoutes.adminReviews)
|
||||
: null,
|
||||
onLogout: () {
|
||||
telegram_session.clearMapflowSession();
|
||||
placeCubit.load();
|
||||
telegram_session.reloadApp();
|
||||
},
|
||||
),
|
||||
@@ -225,12 +224,7 @@ class _MapContent extends StatelessWidget {
|
||||
}
|
||||
|
||||
void _openAddFlow(BuildContext context, LatLng? coordinate) {
|
||||
context.push(
|
||||
MapflowRoutes.addExperienceLocation(
|
||||
coordinate: coordinate,
|
||||
hasTelegramAuth: state.hasTelegramAuth,
|
||||
),
|
||||
);
|
||||
context.push(MapflowRoutes.addExperienceLocation(coordinate: coordinate));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -976,14 +970,9 @@ class _PlaceCarousel extends StatelessWidget {
|
||||
}
|
||||
|
||||
class AddExperienceFlow extends StatefulWidget {
|
||||
const AddExperienceFlow({
|
||||
super.key,
|
||||
required this.coordinate,
|
||||
required this.hasTelegramAuth,
|
||||
});
|
||||
const AddExperienceFlow({super.key, required this.coordinate});
|
||||
|
||||
final LatLng? coordinate;
|
||||
final bool hasTelegramAuth;
|
||||
|
||||
@override
|
||||
State<AddExperienceFlow> createState() => _AddExperienceFlowState();
|
||||
@@ -1137,19 +1126,22 @@ class _AddExperienceFlowState extends State<AddExperienceFlow> {
|
||||
Widget build(BuildContext context) {
|
||||
final tokens = context.mapflowTokens;
|
||||
final controller = context.read<PlaceCubit>();
|
||||
final hasTelegramAuth = context.select(
|
||||
(PlaceCubit cubit) => cubit.state.placeState?.hasTelegramAuth ?? false,
|
||||
);
|
||||
final informationProgress = (_informationUnits / _minimumInformationUnits)
|
||||
.clamp(0.0, 1.0);
|
||||
final content = switch (_step) {
|
||||
0 => _VoiceStep(
|
||||
placeName: '',
|
||||
promptHints: _voicePromptHints,
|
||||
hasTelegramAuth: widget.hasTelegramAuth,
|
||||
hasTelegramAuth: hasTelegramAuth,
|
||||
informationProgress: informationProgress,
|
||||
isRecording: _recording,
|
||||
isSubmitting: _submitting,
|
||||
micAllowed: _micAllowed,
|
||||
liveLevel: _liveLevel,
|
||||
canContinue: widget.hasTelegramAuth && informationProgress >= 1,
|
||||
canContinue: hasTelegramAuth && informationProgress >= 1,
|
||||
onToggleRecording: _toggleRecording,
|
||||
onNext: () async {
|
||||
if (_recording) {
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
|
||||
import 'app/app.dart';
|
||||
import 'shared/auth/telegram_session.dart' as telegram_session;
|
||||
|
||||
void main() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
usePathUrlStrategy();
|
||||
telegram_session.configureTelegramWebApp();
|
||||
runApp(const MapflowApp());
|
||||
}
|
||||
|
||||
@@ -71,5 +71,16 @@ void openExternalUrl(String url) {
|
||||
}
|
||||
|
||||
void reloadApp() {
|
||||
web.window.location.assign(web.window.location.origin);
|
||||
web.window.location.replace(_currentUrlWithoutTelegramLoginToken());
|
||||
}
|
||||
|
||||
String _currentUrlWithoutTelegramLoginToken() {
|
||||
final uri = Uri.parse(web.window.location.href);
|
||||
final queryParameters = Map<String, String>.of(uri.queryParameters)
|
||||
..remove('telegram_login');
|
||||
return uri
|
||||
.replace(
|
||||
queryParameters: queryParameters.isEmpty ? null : queryParameters,
|
||||
)
|
||||
.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user