feat: send immediate location update when precision setting changes

When the user changes their location precision setting, immediately
send an update to all active sharing recipients with the new precision
rather than waiting for the next scheduled update.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
torlando-tech
2025-12-20 01:38:47 -05:00
parent 66e2da2f19
commit f2857ced3d
2 changed files with 30 additions and 0 deletions

View File

@@ -180,6 +180,34 @@ class LocationSharingManager
}
}
/**
* Send an immediate location update to all active sharing recipients.
*
* Call this when settings change (e.g., precision) to immediately notify
* recipients of the new settings rather than waiting for the next scheduled update.
*/
@SuppressLint("MissingPermission")
fun sendImmediateUpdate() {
if (_activeSessions.value.isEmpty()) {
Log.d(TAG, "No active sessions, skipping immediate update")
return
}
// Use last known location if available, otherwise get current location
if (lastLocation != null) {
Log.d(TAG, "Sending immediate update with cached location")
sendLocationToRecipients(lastLocation!!)
} else {
fusedLocationClient.lastLocation.addOnSuccessListener { location ->
location?.let {
Log.d(TAG, "Sending immediate update with fresh location")
lastLocation = it
sendLocationToRecipients(it)
} ?: Log.w(TAG, "No location available for immediate update")
}
}
}
/**
* Stop sharing with a specific contact.
*

View File

@@ -1204,6 +1204,8 @@ class SettingsViewModel
viewModelScope.launch {
settingsRepository.saveLocationPrecisionRadius(radiusMeters)
Log.d(TAG, "Location precision radius set to: ${radiusMeters}m")
// Send immediate update to all active sharing recipients with new precision
locationSharingManager.sendImmediateUpdate()
}
}
}