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
@@ -25,6 +25,7 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
_professionalRepository = professionRepository,
|
||||
super(CreateServiceInitial()) {
|
||||
on<CreateService>(_onCreateService);
|
||||
on<BlockSlot>(_onBlockSlot);
|
||||
on<LoadService>(_onLoadService);
|
||||
on<UpdateServiceStatus>(_onUpdateServiceStatus);
|
||||
on<LoadServicesForUser>(_onLoadServicesForUser);
|
||||
@@ -72,6 +73,17 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onBlockSlot(BlockSlot event, Emitter<ServiceState> emit) async {
|
||||
try {
|
||||
emit(CreateServiceLoading());
|
||||
final serviceId = await _serviceRepository.blockSlot(event.day, event.hour1);
|
||||
emit(CreateServiceSuccess(serviceId));
|
||||
} catch (e) {
|
||||
log(e.toString());
|
||||
emit(CreateServiceFailure());
|
||||
}
|
||||
}
|
||||
|
||||
void _onLoadService(LoadService event, Emitter<ServiceState> emit) async {
|
||||
try {
|
||||
final serviceStream = _serviceRepository.getService(event.serviceId);
|
||||
@@ -108,7 +120,11 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
final professionsDir = {for (var e in professionsList) e.id: e};
|
||||
|
||||
final servicesInfo = services.map((e) {
|
||||
final servicesInfo = services
|
||||
.where((e) =>
|
||||
usersDir.containsKey(e.professionalId) &&
|
||||
professionsDir.containsKey(e.professionalId))
|
||||
.map((e) {
|
||||
return ServiceInfoUI(
|
||||
service: e,
|
||||
user: usersDir[e.professionalId]!,
|
||||
@@ -141,7 +157,9 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
final usersDir = {for (var e in users) e.id: e};
|
||||
|
||||
final servicesInfo = services.map((e) {
|
||||
final servicesInfo = services
|
||||
.where((e) => usersDir.containsKey(e.userId))
|
||||
.map((e) {
|
||||
return ServiceInfoUI(
|
||||
service: e,
|
||||
user: usersDir[e.userId]!,
|
||||
@@ -180,7 +198,11 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
final professionsDir = {for (var e in professionsList) e.id: e};
|
||||
|
||||
final servicesInfo = services.map((e) {
|
||||
final servicesInfo = services
|
||||
.where((e) =>
|
||||
usersDir.containsKey(e.professionalId) &&
|
||||
professionsDir.containsKey(e.professionalId))
|
||||
.map((e) {
|
||||
return ServiceInfoUI(
|
||||
service: e,
|
||||
user: usersDir[e.professionalId]!,
|
||||
@@ -213,7 +235,9 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
final usersDir = {for (var e in users) e.id: e};
|
||||
|
||||
final servicesInfo = services.map((e) {
|
||||
final servicesInfo = services
|
||||
.where((e) => usersDir.containsKey(e.userId))
|
||||
.map((e) {
|
||||
return ServiceInfoUI(
|
||||
service: e,
|
||||
user: usersDir[e.userId]!,
|
||||
@@ -246,7 +270,9 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
final usersDir = {for (var e in users) e.id: e};
|
||||
|
||||
final servicesInfo = services.map((e) {
|
||||
final servicesInfo = services
|
||||
.where((e) => usersDir.containsKey(e.userId))
|
||||
.map((e) {
|
||||
return ServiceInfoUI(
|
||||
service: e,
|
||||
user: usersDir[e.userId]!,
|
||||
|
||||
Reference in New Issue
Block a user