fix: port 7 web features and repair the endless-loading screens
Root cause behind most "stuck loading" reports: the backend changed shape (schedules became an array, location_preferences a string) while the mobile parser still hard-cast to Map/int. The TypeError was swallowed by a silent catch that returned null, and screens only handled the success state, so a parse failure rendered as a permanent spinner. Same class of bug appeared across service lists via non-null map lookups and a total absence of request timeouts. Ported from prosappweb: - in-app suggestions (POST /suggestions) - policies/terms from GET /settings/policies - configurable appointment length (slot_duration_minutes) - block/unblock calendar slots (POST /services/block) - GPS city detection on the profile (Nominatim) - server-side professional search with haversine distance - retry cooldown after a rejected professional application Reliability: - parse schedules array (day_of_week 0=Mon) and string location_preferences - read times as wall clock, so 08:00 stays 08:00 across timezones - carry minutes into hours in TimeOfDay.add; a minute-based step used to loop forever and freeze the calendar (covered by test/time_slots_test.dart) - semver update check instead of string equality, which blocked every build that did not exactly match the configured version - request timeouts across all repositories - surface HTTP >= 400 instead of reporting failed writes as success - error states with retry instead of an indefinite shimmer Includes pre-existing uncommitted work from the UI redesign. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
06a89df690
commit
8631e6f729
@@ -19,8 +19,11 @@ import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
import 'package:prosappco/constansts.dart';
|
||||
import 'package:prosappco/local_notifications/local_notifications.dart';
|
||||
import 'package:prosappco/screens/lists/professional_list_screen.dart';
|
||||
import 'package:prosappco/screens/profile/profile_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_service_screen.dart';
|
||||
import 'package:prosappco/utils/nominatim_geocoder.dart';
|
||||
import 'package:prosappco/utils/time_of_day_extension.dart';
|
||||
import 'package:prosappco/utils/version_utils.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
@@ -42,7 +45,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
|
||||
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||
SettingEntity? settings;
|
||||
late String appVersion;
|
||||
String appVersion = '';
|
||||
|
||||
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
||||
|
||||
@@ -125,7 +128,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
|
||||
void _checkForUpdate(SettingEntity settings) {
|
||||
if (Platform.isAndroid) {
|
||||
if (appVersion != settings.versionAndroid) {
|
||||
if (isUpdateRequired(appVersion, settings.versionAndroid)) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -165,7 +168,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
}
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
if (appVersion != settings.versionIos) {
|
||||
if (isUpdateRequired(appVersion, settings.versionIos)) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -377,9 +380,16 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
state.user?.phone == null) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Por favor completa tu perfil y agrega tu celular'),
|
||||
SnackBar(
|
||||
content: const Text('Por favor completa tu perfil y agrega tu celular'),
|
||||
action: SnackBarAction(
|
||||
label: 'Ir al perfil',
|
||||
onPressed: () {
|
||||
Navigator.push(context, CupertinoPageRoute(
|
||||
builder: (context) => const ProfileScreen(),
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
@@ -552,7 +562,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
description: _observationController.text,
|
||||
range1Hour1: horaSeleccionada!,
|
||||
range1Hour2:
|
||||
horaSeleccionada!.add(hour: 2),
|
||||
horaSeleccionada!.add(
|
||||
minute: profesionalSeleccionado!
|
||||
.professionalInfo
|
||||
.slotDurationMinutes),
|
||||
rate: profesionalSeleccionado!
|
||||
.professionalInfo.rate,
|
||||
location: serviceLocationPreference!,
|
||||
@@ -577,7 +590,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
description: _observationController.text,
|
||||
range1Hour1: horaSeleccionada!,
|
||||
range1Hour2:
|
||||
horaSeleccionada!.add(hour: 2),
|
||||
horaSeleccionada!.add(
|
||||
minute: profesionalSeleccionado!
|
||||
.professionalInfo
|
||||
.slotDurationMinutes),
|
||||
rate: '0',
|
||||
location: serviceLocationPreference!,
|
||||
),
|
||||
@@ -600,7 +616,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
description: _observationController.text,
|
||||
range1Hour1: horaSeleccionada!,
|
||||
range1Hour2:
|
||||
horaSeleccionada!.add(hour: 2),
|
||||
horaSeleccionada!.add(
|
||||
minute: profesionalSeleccionado!
|
||||
.professionalInfo
|
||||
.slotDurationMinutes),
|
||||
rate: profesionalSeleccionado!
|
||||
.professionalInfo.rate,
|
||||
location: serviceLocationPreference!,
|
||||
@@ -620,7 +639,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
description: _observationController.text,
|
||||
range1Hour1: horaSeleccionada!,
|
||||
range1Hour2:
|
||||
horaSeleccionada!.add(hour: 2),
|
||||
horaSeleccionada!.add(
|
||||
minute: profesionalSeleccionado!
|
||||
.professionalInfo
|
||||
.slotDurationMinutes),
|
||||
rate: '0',
|
||||
location: serviceLocationPreference!,
|
||||
),
|
||||
@@ -745,6 +767,25 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
await _locateByUserCity();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _locateByUserCity() async {
|
||||
try {
|
||||
final city = Injector.appInstance.get<MyUserBloc>().state.user?.city;
|
||||
if (city == null || city.isEmpty) return;
|
||||
|
||||
final coords = await NominatimGeocoder.forwardGeocodeCity(city);
|
||||
if (coords == null) return;
|
||||
|
||||
setState(() {
|
||||
_currentP = LatLng(coords.$1, coords.$2);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
|
||||
Reference in New Issue
Block a user