Merge pull request #6212 from vector-im/fix/mna/6209-wrong-live-status

Fix wrong status of live location sharing in timeline (PSF-1073)
This commit is contained in:
Maxime NATUREL 2022-06-08 09:40:33 +02:00 committed by GitHub
commit 73568dbc86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

1
changelog.d/6209.bugfix Normal file
View file

@ -0,0 +1 @@
Fix wrong status of live location sharing in timeline

View file

@ -75,6 +75,7 @@ internal class DeactivateLiveLocationShareWorker(context: Context, params: Worke
private suspend fun deactivateLiveLocationShare(params: Params) {
awaitTransaction(realmConfiguration) { realm ->
Timber.d("deactivating live with id=${params.eventId}")
val aggregatedSummary = LiveLocationShareAggregatedSummaryEntity.get(
realm = realm,
roomId = params.roomId,

View file

@ -67,16 +67,18 @@ internal class LiveLocationAggregationProcessor @Inject constructor(
eventId = targetEventId
)
Timber.d("updating summary of id=$targetEventId with isLive=${content.isLive}")
// remote event can stay with isLive == true while the local summary is no more active
val isActive = aggregatedSummary.isActive.orTrue() && isLive
val endOfLiveTimestampMillis = content.getBestTimestampMillis()?.let { it + (content.timeout ?: 0) }
Timber.d("updating summary of id=$targetEventId with isActive=$isActive and endTimestamp=$endOfLiveTimestampMillis")
aggregatedSummary.endOfLiveTimestampMillis = endOfLiveTimestampMillis
aggregatedSummary.isActive = isLive
aggregatedSummary.isActive = isActive
aggregatedSummary.userId = event.senderId
deactivateAllPreviousBeacons(realm, roomId, event.senderId, targetEventId)
if (isLive) {
if (isActive) {
scheduleDeactivationAfterTimeout(targetEventId, roomId, endOfLiveTimestampMillis)
} else {
cancelDeactivationAfterTimeout(targetEventId, roomId)
@ -90,6 +92,7 @@ internal class LiveLocationAggregationProcessor @Inject constructor(
val workData = WorkerParamsFactory.toData(workParams)
val workName = DeactivateLiveLocationShareWorker.getWorkName(eventId = eventId, roomId = roomId)
val workDelayMillis = (endOfLiveTimestampMillis - clock.epochMillis()).coerceAtLeast(0)
Timber.d("scheduling deactivation of $eventId after $workDelayMillis millis")
val workRequest = workManagerProvider.matrixOneTimeWorkRequestBuilder<DeactivateLiveLocationShareWorker>()
.setInitialDelay(workDelayMillis, TimeUnit.MILLISECONDS)
.setInputData(workData)