mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Rely only on isActive field on UI side
This commit is contained in:
parent
683a9cdfff
commit
b05fc763ae
1 changed files with 1 additions and 12 deletions
|
@ -33,7 +33,6 @@ import im.vector.app.features.home.room.detail.timeline.item.MessageLiveLocation
|
|||
import im.vector.app.features.location.INITIAL_MAP_ZOOM_IN_TIMELINE
|
||||
import im.vector.app.features.location.UrlMapProvider
|
||||
import im.vector.app.features.location.toLocationData
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.threeten.bp.LocalDateTime
|
||||
|
@ -129,7 +128,7 @@ class LiveLocationShareMessageItemFactory @Inject constructor(
|
|||
private fun getViewState(liveLocationShareSummaryData: LiveLocationShareSummaryData?): LiveLocationShareViewState {
|
||||
return when {
|
||||
liveLocationShareSummaryData?.isActive == null -> LiveLocationShareViewState.Unkwown
|
||||
liveLocationShareSummaryData.isActive.not() || isLiveTimedOut(liveLocationShareSummaryData) -> LiveLocationShareViewState.Inactive
|
||||
liveLocationShareSummaryData.isActive.not() -> LiveLocationShareViewState.Inactive
|
||||
liveLocationShareSummaryData.isActive && liveLocationShareSummaryData.lastGeoUri.isNullOrEmpty() -> LiveLocationShareViewState.Loading
|
||||
else ->
|
||||
LiveLocationShareViewState.Running(
|
||||
|
@ -139,16 +138,6 @@ class LiveLocationShareMessageItemFactory @Inject constructor(
|
|||
}.also { viewState -> Timber.d("computed viewState: $viewState") }
|
||||
}
|
||||
|
||||
private fun isLiveTimedOut(liveLocationShareSummaryData: LiveLocationShareSummaryData): Boolean {
|
||||
return getEndOfLiveDateTime(liveLocationShareSummaryData)
|
||||
?.let { endOfLive ->
|
||||
// this will only cover users with different timezones but not users with manually time set
|
||||
val now = LocalDateTime.now()
|
||||
now.isAfter(endOfLive)
|
||||
}
|
||||
.orFalse()
|
||||
}
|
||||
|
||||
private fun getEndOfLiveDateTime(liveLocationShareSummaryData: LiveLocationShareSummaryData): LocalDateTime? {
|
||||
return liveLocationShareSummaryData.endOfLiveTimestampMillis?.let { DateProvider.toLocalDateTime(timestamp = it) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue