new backend 29-04-2026
This commit is contained in:
@@ -412,6 +412,9 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
|
||||
void emitLocationToSocket(LatLng pos, double head, double spd) {
|
||||
String status = box.read(BoxName.statusDriverLocation) ?? 'on';
|
||||
String? currentRideStatus = box.read(BoxName.rideStatus);
|
||||
String? storedPassengerId = box.read(BoxName.passengerID);
|
||||
String? storedRideId = box.read(BoxName.rideId);
|
||||
|
||||
// Basic payload
|
||||
var payload = {
|
||||
@@ -424,16 +427,14 @@ class LocationController extends GetxController with WidgetsBindingObserver {
|
||||
'distance': totalDistance,
|
||||
};
|
||||
|
||||
// 🔥 CRITICAL FIX: Inject Passenger ID if a ride is active 🔥
|
||||
if (Get.isRegistered<MapDriverController>()) {
|
||||
final mapCtrl = Get.find<MapDriverController>();
|
||||
// 🔥 القرار الذكي: حقن بيانات الراكب إذا كان هناك رحلة نشطة في الـ Box 🔥
|
||||
bool hasActiveRide = (currentRideStatus == 'Begin' ||
|
||||
currentRideStatus == 'Apply' ||
|
||||
currentRideStatus == 'Arrived');
|
||||
|
||||
// Check if ride is started/active and we have a passenger ID
|
||||
if (mapCtrl.isRideStarted && mapCtrl.passengerId != null) {
|
||||
payload['passenger_id'] =
|
||||
mapCtrl.passengerId; // This triggers the PHP forwarding
|
||||
payload['ride_id'] = mapCtrl.rideId; // Good for debugging
|
||||
}
|
||||
if (hasActiveRide && storedPassengerId != null) {
|
||||
payload['passenger_id'] = storedPassengerId;
|
||||
payload['ride_id'] = storedRideId;
|
||||
}
|
||||
|
||||
// DebugLog.print to verify
|
||||
|
||||
Reference in New Issue
Block a user