Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd7e6cfa authored by Ellen Poe's avatar Ellen Poe
Browse files

Merge branch 'ellenhp/location_puck_matches_flyto' into 'main'

Ensure that the location puck always follows the camera animation

See merge request e/os/cardinal!21
parents 47aca395 9e8bc338
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ class LocationRepository @Inject constructor(

            cachedLocation?.let { location ->
                if (isLocationRecent(location, currentTime)) {
                    _locationFlow.value = location
                    return location
                }
            }
@@ -465,6 +466,13 @@ class LocationRepository @Inject constructor(
                } catch (_: Exception) {
                    // Ignore exceptions during cleanup
                }
                // This location will be used as if it's fresh by the caller, for e.g. a camera animateTo
                // operation. In order for the location puck to match the location we're animating to, it
                // makes sense to update the locationFlow too. This is "incorrect" because the last known
                // location is potentially stale and the location flow is supposed to contain fresh
                // locations, but if we're timing out while requesting a location, the locationFlow is
                // already stale to begin with, or more likely, empty.
                lastKnownLocation?.let { _locationFlow.value = it }
                locationDeferred.complete(lastKnownLocation)
            }
        }