Fix web routing and SW loader
Build and deploy Flutter Web / build (push) Successful in 4m23s

This commit is contained in:
Ruslan Bakiev
2026-06-22 10:27:04 +07:00
parent ee4e1f5dae
commit 9d7ed4f6e5
7 changed files with 41 additions and 45 deletions
+1 -6
View File
@@ -12,14 +12,10 @@ class MapflowRoutes {
static const addExperience = '/experience/new'; static const addExperience = '/experience/new';
static const adminReviews = '/admin/reviews'; static const adminReviews = '/admin/reviews';
static String addExperienceLocation({ static String addExperienceLocation({required LatLng? coordinate}) {
required LatLng? coordinate,
required bool hasTelegramAuth,
}) {
return Uri( return Uri(
path: addExperience, path: addExperience,
queryParameters: { queryParameters: {
'telegramAuth': hasTelegramAuth ? '1' : '0',
if (coordinate != null) ...{ if (coordinate != null) ...{
'lat': coordinate.latitude.toString(), 'lat': coordinate.latitude.toString(),
'lng': coordinate.longitude.toString(), 'lng': coordinate.longitude.toString(),
@@ -46,7 +42,6 @@ GoRouter createAppRouter() {
key: state.pageKey, key: state.pageKey,
child: AddExperienceFlow( child: AddExperienceFlow(
coordinate: _coordinateFromQuery(queryParameters), coordinate: _coordinateFromQuery(queryParameters),
hasTelegramAuth: queryParameters['telegramAuth'] != '0',
), ),
transitionsBuilder: (context, animation, _, child) { transitionsBuilder: (context, animation, _, child) {
return SlideTransition( return SlideTransition(
@@ -120,11 +120,10 @@ class _MapContent extends StatelessWidget {
child: _UserAvatar( child: _UserAvatar(
user: state.currentUser, user: state.currentUser,
onAdminReviews: state.currentUser?.isAdmin == true onAdminReviews: state.currentUser?.isAdmin == true
? () => context.push('/admin/reviews') ? () => context.push(MapflowRoutes.adminReviews)
: null, : null,
onLogout: () { onLogout: () {
telegram_session.clearMapflowSession(); telegram_session.clearMapflowSession();
placeCubit.load();
telegram_session.reloadApp(); telegram_session.reloadApp();
}, },
), ),
@@ -225,12 +224,7 @@ class _MapContent extends StatelessWidget {
} }
void _openAddFlow(BuildContext context, LatLng? coordinate) { void _openAddFlow(BuildContext context, LatLng? coordinate) {
context.push( context.push(MapflowRoutes.addExperienceLocation(coordinate: coordinate));
MapflowRoutes.addExperienceLocation(
coordinate: coordinate,
hasTelegramAuth: state.hasTelegramAuth,
),
);
} }
} }
@@ -976,14 +970,9 @@ class _PlaceCarousel extends StatelessWidget {
} }
class AddExperienceFlow extends StatefulWidget { class AddExperienceFlow extends StatefulWidget {
const AddExperienceFlow({ const AddExperienceFlow({super.key, required this.coordinate});
super.key,
required this.coordinate,
required this.hasTelegramAuth,
});
final LatLng? coordinate; final LatLng? coordinate;
final bool hasTelegramAuth;
@override @override
State<AddExperienceFlow> createState() => _AddExperienceFlowState(); State<AddExperienceFlow> createState() => _AddExperienceFlowState();
@@ -1137,19 +1126,22 @@ class _AddExperienceFlowState extends State<AddExperienceFlow> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final tokens = context.mapflowTokens; final tokens = context.mapflowTokens;
final controller = context.read<PlaceCubit>(); final controller = context.read<PlaceCubit>();
final hasTelegramAuth = context.select(
(PlaceCubit cubit) => cubit.state.placeState?.hasTelegramAuth ?? false,
);
final informationProgress = (_informationUnits / _minimumInformationUnits) final informationProgress = (_informationUnits / _minimumInformationUnits)
.clamp(0.0, 1.0); .clamp(0.0, 1.0);
final content = switch (_step) { final content = switch (_step) {
0 => _VoiceStep( 0 => _VoiceStep(
placeName: '', placeName: '',
promptHints: _voicePromptHints, promptHints: _voicePromptHints,
hasTelegramAuth: widget.hasTelegramAuth, hasTelegramAuth: hasTelegramAuth,
informationProgress: informationProgress, informationProgress: informationProgress,
isRecording: _recording, isRecording: _recording,
isSubmitting: _submitting, isSubmitting: _submitting,
micAllowed: _micAllowed, micAllowed: _micAllowed,
liveLevel: _liveLevel, liveLevel: _liveLevel,
canContinue: widget.hasTelegramAuth && informationProgress >= 1, canContinue: hasTelegramAuth && informationProgress >= 1,
onToggleRecording: _toggleRecording, onToggleRecording: _toggleRecording,
onNext: () async { onNext: () async {
if (_recording) { if (_recording) {
+2
View File
@@ -1,10 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_web_plugins/url_strategy.dart';
import 'app/app.dart'; import 'app/app.dart';
import 'shared/auth/telegram_session.dart' as telegram_session; import 'shared/auth/telegram_session.dart' as telegram_session;
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
usePathUrlStrategy();
telegram_session.configureTelegramWebApp(); telegram_session.configureTelegramWebApp();
runApp(const MapflowApp()); runApp(const MapflowApp());
} }
+12 -1
View File
@@ -71,5 +71,16 @@ void openExternalUrl(String url) {
} }
void reloadApp() { 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();
} }
+13 -13
View File
@@ -5,18 +5,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: _fe_analyzer_shared name: _fe_analyzer_shared
sha256: a49d6cf99e8d8e7a8e93668d09ced0bbdb954d0b4fccc2f5f9241c6b87fad95c sha256: "8d7ff3948166b8ec5da0fbb5962000926b8e02f2ed9b3e51d1738905fbd4c98d"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "99.0.0" version: "93.0.0"
analyzer: analyzer:
dependency: transitive dependency: transitive
description: description:
name: analyzer name: analyzer
sha256: "663efa951fb8a45e06f491223a604c93820598f20e6a99c25617a1576065e8b7" sha256: de7148ed2fcec579b19f122c1800933dfa028f6d9fd38a152b04b1516cec120b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "12.1.0" version: "10.0.1"
archive: archive:
dependency: transitive dependency: transitive
description: description:
@@ -213,10 +213,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: dart_style name: dart_style
sha256: a4c1ccfee44c7e75ed80484071a5c142a385345e658fd8bd7c4b5c97e7198f98 sha256: "29f7ecc274a86d32920b1d9cfc7502fa87220da41ec60b55f329559d5732e2b2"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.8" version: "3.1.7"
dbus: dbus:
dependency: transitive dependency: transitive
description: description:
@@ -261,10 +261,10 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: ferry_generator name: ferry_generator
sha256: f68c632e23c2ac5f493c05b92135d026cfbd58d658a5056cd8be612f599d505a sha256: "7c3ff4b262301055b33553e9c67c4c8495e93961987683e95a4f3a3ef212eaa3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.0+5" version: "0.12.0+4"
ferry_store: ferry_store:
dependency: transitive dependency: transitive
description: description:
@@ -356,7 +356,7 @@ packages:
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: "direct main"
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
@@ -660,10 +660,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.18.0" version: "1.17.0"
mgrs_dart: mgrs_dart:
dependency: transitive dependency: transitive
description: description:
@@ -1057,10 +1057,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.11" version: "0.7.10"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
+3 -1
View File
@@ -30,6 +30,8 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_web_plugins:
sdk: flutter
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
@@ -60,7 +62,7 @@ dev_dependencies:
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
flutter_lints: ^6.0.0 flutter_lints: ^6.0.0
ferry_generator: ^0.12.0+5 ferry_generator: ^0.12.0+4
build_runner: ^2.15.0 build_runner: ^2.15.0
sw: ^0.1.5 sw: ^0.1.5
+2 -8
View File
@@ -20,15 +20,8 @@
<title>MapFlow</title> <title>MapFlow</title>
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<style> <style>
#sw-loading .sw-title,
#sw-loading .sw-status,
#sw-loading .sw-percentage {
display: none !important;
}
#sw-loading { #sw-loading {
background: #0d1b2a !important; background: #0d1b2a !important;
gap: 0 !important;
} }
</style> </style>
</head> </head>
@@ -86,9 +79,10 @@
src="bootstrap.js" src="bootstrap.js"
data-config='{ data-config='{
"logo": "icons/Icon-192.png?v={{sw_version}}", "logo": "icons/Icon-192.png?v={{sw_version}}",
"title": "MapFlow",
"theme": "dark", "theme": "dark",
"color": "#46d3b1", "color": "#46d3b1",
"showPercentage": false "showPercentage": true
}' }'
></script> ></script>
</body> </body>